forked from miikasyvanen/FastECU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ2534_win.cpp
692 lines (628 loc) · 17.9 KB
/
J2534_win.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "j2534_win.h"
#if defined(_WIN32) || defined(WIN32) || defined (_WIN64) || defined (WIN64)
#else
#include <dlfcn.h>
#include <CoreFoundation/CFBundle.h>
#include <unistd.h>
#endif
J2534::J2534()
{
hDLL = NULL;
debugMode = false;
isLibraryInitialized = false;
// default to the Openport 2.0 J2534 DLL
#if defined(_WIN32) || defined(WIN32) || defined (_WIN64) || defined (WIN64)
strcpy(dllName,"op20pt32.dll");
#else
strcpy(dllName,"op20pt32.dylib");
#endif
}
void J2534::setDllName(const char* name)
{
strcpy(dllName,name);
}
char* J2534::getLastError()
{
return lastError;
}
bool J2534::valid()
{
return hDLL != NULL;
}
J2534::~J2534()
{
#if defined(OP20PT32_USE_LIB)
if (hDLL)
::OP20PT32_Stop();
#else
#if defined(_WIN32) || defined(WIN32) || defined (_WIN64) || defined (WIN64)
if (hDLL)
FreeLibrary(hDLL);
#else
if (hDLL)
dlclose(hDLL);
#endif
#endif
}
#if defined(_WIN32) || defined(WIN32) || defined (_WIN64) || defined (WIN64)
#if defined(OP20PT32_USE_LIB)
#define getPTfn(name) pf##name = ::name;
#else
#define getPTfn(name) if (!(pf##name = (PF_##name*)GetProcAddress(hDLL,"" #name))) return false
#endif
#else
#if defined(OP20PT32_USE_LIB)
#define getPTfn(name) pf##name = ::name;
#else
#define getPTfn(name) if (!(pf##name = (PF_##name*)dlsym(hDLL,"" #name))) return false
#endif
#endif
#define DBGPRINT_BUFSIZE 10240
bool J2534::getPTfns()
{
if (!hDLL)
return false;
getPTfn(PassThruOpen);
getPTfn(PassThruClose);
getPTfn(PassThruConnect);
getPTfn(PassThruDisconnect);
getPTfn(PassThruReadMsgs);
getPTfn(PassThruWriteMsgs);
getPTfn(PassThruStartPeriodicMsg);
getPTfn(PassThruStopPeriodicMsg);
getPTfn(PassThruStartMsgFilter);
getPTfn(PassThruStopMsgFilter);
getPTfn(PassThruSetProgrammingVoltage);
getPTfn(PassThruReadVersion);
getPTfn(PassThruGetLastError);
getPTfn(PassThruIoctl);
return true;
}
void J2534::dbgprint(const char* Format, ...)
{
va_list arglist;
int cb;
char buffer[DBGPRINT_BUFSIZE];
char *pbuf = buffer;
va_start(arglist, Format);
cb = vsprintf(pbuf, Format, arglist);
if (cb == -1)
{
buffer[sizeof(buffer) - 2] = '\n';
buffer[sizeof(buffer) - 1] = '\0';
}
#if defined(_WIN32) || defined(WIN32) || defined (_WIN64) || defined (WIN64)
OutputDebugStringA(buffer);
#else
printf("%s",buffer);
#endif
va_end(arglist);
}
#define MSG_READ 1
#define MSG_WRITE 2
void J2534::dbgdump(const unsigned char *data,unsigned int datalen,int kind)
{
unsigned int i;
char buf[DBGPRINT_BUFSIZE];
char *pbuf = buf;
if (kind == MSG_READ)
{
*pbuf++ = 'R';
*pbuf++ = ' ';
}
else if (kind == MSG_WRITE)
{
*pbuf++ = 'W';
*pbuf++ = ' ';
}
for (i = 0; i < datalen; i++)
{
if (i > 15 && (i & 0xF) == 0)
pbuf += sprintf(pbuf,"\n ");
pbuf += sprintf(pbuf,"%02X ",data[i]);
}
pbuf += sprintf(pbuf,"\n");
dbgprint(buf);
}
void J2534::dbgprintptmsg(const PASSTHRU_MSG *pMsg,int kind)
{
if (!pMsg)
{
dbgprint("(null message)\n");
return;
}
dbgprint("ProtocolID=%u,RxStatus=%u,TxFlags=%u,Timestamp=%u,DataSize=%u,ExtraDataIndex=%u\n",pMsg->ProtocolID,pMsg->RxStatus,pMsg->TxFlags,pMsg->Timestamp,pMsg->DataSize,pMsg->ExtraDataIndex);
dbgdump(pMsg->Data,pMsg->DataSize,kind);
}
long J2534::LoadJ2534DLL(const char* szDLL)
{
#if defined(OP20PT32_USE_LIB)
szDLL; // unused
if (!hDLL)
::OP20PT32_Start();
#if defined(_WIN32) || defined(WIN32) || defined (_WIN64) || defined (WIN64)
hDLL = (HINSTANCE)1;
#else
hDLL = (void*)1;
#endif
getPTfns();
#else
if (szDLL == NULL)
{
DBGPRINT(("NULL string pointer to J2534 DLL location.\n"));
return(1);
}
#if defined(_WIN32) || defined(WIN32) || defined (_WIN64) || defined (WIN64)
if (!(hDLL = LoadLibraryA(szDLL)))
{
strcpy(lastError,"error loading J2534 DLL");
return false;
}
else if (!getPTfns())
{
// assume unusable if we don't have everything we need
FreeLibrary(hDLL);
hDLL = NULL;
strcpy(lastError,"error loading J2534 DLL function pointers");
return false;
}
#else
CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef,
kCFURLPOSIXPathStyle);
const char *pathPtr = CFStringGetCStringPtr(macPath,
CFStringGetSystemEncoding());
char libPath[1024];
char oldPath[1024];
getcwd(oldPath,1024);
strcpy(libPath,pathPtr);
strcat(libPath,"/Contents/Frameworks");
chdir(libPath); // change to this dir so J2534 .dylib can find any other needed dylibs in the same dir
strcat(libPath,"/"");
strcat(libPath,szDLL);
CFRelease(appUrlRef);
CFRelease(macPath);
if (!(hDLL = dlopen(libPath, RTLD_LOCAL|RTLD_LAZY)))
{
strcpy(lastError,"error loading ");
strcat(lastError,libPath);
chdir(oldPath);
return false;
}
else if (!getPTfns())
{
// assume unusable if we don't have everything we need
dlclose(hDLL);
hDLL = NULL;
strcpy(lastError,"error loading J2534 dylib function pointers");
chdir(oldPath);
return false;
}
chdir(oldPath);
#endif
DBGPRINT(("DLL loaded successfully\n"));
#endif
return true;
}
bool J2534::checkDLL()
{
if (!hDLL)
LoadJ2534DLL(dllName);
return (hDLL != NULL);
}
bool J2534::is_serial_port_open()
{
return J2534_init_ok;
}
long J2534::PassThruOpen(const void *pName, unsigned long *pDeviceID)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruOpen(name=%s,pDeviceID=@%08X)\n",(char*)pName,pDeviceID));
result = (*pfPassThruOpen)(pName,pDeviceID);
DBGPRINT(("PassThruOpen returned result %d and DeviceID %u\n",result,*pDeviceID));
return result;
}
long J2534::PassThruClose(unsigned long DeviceID)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruClose(%u)\n",DeviceID));
result = (*pfPassThruClose)(DeviceID);
DBGPRINT(("PassThruClose returned result %d\n",result));
return result;
}
long J2534::PassThruConnect(unsigned long DeviceID, unsigned long ProtocolID, unsigned long Flags, unsigned long Baudrate, unsigned long *pChannelID)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruConnect(DeviceID=%u,ProtocolID=%u,Flags=%08X,Baudrate=%u,pChannelID=@%08X)\n",DeviceID,ProtocolID,Flags,Baudrate,pChannelID));
result = (*pfPassThruConnect)(DeviceID,ProtocolID,Flags,Baudrate,pChannelID);
DBGPRINT(("PassThruConnect returned result %d and ChannelID %u\n",result,*pChannelID));
return result;
}
long J2534::PassThruDisconnect(unsigned long ChannelID)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruDisconnect(ChannelID=%u)\n",ChannelID));
result = (*pfPassThruDisconnect)(ChannelID);
DBGPRINT(("PassThruDisconnect returned result %d\n",result));
return result;
}
long J2534::PassThruReadMsgs(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruReadMsgs(ChannelID=%u,pMsg=@%08X,pNumMsgs=%u,Timeout=%u)\n",ChannelID,pMsg,*pNumMsgs,Timeout));
result = (*pfPassThruReadMsgs)(ChannelID,pMsg,pNumMsgs,Timeout);
DBGPRINT(("PassThruReadMsgs returned result %d\n",result));
return result;
}
long J2534::PassThruWriteMsgs(unsigned long ChannelID, const PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout)
{
unsigned int i;
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruWriteMsgs(ChannelID=%u,pMsg=@%08X,NumMsgs=%u,Timeout=%u)\n",ChannelID,pMsg,*pNumMsgs,Timeout));
result = (*pfPassThruWriteMsgs)(ChannelID,pMsg,pNumMsgs,Timeout);
for (i = 0; i < *pNumMsgs; i++)
DBGPRINTPT((&(pMsg[i]),MSG_WRITE));
DBGPRINT(("PassThruWriteMsgs returned result %d\n",result));
return result;
}
long J2534::PassThruStartPeriodicMsg(unsigned long ChannelID, const PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruStartPeriodicMsg(ChannelID=%u,pMsg=@%08X,pMsgID=@%08X,TimeInterval=%u)\n",ChannelID,pMsg,pMsgID,TimeInterval));
result = (*pfPassThruStartPeriodicMsg)(ChannelID,pMsg,pMsgID,TimeInterval);
DBGPRINTPT((pMsg,0));
DBGPRINT(("PassThruStartPeriodicMsg returned result %d and MsgID %u\n",result,*pMsgID));
return result;
}
long J2534::PassThruStopPeriodicMsg(unsigned long ChannelID, unsigned long MsgID)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruStopPeriodicMsg(ChannelID=%u,MsgID=@%08X,TimeInterval=%u)\n",ChannelID,MsgID));
result = (*pfPassThruStopPeriodicMsg)(ChannelID,MsgID);
DBGPRINT(("PassThruStopPeriodicMsg returned result %d\n",result));
return result;
}
long J2534::PassThruStartMsgFilter(unsigned long ChannelID,
unsigned long FilterType, const PASSTHRU_MSG *pMaskMsg, const PASSTHRU_MSG *pPatternMsg,
const PASSTHRU_MSG *pFlowControlMsg, unsigned long *pMsgID)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruStartMsgFilter(ChannelID=%u,FilterType=%u,pMaskMsg=@%08X,pPatternMsg=@%08X,pFlowControlMsg=@%08X,pMsgID=@%08X)\n",
ChannelID,FilterType,pMaskMsg,pPatternMsg,pFlowControlMsg,pMsgID));
DBGPRINT(("MaskMsg\n",result));
DBGPRINTPT((pMaskMsg,0));
DBGPRINT(("PatternMsg\n",result));
DBGPRINTPT((pPatternMsg,0));
DBGPRINT(("FlowControlMsg\n",result));
DBGPRINTPT((pFlowControlMsg,0));
result = (*pfPassThruStartMsgFilter)(ChannelID,FilterType,pMaskMsg,pPatternMsg,pFlowControlMsg,pMsgID);
DBGPRINT(("PassThruStartMsgFilter returned result %d and MsgID %u\n",result,*pMsgID));
return result;
}
long J2534::PassThruStopMsgFilter(unsigned long ChannelID, unsigned long MsgID)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruStopMsgFilter(ChannelID=%u,MsgID=@%08X,TimeInterval=%u)\n",ChannelID,MsgID));
result = (*pfPassThruStopMsgFilter)(ChannelID,MsgID);
DBGPRINT(("PassThruStopMsgFilter returned result %d\n",result));
return result;
}
long J2534::PassThruSetProgrammingVoltage(unsigned long DeviceID, unsigned long Pin, unsigned long Voltage)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruSetProgrammingVoltage(DeviceID=%u,Pin=%u,Voltage=%u)\n",DeviceID,Pin,Voltage));
result = (*pfPassThruSetProgrammingVoltage)(DeviceID,Pin,Voltage);
DBGPRINT(("PassThruSetProgrammingVoltage returned result %d\n",result));
return result;
}
long J2534::PassThruReadVersion(char *pApiVersion,char *pDllVersion,char *pFirmwareVersion,unsigned long DeviceID)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruReadVersion(DeviceID=%u,pFirmwareVersion=@%08X,pDllVersion=@%08X,pApiVersion=@%08X)\n",DeviceID,pFirmwareVersion,pDllVersion,pApiVersion));
result = (*pfPassThruReadVersion)(DeviceID,pFirmwareVersion,pDllVersion,pApiVersion);
DBGPRINT(("PassThruReadVersion returned result %d and FirmwareVersion [%s], DllVersion [%s], ApiVersion [%s]\n",result,pFirmwareVersion,pDllVersion,pApiVersion));
return result;
}
long J2534::PassThruGetLastError(char *pErrorDescription)
{
long result = STATUS_NOERROR;
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
DBGPRINT(("PassThruGetLastError(pErrorDescription=@%08X\n",pErrorDescription));
result = (*pfPassThruGetLastError)(pErrorDescription);
DBGPRINT(("PassThruGetLastError returned result %d and ErrorDescription [%s]\n",result,pErrorDescription));
return result;
}
int J2534::is_valid_sconfig_param(SCONFIG s)
{
switch (s.Parameter)
{
case P1_MIN:
case P2_MIN:
case P3_MAX:
case P4_MAX:
return 0;
break;
default:
return 1;
}
}
void J2534::dump_sbyte_array(const SBYTE_ARRAY* s)
{
DBGPRINT(("SBYTE_ARRAY size=%u\n",s->NumOfBytes));
DBGDUMP((s->BytePtr,s->NumOfBytes,0));
}
void J2534::dump_sconfig_param(SCONFIG s)
{
char paramName[128];
switch (s.Parameter)
{
case DATA_RATE:
strcpy(paramName,"DATA_RATE");
break;
case LOOPBACK:
strcpy(paramName,"LOOPBACK");
break;
case NODE_ADDRESS:
strcpy(paramName,"NODE_ADDRESS");
break;
case NETWORK_LINE:
strcpy(paramName,"NETWORK_LINE");
break;
case P1_MIN:
strcpy(paramName,"P1_MIN");
break;
case P1_MAX:
strcpy(paramName,"P1_MAX");
break;
case P2_MIN:
strcpy(paramName,"P2_MIN");
break;
case P2_MAX:
strcpy(paramName,"P2_MAX");
break;
case P3_MIN:
strcpy(paramName,"P3_MIN");
break;
case P3_MAX:
strcpy(paramName,"P3_MAX");
break;
case P4_MIN:
strcpy(paramName,"P4_MIN");
break;
case P4_MAX:
strcpy(paramName,"P4_MAX");
break;
case W1:
strcpy(paramName,"W1");
break;
case W2:
strcpy(paramName,"W2");
break;
case W3:
strcpy(paramName,"W3");
break;
case W4:
strcpy(paramName,"W4");
break;
case W5:
strcpy(paramName,"W5");
break;
case TIDLE:
strcpy(paramName,"TIDLE");
break;
case TINIL:
strcpy(paramName,"TINIL");
break;
case TWUP:
strcpy(paramName,"TWUP");
break;
case PARITY:
strcpy(paramName,"PARITY");
break;
case BIT_SAMPLE_POINT:
strcpy(paramName,"BIT_SAMPLE_POINT");
break;
case SYNC_JUMP_WIDTH:
strcpy(paramName,"SYNC_JUMP_WIDTH");
break;
case W0:
strcpy(paramName,"W0");
break;
case T1_MAX:
strcpy(paramName,"T1_MAX");
break;
case T2_MAX:
strcpy(paramName,"T2_MAX");
break;
case T4_MAX:
strcpy(paramName,"T4_MAX");
break;
case T5_MAX:
strcpy(paramName,"T5_MAX");
break;
case ISO15765_BS:
strcpy(paramName,"ISO15765_BS");
break;
case ISO15765_STMIN:
strcpy(paramName,"ISO15765_STMIN");
break;
case DATA_BITS:
strcpy(paramName,"DATA_BITS");
break;
case FIVE_BAUD_MOD:
strcpy(paramName,"FIVE_BAUD_MOD");
break;
case BS_TX:
strcpy(paramName,"BS_TX");
break;
case STMIN_TX:
strcpy(paramName,"STMIN_TX");
break;
case T3_MAX:
strcpy(paramName,"T3_MAX");
break;
case ISO15765_WFT_MAX:
strcpy(paramName,"ISO15765_WFT_MAX");
break;
case CAN_MIXED_FORMAT:
strcpy(paramName,"CAN_MIXED_FORMAT");
break;
case J1962_PINS:
strcpy(paramName,"J1962_PINS");
break;
case SW_CAN_HS_DATA_RATE:
strcpy(paramName,"W_CAN_HS_DATA_RATE");
break;
case SW_CAN_SPEEDCHANGE_ENABLE:
strcpy(paramName,"SW_CAN_SPEEDCHANGE_ENABLE");
break;
case SW_CAN_RES_SWITCH:
strcpy(paramName,"SW_CAN_RES_SWITCH");
break;
case ACTIVE_CHANNELS:
strcpy(paramName,"ACTIVE_CHANNELS");
break;
case SAMPLE_RATE:
strcpy(paramName,"SAMPLE_RATE");
break;
case SAMPLES_PER_READING:
strcpy(paramName,"SAMPLES_PER_READING");
break;
case READINGS_PER_MSG:
strcpy(paramName,"READINGS_PER_MSG");
break;
case AVERAGING_METHOD:
strcpy(paramName,"AVERAGING_METHOD");
break;
case SAMPLE_RESOLUTION:
strcpy(paramName,"SAMPLE_RESOLUTION");
break;
case INPUT_RANGE_LOW:
strcpy(paramName,"INPUT_RANGE_LOW");
break;
case INPUT_RANGE_HIGH:
strcpy(paramName,"INPUT_RANGE_HIGH");
break;
default:
sprintf(paramName,"%lu(unknown)",s.Parameter);
break;
}
DBGPRINT((" %s : %u",paramName,s.Value));
}
long J2534::PassThruIoctl(unsigned long ChannelID, unsigned long IoctlID, const void *pInput, void *pOutput)
{
int input_as_sa = 0;
int output_as_sa = 0;
unsigned int i;
SCONFIG_LIST* scl;
long result = STATUS_NOERROR;
char IoctlName[128];
if (!checkDLL())
return ERR_DEVICE_NOT_CONNECTED;
switch (IoctlID)
{
case GET_CONFIG:
strcpy(IoctlName,"GET_CONFIG");
break;
case SET_CONFIG:
strcpy(IoctlName,"SET_CONFIG");
break;
case READ_VBATT:
strcpy(IoctlName,"READ_VBATT");
break;
case FIVE_BAUD_INIT:
strcpy(IoctlName,"FIVE_BAUD_INIT");
input_as_sa = 1;
output_as_sa = 1;
break;
case FAST_INIT:
strcpy(IoctlName,"FAST_INIT");
break;
case CLEAR_TX_BUFFER:
strcpy(IoctlName,"CLEAR_TX_BUFFER");
break;
case CLEAR_RX_BUFFER:
strcpy(IoctlName,"CLEAR_RX_BUFFER");
break;
case CLEAR_PERIODIC_MSGS:
strcpy(IoctlName,"CLEAR_PERIODIC_MSGS");
break;
case CLEAR_MSG_FILTERS:
strcpy(IoctlName,"CLEAR_MSG_FILTERS");
break;
case CLEAR_FUNCT_MSG_LOOKUP_TABLE:
strcpy(IoctlName,"CLEAR_FUNCT_MSG_LOOKUP_TABLE");
break;
case ADD_TO_FUNCT_MSG_LOOKUP_TABLE:
strcpy(IoctlName,"ADD_TO_FUNCT_MSG_LOOKUP_TABLE");
break;
case DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE:
strcpy(IoctlName,"DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE");
break;
case READ_PROG_VOLTAGE:
strcpy(IoctlName,"READ_PROG_VOLTAGE");
break;
case TX_IOCTL_APP_SERVICE:
strcpy(IoctlName,"APP_SERVICE");
break;
default:
sprintf(IoctlName,"%lu(unknown)",IoctlID);
break;
}
DBGPRINT(("PassThruIoctl(ChannelID=%u,Ioctl=%s,pInput=@%08X,pOutputMsgID=@%08X)\n",ChannelID,IoctlName,pInput,pOutput));
if (IoctlID == SET_CONFIG)
{
pOutput = NULL; // make some DLLs happy
// dump params
scl = (SCONFIG_LIST*)pInput;
for (i = 0; i < scl->NumOfParams; i++)
dump_sconfig_param((scl->ConfigPtr)[i]);
for (i = 0; i < scl->NumOfParams; i++)
if (!is_valid_sconfig_param((scl->ConfigPtr)[i]))
{
DBGPRINT(("param not allowed - not passing through and instead faking success\n",result));
return STATUS_NOERROR;
}
}
if (input_as_sa)
{
DBGPRINT(("Input\n"));
dump_sbyte_array((SBYTE_ARRAY*)pInput);
}
result = (*pfPassThruIoctl)(ChannelID,IoctlID,pInput,pOutput);
if (output_as_sa)
{
DBGPRINT(("Output\n"));
dump_sbyte_array((SBYTE_ARRAY*)pOutput);
}
DBGPRINT(("PassThruIoctl returned result %d\n",result));
return result;
}