1 // Copyright (c) <2012> <Leif Asbrink>
2 //
3 // Permission is hereby granted, free of charge, to any person
4 // obtaining a copy of this software and associated documentation
5 // files (the "Software"), to deal in the Software without restriction,
6 // including without limitation the rights to use, copy, modify,
7 // merge, publish, distribute, sublicense, and/or sell copies of
8 // the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21 // OR OTHER DEALINGS IN THE SOFTWARE.
22
23 #include "globdef.h"
24 #include "uidef.h"
25 #include "rusage.h"
26 #include "thrdef.h"
27 #include "wdef.h"
28 #include "fft1def.h"
29 #include "sdrdef.h"
30
31
32 #define FT_OPEN_BY_SERIAL_NUMBER 1
33 #define FT_OPEN_BY_DESCRIPTION 2
34
35 #define FT_OK 0
36 #define FT_INVALID_HANDLE 1
37 #define FT_DEVICE_NOT_FOUND 2
38 #define FT_DEVICE_NOT_OPENED 3
39 #define FT_IO_ERROR 4
40 #define FT_INSUFFICIENT_RESOURCES 5
41 #define FT_INVALID_PARAMETER 6
42 #define FT_INVALID_BAUD_RATE 7
43 #define FT_DEVICE_NOT_OPENED_FOR_ERASE 8
44 #define FT_DEVICE_NOT_OPENED_FOR_WRITE 9
45 #define FT_FAILED_TO_WRITE_DEVICE 10
46 #define FT_EEPROM_READ_FAILED 11
47 #define FT_EEPROM_WRITE_FAILED 12
48 #define FT_EEPROM_ERASE_FAILED 13
49 #define FT_EEPROM_NOT_PRESENT 14
50 #define FT_EEPROM_NOT_PROGRAMMED 15
51 #define FT_INVALID_ARGS 16
52 #define FT_NOT_SUPPORTED 17
53 #define FT_OTHER_ERROR 18
54
55
56 typedef PVOID FT_HANDLE;
57 typedef ULONG FT_STATUS;
58
59 typedef FT_STATUS (WINAPI *sdr14_Open_Ex)(PVOID, DWORD, FT_HANDLE *);
60 typedef FT_STATUS (WINAPI *sdr14_Read)(FT_HANDLE, LPVOID, DWORD, LPDWORD);
61 typedef FT_STATUS (WINAPI *sdr14_Write)(FT_HANDLE, LPVOID, DWORD, LPDWORD);
62 typedef FT_STATUS (WINAPI *sdr14_close)(FT_HANDLE);
63 typedef FT_STATUS (WINAPI *sdr14_SetTimeouts)(FT_HANDLE, DWORD, DWORD);
64 typedef FT_STATUS (WINAPI *sdr14_SetResetPipeRetryCount)(FT_HANDLE,DWORD);
65 typedef FT_STATUS (WINAPI *sdr14_ResetDevice)(FT_HANDLE);
66 typedef FT_STATUS (WINAPI *sdr14_GetQueueStatus)(FT_HANDLE, LPDWORD);
67
68
69 #include "screendef.h"
70
71 #define UINT8 unsigned char
72 #define INT16 short int
73 #define UINT16 unsigned short int
74 #include "g31ddcapi.h"
75
76
77 char *unable_to_load="Unable to load ";
78
79 sdr14_Write p_sdr14_Write;
80 sdr14_Read p_sdr14_Read;
81 sdr14_close p_sdr14_Close;
82 sdr14_SetTimeouts p_sdr14_SetTimeouts;
83 sdr14_SetResetPipeRetryCount p_sdr14_SetResetPipeRetryCount;
84 sdr14_ResetDevice p_sdr14_ResetDevice;
85 sdr14_GetQueueStatus p_sdr14_GetQueueStatus;
86
87 FT_HANDLE sdr14_handle;
88
89 HINSTANCE h_sdr14;
90
91 HMODULE h_excalibur_api;
92 INT32 h_excalibur_device;
93 char *excalibur_dll_name="G31DDCAPI.dll";
94 G31DDC_OPEN_DEVICE p_excalibur_open_device;
95 G31DDC_CLOSE_DEVICE p_excalibur_close_device;
96 G31DDC_GET_DEVICE_LIST p_excalibur_device_list;
97 G31DDC_GET_DEVICE_INFO p_excalibur_device_info;
98 G31DDC_GET_DDC_INFO p_excalibur_ddc_info;
99 G31DDC_SET_DDC1 p_excalibur_set_ddc1;
100 G31DDC_SET_DDC1_FREQUENCY p_excalibur_set_ddc1_frequency;
101 G31DDC_START_DDC1 p_excalibur_start_ddc1;
102 G31DDC_SET_MW_FILTER p_excalibur_set_mw_filter;
103 G31DDC_SET_ATTENUATOR p_excalibur_set_attenuator;
104 G31DDC_SET_CALLBACKS p_excalibur_set_callbacks;
105 G31DDC_SET_POWER p_excalibur_set_power;
106 G31DDC_SET_DITHERING p_excalibur_set_dithering;
107 G31DDC_START_IF p_excalibur_start_if;
108 G31DDC_STOP_IF p_excalibur_stop_if;
109 G31DDC_STOP_DDC1 p_excalibur_stop_ddc1;
110
111
112 G31DDC_DEVICE_INFO excalibur_dev_info;
113
excalibur_errexit(char * s)114 void excalibur_errexit(char *s)
115 {
116 clear_screen();
117 lir_text(10,5,s);
118 SNDLOG"\n%s",s);
119 lir_text(10,7,press_any_key);
120 await_keyboard();
121 }
122
load_excalibur_library(char * buf)123 int load_excalibur_library(char* buf)
124 {
125 G31DDC_DEVICE_INFO *excalibur_device_list;
126 char s[80];
127 int i, j, count;
128 h_excalibur_api=LoadLibrary(excalibur_dll_name);
129 if(h_excalibur_api==NULL)
130 {
131 sprintf(s,"%s%s",unable_to_load, excalibur_dll_name);
132 excalibur_errexit(s);
133 return 0;
134 }
135 if(write_log)
136 {
137 sprintf(s,"%s successfully loaded.",excalibur_dll_name);
138 lir_text(10,3,s);
139 SNDLOG"\n%s",s);
140 }
141 p_excalibur_device_list=
142 (G31DDC_GET_DEVICE_LIST)GetProcAddress(h_excalibur_api,"GetDeviceList");
143 if(p_excalibur_device_list == NULL)
144 {
145 sprintf(s,"Error in %s",excalibur_dll_name);
146 excalibur_errexit(s);
147 retzer:;
148 FreeLibrary(h_excalibur_api);
149 return 0;
150 }
151 count=p_excalibur_device_list(NULL,0);
152 if(count == 0)goto retzer;
153 if(count >MAX_EXCALIBUR_DEVICES)count=MAX_EXCALIBUR_DEVICES;
154 excalibur_device_list=malloc(count*sizeof(G31DDC_DEVICE_INFO));
155 if(excalibur_device_list == NULL)
156 {
157 lirerr(631952);
158 goto retzer;
159 }
160 count=p_excalibur_device_list(excalibur_device_list,
161 count*sizeof(G31DDC_DEVICE_INFO));
162 for(i=0; i<count; i++)
163 {
164 for(j=0; j<9; j++)
165 {
166 buf[9*i+j]=excalibur_device_list[i].SerialNumber[j];
167 }
168 }
169 free(excalibur_device_list);
170 FreeLibrary(h_excalibur_api);
171 return count;
172 }
173
open_excalibur(void)174 void open_excalibur(void)
175 {
176 int i;
177 char sernum[16];
178 char s[80];
179 FILE *excalibur_sernum_file;
180 excalibur_sernum_file=fopen(excalibur_sernum_filename,"r");
181 if(excalibur_sernum_file == NULL)
182 {
183 lirerr(1333);
184 return;
185 }
186 i=fscanf(excalibur_sernum_file,"%9s",sernum);
187 fclose(excalibur_sernum_file);
188 if(i==0)
189 {
190 lirerr(1334);
191 return;
192 }
193 h_excalibur_api=LoadLibrary(excalibur_dll_name);
194 if(h_excalibur_api==NULL)
195 {
196 sprintf(s,"%s%s",unable_to_load, excalibur_dll_name);
197 excalibur_errexit(s);
198 return;
199 }
200 if(write_log)
201 {
202 sprintf(s,"%s successfully loaded.",excalibur_dll_name);
203 lir_text(10,3,s);
204 SNDLOG"\n%s",s);
205 }
206 p_excalibur_open_device=
207 (G31DDC_OPEN_DEVICE)GetProcAddress(h_excalibur_api,"OpenDevice");
208 p_excalibur_close_device=
209 (G31DDC_CLOSE_DEVICE)GetProcAddress(h_excalibur_api,"CloseDevice");
210 if(p_excalibur_open_device == NULL || p_excalibur_close_device == NULL )
211 {
212 sprintf(s,"Error in %s",excalibur_dll_name);
213 excalibur_errexit(s);
214 return;
215 }
216 h_excalibur_device=p_excalibur_open_device(sernum);
217 if(h_excalibur_device < 0)
218 {
219 lirerr(1335);
220 apierr:;
221 FreeLibrary(h_excalibur_api);
222 return;
223 }
224 p_excalibur_device_info=
225 (G31DDC_GET_DEVICE_INFO)GetProcAddress(h_excalibur_api,"GetDeviceInfo");
226 if(p_excalibur_device_info == NULL)
227 {
228 apierr2:;
229 lirerr(1336);
230 p_excalibur_close_device(h_excalibur_device);
231 goto apierr;
232 }
233 p_excalibur_set_ddc1=
234 (G31DDC_SET_DDC1)GetProcAddress(h_excalibur_api,"SetDDC1");
235 if(p_excalibur_set_ddc1 == NULL)goto apierr2;
236 p_excalibur_set_ddc1_frequency=(G31DDC_SET_DDC1_FREQUENCY)
237 GetProcAddress(h_excalibur_api,"SetDDC1Frequency");
238 if(p_excalibur_set_ddc1_frequency == NULL)goto apierr2;
239 p_excalibur_start_ddc1=
240 (G31DDC_START_DDC1)GetProcAddress(h_excalibur_api,"StartDDC1");
241 if(p_excalibur_start_ddc1 == NULL)goto apierr2;
242 p_excalibur_set_mw_filter=
243 (G31DDC_SET_MW_FILTER)GetProcAddress(h_excalibur_api,"SetMWFilter");
244 if(p_excalibur_set_mw_filter == NULL)goto apierr2;
245 p_excalibur_set_attenuator=
246 (G31DDC_SET_ATTENUATOR)GetProcAddress(h_excalibur_api,"SetAttenuator");
247 if(p_excalibur_set_attenuator == NULL)goto apierr2;
248 p_excalibur_set_callbacks=
249 (G31DDC_SET_CALLBACKS)GetProcAddress(h_excalibur_api,"SetCallbacks");
250 if(p_excalibur_set_callbacks == NULL)goto apierr2;
251 p_excalibur_set_power=
252 (G31DDC_SET_POWER)GetProcAddress(h_excalibur_api,"SetPower");
253 if(p_excalibur_set_power == NULL)goto apierr2;
254 p_excalibur_set_dithering=
255 (G31DDC_SET_DITHERING)GetProcAddress(h_excalibur_api,"SetDithering");
256 p_excalibur_start_if=
257 (G31DDC_START_IF)GetProcAddress(h_excalibur_api,"StartIF");
258
259 p_excalibur_stop_if=(G31DDC_STOP_IF)GetProcAddress(h_excalibur_api,"StopIF");
260 if(p_excalibur_stop_if == NULL)goto apierr2;
261 p_excalibur_stop_ddc1=
262 (G31DDC_STOP_DDC1)GetProcAddress(h_excalibur_api,"StopDDC1");
263 if(p_excalibur_stop_ddc1 == NULL)goto apierr2;
264 p_excalibur_set_power(h_excalibur_device, TRUE);
265 p_excalibur_device_info(h_excalibur_device, &excalibur_dev_info,
266 sizeof(G31DDC_DEVICE_INFO));
267 p_excalibur_ddc_info=
268 (G31DDC_GET_DDC_INFO)GetProcAddress(h_excalibur_api,"GetDDCInfo");
269 if(p_excalibur_ddc_info == NULL)goto apierr2;
270 no_of_excalibur_rates=excalibur_dev_info.DDCTypeCount;
271 sdr=0;
272 }
273
excalibur_stop(void)274 void excalibur_stop(void)
275 {
276 p_excalibur_stop_ddc1(h_excalibur_device);
277 p_excalibur_stop_if(h_excalibur_device);
278 }
279
close_excalibur(void)280 void close_excalibur(void)
281 {
282 p_excalibur_set_callbacks(h_excalibur_device, NULL,0);
283 p_excalibur_set_power(h_excalibur_device, FALSE);
284 p_excalibur_close_device(h_excalibur_device);
285 FreeLibrary(h_excalibur_api);
286 sdr=-1;
287 }
288
289
290
excalibur_if_callback(CONST SHORT * Buffer,UINT32 NumberOfSamples,WORD MaxADCAmplitude,UINT32 ADCSamplingRate,DWORD_PTR UserData)291 void WINAPI excalibur_if_callback(
292 CONST SHORT *Buffer,
293 UINT32 NumberOfSamples,
294 WORD MaxADCAmplitude,
295 UINT32 ADCSamplingRate,
296 DWORD_PTR UserData)
297 {
298 (void)MaxADCAmplitude;
299 (void)Buffer;
300 (void)NumberOfSamples;
301 (void)ADCSamplingRate;
302 (void)UserData;
303 if(MaxADCAmplitude > ad_maxamp[0])
304 {
305 ad_maxamp[0]=MaxADCAmplitude;
306 }
307 }
308
309
excalibur_ddc1_callback(CONST VOID * Buffer,UINT32 NumberOfSamples,UINT32 BitsPerSample,DWORD_PTR UserData)310 void WINAPI excalibur_ddc1_callback(
311 CONST VOID *Buffer,
312 UINT32 NumberOfSamples,
313 UINT32 BitsPerSample,
314 DWORD_PTR UserData)
315 {
316 // This callback gets called whenever a buffer is ready
317 // from the USB interface
318 (void)UserData;
319 int *ibuf, *obuf;
320 short int *sh_ibuf, *sh_obuf;
321 unsigned int i;
322 if(BitsPerSample == 32)
323 {
324 ibuf=(int*)Buffer;
325 for(i=0; i<2*NumberOfSamples; i+=2)
326 {
327 obuf=(int*)&timf1_char[timf1p_sdr];
328 obuf[0]=ibuf[i ];
329 obuf[1]=ibuf[i+1];
330 timf1p_sdr=(timf1p_sdr+8)&timf1_bytemask;
331 }
332 }
333 else
334 {
335 sh_ibuf=(short int*)Buffer;
336 for(i=0; i<2*NumberOfSamples; i+=2)
337 {
338 sh_obuf=(short int*)&timf1_char[timf1p_sdr];
339 sh_obuf[0]=sh_ibuf[i ];
340 sh_obuf[1]=sh_ibuf[i+1];
341 timf1p_sdr=(timf1p_sdr+4)&timf1_bytemask;
342 }
343 }
344 if(((timf1p_sdr-timf1p_pa+timf1_bytes)&timf1_bytemask) >=
345 (int)snd[RXAD].block_bytes)
346 {
347 SetEvent(rxin1_bufready);
348 }
349 }
350
start_excalibur_read(void)351 void start_excalibur_read(void)
352 {
353 int err;
354 G31DDC_CALLBACKS callbacks;
355 callbacks.IFCallback=(G31DDC_IF_CALLBACK)excalibur_if_callback;
356 callbacks.DDC1StreamCallback=
357 (G31DDC_DDC1_STREAM_CALLBACK)excalibur_ddc1_callback;
358 p_excalibur_set_ddc1(h_excalibur_device,excalib.rate_no);
359 p_excalibur_set_callbacks(h_excalibur_device, &callbacks,0);
360 rxin1_bufready=CreateEvent( NULL, FALSE, FALSE, NULL);
361 if(rxin1_bufready== NULL)
362 {
363 close_excalibur();
364 lirerr(1223);
365 return;
366 }
367 p_excalibur_set_dithering(h_excalibur_device, excalib.dither);
368 timf1p_sdr=timf1p_pa;
369 lir_sched_yield();
370 err=p_excalibur_start_ddc1(h_excalibur_device, snd[RXAD].block_frames);
371 if(err == 0)
372 {
373 lirerr(61125);
374 return;
375 }
376 err=p_excalibur_start_if(h_excalibur_device,500);
377 if(err == 0)lirerr(61126);
378 }
379
select_excalibur_mode(int * line)380 void select_excalibur_mode(int *line)
381 {
382 unsigned int i, j, k;
383 G3XDDC_DDC_INFO info;
384 char s[80];
385 p_excalibur_ddc_info=
386 (G31DDC_GET_DDC_INFO)GetProcAddress(h_excalibur_api,"GetDDCInfo");
387 if(p_excalibur_ddc_info == NULL)
388 {
389 lirerr(1336);
390 return;
391 }
392 lir_text(0,line[0],"No Sampl.Rate Bandwidth Bits");
393 line[0]++;
394 k=no_of_excalibur_rates-1;
395 for(i=0; i<=k; i++)
396 {
397 j=p_excalibur_ddc_info(h_excalibur_device, i, &info);
398 if(j != 0 && (ui.operator_skil != OPERATOR_SKIL_NEWCOMER ||
399 info.SampleRate <=500000))
400 {
401 sprintf(s,"%2d %7d %7d %2d",i,info.SampleRate,
402 info.Bandwidth, info.BitsPerSample);
403 lir_text(0,line[0],s);
404 line[0]++;
405 }
406 else
407 {
408 k=i-1;
409 }
410 }
411 line[0]+=2;
412 lir_text(0,line[0],"Select sampling rate (DDC mode) by line number");
413 excalib.rate_no=lir_get_integer(47, line[0], 2, 0, k);
414 if(kill_all_flag)return;
415 p_excalibur_ddc_info(h_excalibur_device, excalib.rate_no, &info);
416 excalib.sampling_rate=info.SampleRate;
417 ui.rx_addev_no=EXCALIBUR_DEVICE_CODE;
418 ui.rx_input_mode=IQ_DATA+DIGITAL_IQ;
419 if(info.BitsPerSample == 32)ui.rx_input_mode+=DWORD_INPUT;
420 ui.rx_rf_channels=1;
421 ui.rx_ad_channels=2;
422 ui.rx_admode=0;
423
424 line[0]+=2;
425 }
426
set_excalibur_frequency(void)427 void set_excalibur_frequency(void)
428 {
429 double dt1;
430 dt1=fg.passband_center*1000000+0.5;
431 if(dt1 < 0 || dt1 > adjusted_sdr_clock/2)
432 {
433 fg.passband_center=7.05;
434 dt1=fg.passband_center*1000000;
435 }
436 p_excalibur_set_ddc1_frequency(h_excalibur_device,round(dt1));
437 if(1000000.*fg.passband_center-ui.rx_ad_speed/2 < excalib.mw_filter_maxfreq)
438 {
439 p_excalibur_set_mw_filter(h_excalibur_device, FALSE);
440 }
441 else
442 {
443 p_excalibur_set_mw_filter(h_excalibur_device, TRUE);
444 }
445 }
446
set_excalibur_att(void)447 void set_excalibur_att(void)
448 {
449 int i;
450 fg.gain/=3;
451 fg.gain*=3;
452 i=-fg.gain;
453 p_excalibur_set_attenuator(h_excalibur_device, i);
454 }
455
lir_excalibur_read(void)456 void lir_excalibur_read(void)
457 {
458 lir_sched_yield();
459 while(((timf1p_sdr-timf1p_pa+timf1_bytes)&timf1_bytemask) < (int)snd[RXAD].block_bytes)
460 {
461 WaitForSingleObject(rxin1_bufready, INFINITE);
462 }
463 }
464
465 // *********************** SDR-14 and SDR-IQ *************************
466
lir_sdr14_write(char * s,int bytes)467 void lir_sdr14_write(char *s, int bytes)
468 {
469 DWORD written;
470 int totwr, cnt;
471 FT_STATUS err;
472 totwr=0;
473 cnt=0;
474 do_write:;
475 err=p_sdr14_Write(sdr14_handle,&s[totwr],bytes-totwr, &written);
476 if(err != FT_OK)
477 {
478 return;
479 }
480 totwr+=written;
481 if(totwr == bytes)
482 {
483 return;
484 }
485 lir_sched_yield();
486 cnt++;
487 if(cnt < 25)goto do_write;
488 }
489
lir_sdr14_read(char * s,int bytes)490 int lir_sdr14_read(char *s,int bytes)
491 {
492 DWORD i;
493 int cnt, totread;
494 FT_STATUS err;
495 cnt=0;
496 wait:;
497 err=p_sdr14_GetQueueStatus(sdr14_handle, &i);
498 if( (int)i < bytes)
499 {
500 lir_sleep(5000);
501 cnt++;
502 if(cnt < 50)goto wait;
503 }
504 totread=0;
505 cnt=0;
506 do_read:;
507 err=p_sdr14_Read(sdr14_handle, &s[totread], bytes-totread, &i);
508 if(kill_all_flag || err != FT_OK)
509 {
510 return -1;
511 }
512 totread+=i;
513 if(totread == bytes)return bytes;
514 lir_sched_yield();
515 cnt++;
516 if(cnt<25)goto do_read;
517 return -1;
518 }
519
close_sdr14(void)520 void close_sdr14(void)
521 {
522 p_sdr14_Close(sdr14_handle);
523 sdr=-1;
524 FreeLibrary(h_sdr14);
525 }
526
open_sdr14(void)527 void open_sdr14(void)
528 {
529 sdr14_Open_Ex p_sdr14_OpenEx;
530 h_sdr14 = LoadLibrary("ftd2xx.dll");
531 if (h_sdr14 == NULL)
532 {
533 SNDLOG"Failed to load ftd2xx.dll\n");
534 goto open_sdr14_fail2;
535 }
536 SNDLOG"File ftd2xx.dll loaded.\n");
537 p_sdr14_OpenEx=(sdr14_Open_Ex)GetProcAddress(h_sdr14, "FT_OpenEx");
538 if(p_sdr14_OpenEx == NULL)
539 {
540 SNDLOG"Could not find FT_OpenEx\n");
541 goto open_sdr14_fail;
542 }
543 if(p_sdr14_OpenEx(sdr14_name_string,
544 FT_OPEN_BY_DESCRIPTION, &sdr14_handle) != FT_OK)
545 {
546 SNDLOG"Could not open %s\n",sdr14_name_string);
547 if(p_sdr14_OpenEx(sdriq_name_string,
548 FT_OPEN_BY_DESCRIPTION, &sdr14_handle) != FT_OK)
549 {
550 SNDLOG"Could not open %s\n",sdriq_name_string);
551 goto open_sdr14_fail;
552 }
553 else
554 {
555 SNDLOG"%s open OK\n",sdriq_name_string);
556 }
557 }
558 else
559 {
560 SNDLOG"%s open OK\n",sdr14_name_string);
561 }
562 p_sdr14_Read=(sdr14_Read)GetProcAddress(h_sdr14, "FT_Read");
563 p_sdr14_Write=(sdr14_Write)GetProcAddress(h_sdr14, "FT_Write");
564 p_sdr14_Close=(sdr14_close)GetProcAddress(h_sdr14, "FT_Close");
565 p_sdr14_SetTimeouts=(sdr14_SetTimeouts)GetProcAddress(h_sdr14, "FT_SetTimeouts");
566 p_sdr14_SetResetPipeRetryCount=(sdr14_SetResetPipeRetryCount)
567 GetProcAddress(h_sdr14, "FT_SetResetPipeRetryCount");
568 p_sdr14_ResetDevice=(sdr14_ResetDevice)
569 GetProcAddress(h_sdr14, "FT_ResetDevice");
570 p_sdr14_GetQueueStatus=(sdr14_GetQueueStatus)
571 GetProcAddress(h_sdr14, "FT_GetQueueStatus");
572
573
574 if(p_sdr14_Read == NULL ||
575 p_sdr14_Write == NULL ||
576 p_sdr14_Close == NULL ||
577 p_sdr14_SetTimeouts == NULL ||
578 p_sdr14_SetResetPipeRetryCount == NULL ||
579 p_sdr14_ResetDevice == NULL ||
580 p_sdr14_GetQueueStatus == NULL )goto open_sdr14_fail;
581 if(p_sdr14_ResetDevice(sdr14_handle) != FT_OK)goto open_sdr14_fail;
582 if(p_sdr14_SetResetPipeRetryCount(sdr14_handle,100) != FT_OK)
583 goto open_sdr14_fail;
584 if(p_sdr14_SetTimeouts(sdr14_handle,500,500) != FT_OK)
585 goto open_sdr14_fail;
586 sdr=1;
587 SNDLOG"open_sdr14() sucessful.\n");
588 return;
589 open_sdr14_fail:;
590 FreeLibrary(h_sdr14);
591 open_sdr14_fail2:;
592 sdr=-1;
593 SNDLOG"open_sdr14() returned an error.\n");
594 }
595
596