72 if((ret =
devGetInfo(GET_FIRMWARE_INFO)) != DRV_NO_ERROR)
return ret;
77 if(
debug) printf(
"cif.open() success\n");
94 int ret = DevOpenDriver();
98 if(
debug) printf(
"DevOpenDriver ret=%d\n",ret);
109 if(
debug) printf(
"DevInitBoard ret=%d\n",ret);
115 if(info == GET_FIRMWARE_INFO)
119 sizeof(FIRMWAREINFO),
121 if(
debug) printf(
"DevGetInfo(GET_FIRMWARE_INFO) ret=%d\n", ret);
124 if(info == GET_IO_INFO)
134 printf(
"DevGetInfo (IOINFO) ret=%d \n", ret);
135 printf(
"ExchangeIO information\n" 136 " IO-Communication mode : %d\n" 140 if(
tIoInfo.bIOExchangeMode == 0)
142 printf(
" --- IO-Communication NOT AVAILABLE ---\n");
146 printf(
" --- IO-Communication AVAILABLE ---\n");
150 printf(
" IO-Communication is not running, so all function\n" 151 " returning an error !\n");
157 printf(
"rlHilscherCIF::devGetInfo() unknown info\n");
166 if(
debug) printf(
"DevSetHostState mode=%d ret=%d\n", mode, ret);
177 if(
debug) printf(
"DevPutTaskParameter ret=%d (Interface number 1)\n", ret);
186 (
unsigned long) 8000L);
187 if(
debug) printf(
"DevResetBoard ret=%d\n", ret);
194 if(
debug) printf(
"DevExitBoard ret=%d \n", ret);
202 int ret = DevCloseDriver();
206 if(
debug) printf(
"DevCloseDriver ret=%d\n", ret);
214 printf(
"rlHilscherCIF::devGetMessage ERROR device is not open\n");
219 printf(
"rlHilscherCIF::devGetMessage() ERROR you have to set tMessage first\n");
222 if(
debug) printf(
"rlHilscherCIF::devGetMessage() timeout=%d", timeout);
227 if(
debug) printf(
"DevGetMessage ret=%d\n", ret);
228 if(ret == DRV_NO_ERROR)
231 if(
debug) printf(
" RX: 0x%02X, TX: 0x%02X, LN: 0x%02X, NR: 0x%02X\n",
236 if(
debug) printf(
" A: 0x%02X, F: 0x%02X, B: 0x%02X, E: 0x%02X\n",
249 printf(
"rlHilscherCIF::devPutMessage ERROR device is not open\n");
252 if(
debug) printf(
"rlHilscherCIF::devPutMessage() timeout=%d", timeout);
256 if(
debug) printf(
"DevPutMessage ret=%d\n", ret);
261 int receiveOffset,
int receiveSize,
unsigned char *receiveData,
266 printf(
"rlHilscherCIF::devExchangeIO ERROR device is not open\n");
271 (
unsigned short) sendOffset,
272 (
unsigned short) sendSize,
274 (
unsigned short) receiveOffset,
275 (
unsigned short) receiveSize,
278 if(ret != DRV_NO_ERROR)
280 if(
debug) printf(
"DevExchangeIO ret=%d timeout\n", ret);
285 if(
debug && sendSize >= 4 && receiveSize >= 4)
287 printf(
" ExchangeIO data:\n" 288 " Send data: Receive data\n");
289 printf(
" byte 0 : %d byte 0 : %d\n", sendData[0],receiveData[0]);
290 printf(
" byte 1 : %d byte 1 : %d\n", sendData[1],receiveData[1]);
291 printf(
" byte 2 : %d byte 2 : %d\n", sendData[2],receiveData[2]);
292 printf(
" byte 3 : %d byte 3 : %d\n", sendData[3],receiveData[3]);
300 unsigned char abTemp[30];
301 memcpy(&abTemp, &
abInfo[0], 16);
303 printf(
"FirmwareName: %s\n",&abTemp[0]);
304 memcpy(&abTemp, &
abInfo[16], 16);
306 printf(
"FirmwareVersion: %s\n",&abTemp[0]);
316 unsigned char sendData[512];
317 unsigned char receiveData[512];
320 if(cif.
open() != DRV_NO_ERROR)
return -1;
324 printf(
"hit RETURN 'x'=end ");
328 sendData[0] = (
unsigned char) i++;
342 unsigned short usBoardNumber = 0;
343 unsigned short usDevState, usHostState;
345 unsigned char abTemp[30];
346 unsigned char abInfo[300];
350 ASC_PARAMETER aParameter;
356 RCS_MESSAGETELEGRAM_10 tMessage;
359 unsigned char tIOSendData[512];
360 unsigned char tIORecvData[512];
363 printf(
"HILSCHER GmbH - Communication test program \n\n");
365 printf(
"\n*** Open communication driver ***\n");
366 printf(
"*** Board number: %d ***\n\n", usBoardNumber);
370 if ( (sRet = DevOpenDriver()) != DRV_NO_ERROR) {
371 printf(
"DevOpenDriver RetWert = %5d \n", sRet );
375 }
else if ( (sRet = DevInitBoard ( usBoardNumber)) != DRV_NO_ERROR) {
376 printf(
"DevInitBoard RetWert = %5d \n", sRet );
380 }
else if ( (sRet = DevGetInfo( usBoardNumber,
382 sizeof(FIRMWAREINFO),
383 &abInfo[0])) != DRV_NO_ERROR ) {
385 printf(
"DevGetInfo (GET_FIRMWARE_INFO) RetWert = %5d \n", sRet );
389 }
else if ( (sRet = DevSetHostState( usBoardNumber,
391 0L)) != DRV_NO_ERROR ) {
393 printf(
"DevSetHostState (HOST_READY) RetWert = %5d \n", sRet );
398 memcpy ( &abTemp, &abInfo[0], 16);
400 printf(
" FirmwareName: %s\n", &abTemp[0] );
401 memcpy ( &abTemp, &abInfo[16], 16);
403 printf(
" FirmwareVersion: %s\n", &abTemp[0]);
408 if ( (sRet = DevGetMBXState( usBoardNumber,
410 &usHostState)) != DRV_NO_ERROR ) {
412 printf(
"DevGetMBXState RetWert = %5d\n", sRet );
417 printf(
"DevGetMBXState device MBX state = %5d (0=empty, 1=full)\n", usDevState);
418 printf(
"DevGetMBXState host MBX state = %5d (0=empty, 1=full)\n", usHostState);
427 aParameter.bRtsControl = 0;
428 aParameter.bBaudrate = 10;
429 aParameter.bDataBits = 8;
430 aParameter.bStopBits = 1;
431 aParameter.bParityBit = 1;
432 aParameter.bMode = 1;
433 aParameter.bEndMode = 0;
434 aParameter.bCheckMode = 0;
435 aParameter.bCheckArea = 0;
436 aParameter.bFilterMode = 0;
437 aParameter.usFilterCharacter = 0;
438 aParameter.usTelTimeout = 1000;
439 aParameter.usStartTimeout = 0;
440 aParameter.usCharTimeout = 0;
441 aParameter.bRetries = 0;
442 aParameter.bErrorLed = 1;
443 aParameter.bTelStartLen = 0;
444 aParameter.bTelStart[0] = 0;
445 aParameter.bTelEndLen = 0;
446 aParameter.bTelEnd[0] = 0;
447 aParameter.bTelAckLen = 0;
448 aParameter.bTelAck[0] = 0;
449 aParameter.bTelNackLen = 0;
450 aParameter.bTelNack[0] = 0;
451 aParameter.bTelDeviceLen = 0;
454 sRet = DevPutTaskParameter( usBoardNumber,
458 printf(
"DevPutTaskParameter RetWert = %5d (Interface number 1)\n", sRet );
463 sRet = DevReset( (
unsigned char) usBoardNumber,
465 (
unsigned long) 8000L);
466 printf(
"DevResetBoard RetWert = %5d \n", sRet );
470 printf(
"\nPress RETURN to continue .... \n");
477 printf(
"\n*** Test for message transfer ***\n\n");
480 printf(
" DevGetMessage Wait for a maximum of %ld ms\n", 5000L );
482 sRet = DevGetMessage ( usBoardNumber,
484 (MSG_STRUC *)&tMessage,
486 printf(
" DevGetMessage RetWert = %5d \n", sRet );
501 tMessage.device_adr = 0;
502 tMessage.data_area = 0;
503 tMessage.data_adr = 0;
504 tMessage.data_idx = 0;
505 tMessage.data_cnt = 4;
506 tMessage.data_type = 10;
507 tMessage.function = 2;
513 sRet = DevPutMessage ( usBoardNumber,
514 (MSG_STRUC *)&tMessage,
516 printf(
" DevPutMessage RetWert = %5d \n", sRet );
521 printf(
"\nPress RETURN to continue .... \n");
526 printf(
" DevGetMessage Wait for a maximum of %ld ms\n", 20000L );
528 sRet = DevGetMessage ( 0,
530 (MSG_STRUC *)&tMessage,
532 printf(
" DevGetMessage RetWert = %5d \n", sRet );
534 if ( sRet == DRV_NO_ERROR) {
536 printf(
" RX: 0x%02X, TX: 0x%02X, LN: 0x%02X, NR: 0x%02X \n",
541 printf(
" A: 0x%02X, F: 0x%02X, B: 0x%02X, E: 0x%02X \n",
558 printf(
"\n\n*** Test for ExchangeIO functions ***\n\n");
562 sRet = DevGetInfo( usBoardNumber,
567 printf(
" DevGetInfo (IOINFO) RetWert = %5d \n", sRet );
570 printf(
" ExchangeIO information\n" 571 " IO-Communication mode : %d\n" 574 tIoInfo.bIOExchangeMode, tIoInfo.bComBit, tIoInfo.ulIOExchangeCnt);
576 if ( tIoInfo.bIOExchangeMode == 0) {
579 printf(
" --- IO-Communication NOT AVAILABLE ---\n");
584 printf(
" --- IO-Communication AVAILABLE ---\n");
587 if ( tIoInfo.bComBit == 0) {
589 printf(
" IO-Communication is not running, so all function\n" 590 " returning an error !.\n");
596 if ( (sRet = DevGetInfo( usBoardNumber,
599 (
void*)&tIOSendData[0])) != DRV_NO_ERROR ) {
601 printf(
" DevGetInfo (IO_SEND_DATA) RetWert = %5d \n", sRet );
606 tIOSendData[0] = 0xC7;
607 tIOSendData[1] = 0xFF;
613 if ( (sRet = DevExchangeIO ( usBoardNumber,
620 100L )) != DRV_NO_ERROR ) {
622 printf(
"DevExchangeIO RetWert = %5d \n", sRet );
627 printf(
" ExchangeIO data:\n" 628 " Send data: Receive data\n");
629 printf(
" byte 0 : %d byte 0 : %d\n", tIOSendData[0],tIORecvData[0]);
630 printf(
" byte 1 : %d byte 1 : %d\n", tIOSendData[1],tIORecvData[1]);
631 printf(
" byte 2 : %d byte 2 : %d\n", tIOSendData[2],tIORecvData[2]);
632 printf(
" byte 3 : %d byte 3 : %d\n", tIOSendData[3],tIORecvData[3]);
638 printf(
"\nPress RETURN to continue .... \n");
643 if ( (sRet = DevSetHostState( usBoardNumber,
645 0L)) != DRV_NO_ERROR ) {
647 printf(
"DevSetHostState (HOST_NOT_READY) RetWert = %5d \n", sRet );
650 printf(
"\n*** Close communication driver ***\n\n");
655 sRet = DevExitBoard( usBoardNumber);
656 printf(
"DevExitBoard RetWert = %5d \n", sRet );
661 sRet = DevCloseDriver();
662 printf(
"DevCloseDriver RetWert = %5d \n", sRet );
unsigned short usBoardNumber
int devGetMessage(int timeout)
int devExchangeIO(int sendOffset, int sendSize, unsigned char *sendData, int receiveOffset, int receiveSize, unsigned char *receiveData, int timeout)
int devSetHostState(int mode)
RCS_MESSAGETELEGRAM_10 tMessage
int devPutMessage(int timeout)
unsigned char abInfo[300]
int devPutTaskParameter()