rllib  1
rlhilschercif.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  rlhilschercif.cpp - description
3  -------------------
4  begin : Tue Feb 13 2007
5  copyright : (C) 2007 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #include "rlhilschercif.h"
17 #include <stdio.h>
18 
19 // On Windows add *dll.lib to Makefile
20 #ifdef RLUNIX
21 #include "cif_api.c"
22 #endif
23 
25 {
26  debug = 0;
27  isOpen = 0;
28  usBoardNumber = 0; // Board number, 0-3
29 
30  // Fill in protokoll parameters
31  aParameter.bScl = 1; /* Interface number */
32  aParameter.bRtsControl = 0; /* Bus handling */
33  aParameter.bBaudrate = 10; /* Baud rate */
34  aParameter.bDataBits = 8; /* Number of data bits */
35  aParameter.bStopBits = 1; /* Number of stop bits */
36  aParameter.bParityBit = 1; /* Parity */
37  aParameter.bMode = 1; /* Interface mode */
38  aParameter.bEndMode = 0; /* Stop mod */
39  aParameter.bCheckMode = 0; /* Checksum mode */
40  aParameter.bCheckArea = 0; /* Checksum area */
41  aParameter.bFilterMode = 0; /* Character filter mode */
42  aParameter.usFilterCharacter = 0; /* Characters */
43  aParameter.usTelTimeout = 1000; /* Telegram timeout */
44  aParameter.usStartTimeout = 0; /* Start timeout */
45  aParameter.usCharTimeout = 0; /* Character timeout */
46  aParameter.bRetries = 0; /* Retray number */
47  aParameter.bErrorLed = 1; /* Error LED */
48  aParameter.bTelStartLen = 0; /* Length of telegram start */
49  aParameter.bTelStart[0] = 0; /* Telegram beginning */
50  aParameter.bTelEndLen = 0; /* Length of telegram end */
51  aParameter.bTelEnd[0] = 0; /* Telegram end */
52  aParameter.bTelAckLen = 0; /* Length of ACK telegram */
53  aParameter.bTelAck[0] = 0; /* ACK telegramm */
54  aParameter.bTelNackLen = 0; /* Length of NAK telegram */
55  aParameter.bTelNack[0] = 0; /* NAK telegram */
56  aParameter.bTelDeviceLen = 0; /* Length of the device telegram */
57 
58  tMessage.rx = 0x0ff;
59 }
60 
62 {
63  if(isOpen) close();
64 }
65 
67 {
68  int ret;
69  isOpen = 1;
70  if((ret = devOpenDriver()) != DRV_NO_ERROR) return ret;
71  if((ret = devInitBoard()) != DRV_NO_ERROR) return ret;
72  if((ret = devGetInfo(GET_FIRMWARE_INFO)) != DRV_NO_ERROR) return ret;
73  if((ret = devSetHostState(HOST_READY)) != DRV_NO_ERROR) return ret;
76  devReset();
77  if(debug) printf("cif.open() success\n");
78  return ret;
79 }
80 
82 {
83  int ret;
84  isOpen = 0;
85  if((ret = devSetHostState(HOST_NOT_READY)) != DRV_NO_ERROR) return ret;
86  ret = devCloseDriver();
87  return ret;
88 }
89 
91 {
92  isOpen = 1;
93 #ifdef RLUNIX
94  int ret = DevOpenDriver();
95 #else
96  int ret = DevOpenDriver(usBoardNumber);
97 #endif
98  if(debug) printf("DevOpenDriver ret=%d\n",ret);
99  return ret;
100 }
101 
103 {
104 #ifdef RLUNIX
105  int ret = DevInitBoard(usBoardNumber);
106 #else
107  int ret = DevInitBoard(usBoardNumber,NULL);
108 #endif
109  if(debug) printf("DevInitBoard ret=%d\n",ret);
110  return ret;
111 }
112 
114 {
115  if(info == GET_FIRMWARE_INFO)
116  {
117  int ret = DevGetInfo(usBoardNumber,
118  GET_FIRMWARE_INFO,
119  sizeof(FIRMWAREINFO),
120  &abInfo[0]);
121  if(debug) printf("DevGetInfo(GET_FIRMWARE_INFO) ret=%d\n", ret);
122  return ret;
123  }
124  if(info == GET_IO_INFO)
125  {
126  // Read the mode of the IO-Communication, 0 = MODE UNKNOWN
127  int ret = DevGetInfo(usBoardNumber, // DeviceNumber
128  GET_IO_INFO, // InfoArea
129  sizeof(IOINFO), // Size of bytes to read
130  &tIoInfo); // Pointer to user buffer
131 
132  if(debug)
133  {
134  printf("DevGetInfo (IOINFO) ret=%d \n", ret);
135  printf("ExchangeIO information\n"
136  " IO-Communication mode : %d\n"
137  " IO-COM bit : %d\n"
138  " IO-Count : %ld\n",
139  tIoInfo.bIOExchangeMode, tIoInfo.bComBit, tIoInfo.ulIOExchangeCnt);
140  if(tIoInfo.bIOExchangeMode == 0)
141  {
142  printf( " --- IO-Communication NOT AVAILABLE ---\n");
143  }
144  else
145  {
146  printf( " --- IO-Communication AVAILABLE ---\n");
147  // Test if IO-Communication is running
148  if(tIoInfo.bComBit == 0)
149  {
150  printf(" IO-Communication is not running, so all function\n"
151  " returning an error !\n");
152  }
153  }
154  }
155  return ret;
156  }
157  printf("rlHilscherCIF::devGetInfo() unknown info\n");
158  return -1;
159 }
160 
162 {
163  int ret = DevSetHostState(usBoardNumber,
164  mode,
165  0L);
166  if(debug) printf("DevSetHostState mode=%d ret=%d\n", mode, ret);
167  return ret;
168 }
169 
171 {
172  // Write parameters to communication board
173  int ret = DevPutTaskParameter(usBoardNumber, // Device number
174  1, // Protokoll task number
175  sizeof(aParameter), // Lenght of bytes
176  &aParameter ); // Pointer to data buffer
177  if(debug) printf("DevPutTaskParameter ret=%d (Interface number 1)\n", ret);
178  return ret;
179 }
180 
182 {
183  // Reset board so it can take the parameters
184  int ret = DevReset((unsigned char) usBoardNumber, // Device number
185  (unsigned short) WARMSTART, // Reset mode, Warmstar
186  (unsigned long) 8000L); // Timeout 8000 ms
187  if(debug) printf("DevResetBoard ret=%d\n", ret);
188  return ret;
189 }
190 
192 {
193  int ret = DevExitBoard(usBoardNumber);
194  if(debug) printf("DevExitBoard ret=%d \n", ret);
195  return ret;
196 }
197 
199 {
200  isOpen = 0;
201 #ifdef RLUNIX
202  int ret = DevCloseDriver();
203 #else
204  int ret = DevCloseDriver(usBoardNumber);
205 #endif
206  if(debug) printf( "DevCloseDriver ret=%d\n", ret);
207  return ret;
208 }
209 
211 {
212  if(isOpen == 0)
213  {
214  printf("rlHilscherCIF::devGetMessage ERROR device is not open\n");
215  return -1;
216  }
217  if(tMessage.rx == 0x0ff)
218  {
219  printf("rlHilscherCIF::devGetMessage() ERROR you have to set tMessage first\n");
220  return -1;
221  }
222  if(debug) printf("rlHilscherCIF::devGetMessage() timeout=%d", timeout);
223  int ret = DevGetMessage(usBoardNumber, // Device Number
224  sizeof(tMessage), // Users buffer size
225  (MSG_STRUC *)&tMessage, // Pointer to user buffer
226  (long) timeout); // Timeout
227  if(debug) printf("DevGetMessage ret=%d\n", ret);
228  if(ret == DRV_NO_ERROR)
229  {
230  // Message available
231  if(debug) printf( " RX: 0x%02X, TX: 0x%02X, LN: 0x%02X, NR: 0x%02X\n",
232  tMessage.rx,
233  tMessage.tx,
234  tMessage.ln,
235  tMessage.nr);
236  if(debug) printf( " A: 0x%02X, F: 0x%02X, B: 0x%02X, E: 0x%02X\n",
237  tMessage.a,
238  tMessage.f,
239  tMessage.b,
240  tMessage.e);
241  }
242  return ret;
243 }
244 
246 {
247  if(isOpen == 0)
248  {
249  printf("rlHilscherCIF::devPutMessage ERROR device is not open\n");
250  return -1;
251  }
252  if(debug) printf("rlHilscherCIF::devPutMessage() timeout=%d", timeout);
253  int ret = DevPutMessage(usBoardNumber, // Device Number
254  (MSG_STRUC *)&tMessage, // Pointer to user buffer
255  timeout); // Timeout
256  if(debug) printf("DevPutMessage ret=%d\n", ret);
257  return ret;
258 }
259 
260 int rlHilscherCIF::devExchangeIO(int sendOffset, int sendSize, unsigned char *sendData,
261  int receiveOffset, int receiveSize, unsigned char *receiveData,
262  int timeout)
263 {
264  if(isOpen == 0)
265  {
266  printf("rlHilscherCIF::devExchangeIO ERROR device is not open\n");
267  return -1;
268  }
269  // Run ExchangeIO
270  int ret = DevExchangeIO(usBoardNumber,
271  (unsigned short) sendOffset,
272  (unsigned short) sendSize,
273  sendData,
274  (unsigned short) receiveOffset,
275  (unsigned short) receiveSize,
276  receiveData,
277  timeout);
278  if(ret != DRV_NO_ERROR)
279  {
280  if(debug) printf("DevExchangeIO ret=%d timeout\n", ret);
281  }
282  else
283  {
284  // Data exchange is done, print some information
285  if(debug && sendSize >= 4 && receiveSize >= 4)
286  {
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]);
293  }
294  }
295  return ret;
296 }
297 
299 {
300  unsigned char abTemp[30]; // Temporary buffer
301  memcpy(&abTemp, &abInfo[0], 16);
302  abTemp[16] = 0;
303  printf("FirmwareName: %s\n",&abTemp[0]);
304  memcpy(&abTemp, &abInfo[16], 16);
305  abTemp[16] = 0;
306  printf("FirmwareVersion: %s\n",&abTemp[0]);
307 }
308 
309 //#define TESTING
310 #ifdef TESTING
311 int main()
312 {
313  rlHilscherCIF cif;
314  int c = 0;
315  int i = 0;
316  unsigned char sendData[512];
317  unsigned char receiveData[512];
318 
319  cif.debug = 1;
320  if(cif.open() != DRV_NO_ERROR) return -1;
321 
322  while(c != 'x')
323  {
324  printf("hit RETURN 'x'=end ");
325  c = getchar();
326 
327  // Write test data to Send buffer
328  sendData[0] = (unsigned char) i++;
329  sendData[1] = 0xFF;
330  sendData[2] = 2;
331  sendData[3] = 3;
332  cif.devExchangeIO(0,4,sendData,
333  0,4,receiveData,
334  1000);
335  if(i >= 256) i = 0;
336  }
337  return 0;
338 }
339 
340 int xmain( void )
341 {
342  unsigned short usBoardNumber = 0; /* Board number, 0-3 */
343  unsigned short usDevState, usHostState;
344 
345  unsigned char abTemp[30]; /* Temporary buffer */
346  unsigned char abInfo[300]; /* Buffer for various information */
347  short sRet; /* Return value */
348 
349  /* Protocol parameter definition */
350  ASC_PARAMETER aParameter; /* Parameters for ASCII protocolls */
351 
352  /* Information structure */
353  IOINFO tIoInfo; /* IO information structure */
354 
355  /* Data structure for message based communication */
356  RCS_MESSAGETELEGRAM_10 tMessage;
357 
358  /* Data areas for IO based communication */
359  unsigned char tIOSendData[512]; /* Buffer for send data */
360  unsigned char tIORecvData[512]; /* Buffer for receive data */
361 
362 
363  printf( "HILSCHER GmbH - Communication test program \n\n");
364 
365  printf( "\n*** Open communication driver ***\n");
366  printf( "*** Board number: %d ***\n\n", usBoardNumber);
367 
368  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
369  /* Open the driver */
370  if ( (sRet = DevOpenDriver()) != DRV_NO_ERROR) {
371  printf( "DevOpenDriver RetWert = %5d \n", sRet );
372 
373  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
374  /* Initialize board */
375  } else if ( (sRet = DevInitBoard ( usBoardNumber)) != DRV_NO_ERROR) {
376  printf( "DevInitBoard RetWert = %5d \n", sRet );
377 
378  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
379  /* Read Firmware information field */
380  } else if ( (sRet = DevGetInfo( usBoardNumber, /* DeviceNumber */
381  GET_FIRMWARE_INFO, /* InfoArea */
382  sizeof(FIRMWAREINFO), /* Size of bytes to read */
383  &abInfo[0])) != DRV_NO_ERROR ) { /* Pointer to user buffer */
384 
385  printf( "DevGetInfo (GET_FIRMWARE_INFO) RetWert = %5d \n", sRet );
386 
387  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
388  /* Signal board, application is running */
389  } else if ( (sRet = DevSetHostState( usBoardNumber, /* DeviceNumber */
390  HOST_READY, /* Mode */
391  0L)) != DRV_NO_ERROR ) { /* Pointer to user buffer */
392 
393  printf( "DevSetHostState (HOST_READY) RetWert = %5d \n", sRet );
394 
395  } else {
396 
397  /* Print firmware information */
398  memcpy ( &abTemp, &abInfo[0], 16);
399  abTemp[16] = 0;
400  printf( " FirmwareName: %s\n", &abTemp[0] );
401  memcpy ( &abTemp, &abInfo[16], 16);
402  abTemp[16] = 0;
403  printf( " FirmwareVersion: %s\n", &abTemp[0]);
404  printf( "\n\n" );
405 
406  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
407  /* Read mailbox information */
408  if ( (sRet = DevGetMBXState( usBoardNumber, /* DeviceNumber */
409  &usDevState, /* Buffer for device state */
410  &usHostState)) != DRV_NO_ERROR ) {/* Buffer for host state */
411  // function error
412  printf( "DevGetMBXState RetWert = %5d\n", sRet );
413 
414  } else {
415 
416  // show actual state
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);
419 
420  }
421 
422 
423  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
424  /* Fill in protokoll parameters */
425 
426  aParameter.bScl = 1; /* Interface number */
427  aParameter.bRtsControl = 0; /* Bus handling */
428  aParameter.bBaudrate = 10; /* Baud rate */
429  aParameter.bDataBits = 8; /* Number of data bits */
430  aParameter.bStopBits = 1; /* Number of stop bits */
431  aParameter.bParityBit = 1; /* Parity */
432  aParameter.bMode = 1; /* Interface mode */
433  aParameter.bEndMode = 0; /* Stop mod */
434  aParameter.bCheckMode = 0; /* Checksum mode */
435  aParameter.bCheckArea = 0; /* Checksum area */
436  aParameter.bFilterMode = 0; /* Character filter mode */
437  aParameter.usFilterCharacter = 0; /* Characters */
438  aParameter.usTelTimeout = 1000; /* Telegram timeout */
439  aParameter.usStartTimeout = 0; /* Start timeout */
440  aParameter.usCharTimeout = 0; /* Character timeout */
441  aParameter.bRetries = 0; /* Retray number */
442  aParameter.bErrorLed = 1; /* Error LED */
443  aParameter.bTelStartLen = 0; /* Length of telegram start */
444  aParameter.bTelStart[0] = 0; /* Telegram beginning */
445  aParameter.bTelEndLen = 0; /* Length of telegram end */
446  aParameter.bTelEnd[0] = 0; /* Telegram end */
447  aParameter.bTelAckLen = 0; /* Length of ACK telegram */
448  aParameter.bTelAck[0] = 0; /* ACK telegramm */
449  aParameter.bTelNackLen = 0; /* Length of NAK telegram */
450  aParameter.bTelNack[0] = 0; /* NAK telegram */
451  aParameter.bTelDeviceLen = 0; /* Length of the device telegram */
452 
453  /* Write parameters to communication board */
454  sRet = DevPutTaskParameter( usBoardNumber, /* Device number */
455  1, /* Protokoll task number */
456  sizeof(aParameter), /* Lenght of bytes */
457  &aParameter ); /* Pointer to data buffer */
458  printf( "DevPutTaskParameter RetWert = %5d (Interface number 1)\n", sRet );
459 
460  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
461  /* Reset board so it can take the parameters */
462 
463  sRet = DevReset( (unsigned char) usBoardNumber, /* Device number */
464  (unsigned short) WARMSTART, /* Reset mode, Warmstart */
465  (unsigned long) 8000L); /* Timeout 8000 ms */
466  printf( "DevResetBoard RetWert = %5d \n", sRet );
467 
468  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
469  /* Wait for user response */
470  printf( "\nPress RETURN to continue .... \n");
471  getchar();
472 
473  /* ========================================================================= */
474  /* Test Message transfer */
475  /* ========================================================================= */
476 
477  printf( "\n*** Test for message transfer ***\n\n");
478 
479  /* Tray to read a message */
480  printf( " DevGetMessage Wait for a maximum of %ld ms\n", 5000L );
481 
482  sRet = DevGetMessage ( usBoardNumber, /* Device Number */
483  sizeof(tMessage), /* Users buffer size */
484  (MSG_STRUC *)&tMessage, /* Pointer to user buffer */
485  5000L ); /* Timeout */
486  printf( " DevGetMessage RetWert = %5d \n", sRet );
487 
488 
489  /*===========================================================================*/
490  /* Test message transfer */
491  /*===========================================================================*/
492  /* Build a message */
493  tMessage.rx = 0x01;
494  tMessage.tx = 0x10;
495  tMessage.ln = 12;
496  tMessage.nr = 1;
497  tMessage.a = 0;
498  tMessage.f = 0;
499  tMessage.b = 17;
500  tMessage.e = 0x00;
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;
508  tMessage.d[0] = 1; /* Some user data */
509  tMessage.d[1] = 2; /* Some user data */
510  tMessage.d[2] = 3; /* Some user data */
511  tMessage.d[3] = 4; /* Some user data */
512 
513  sRet = DevPutMessage ( usBoardNumber, /* Device Number */
514  (MSG_STRUC *)&tMessage, /* Pointer to user buffer */
515  5000L ); /* Timeout */
516  printf( " DevPutMessage RetWert = %5d \n", sRet );
517 
518 
519  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
520  /* Wait for user response */
521  printf( "\nPress RETURN to continue .... \n");
522  getchar();
523 
524  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
525  /* Tray to read a message */
526  printf( " DevGetMessage Wait for a maximum of %ld ms\n", 20000L );
527 
528  sRet = DevGetMessage ( 0, /* Device Number */
529  sizeof(tMessage), /* Users buffer size */
530  (MSG_STRUC *)&tMessage, /* Pointer to user buffer */
531  20000L ); /* Timeout */
532  printf( " DevGetMessage RetWert = %5d \n", sRet );
533 
534  if ( sRet == DRV_NO_ERROR) {
535  /* Message available */
536  printf( " RX: 0x%02X, TX: 0x%02X, LN: 0x%02X, NR: 0x%02X \n",
537  tMessage.rx,
538  tMessage.tx,
539  tMessage.ln,
540  tMessage.nr );
541  printf( " A: 0x%02X, F: 0x%02X, B: 0x%02X, E: 0x%02X \n",
542  tMessage.a,
543  tMessage.f,
544  tMessage.b,
545  tMessage.e );
546  } /* endif */
547 
548 
549  /* ========================================================================= */
550  /* Test for ExchangeIO */
551  /* ========================================================================= */
552 
553  /* ========================================================================= */
554  /* Test for ExchangeIO */
555  /* ========================================================================= */
556  /* Test if IO-Communication is available */
557 
558  printf( "\n\n*** Test for ExchangeIO functions ***\n\n");
559 
560  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
561  /* Read the mode of the IO-Communication, 0 = MODE UNKNOWN */
562  sRet = DevGetInfo( usBoardNumber, /* DeviceNumber */
563  GET_IO_INFO, /* InfoArea */
564  sizeof(IOINFO), /* Size of bytes to read */
565  &tIoInfo); /* Pointer to user buffer */
566 
567  printf( " DevGetInfo (IOINFO) RetWert = %5d \n", sRet );
568 
569  /* Print IO information */
570  printf( " ExchangeIO information\n"
571  " IO-Communication mode : %d\n"
572  " IO-COM bit : %d\n"
573  " IO-Count : %ld\n",
574  tIoInfo.bIOExchangeMode, tIoInfo.bComBit, tIoInfo.ulIOExchangeCnt);
575 
576  if ( tIoInfo.bIOExchangeMode == 0) {
577 
578  /* No IO-Communication available */
579  printf( " --- IO-Communication NOT AVAILABLE ---\n");
580 
581  } else {
582 
583  /* IO-Communication is available */
584  printf( " --- IO-Communication AVAILABLE ---\n");
585 
586  /* Test if IO-Communication is running */
587  if ( tIoInfo.bComBit == 0) {
588  /* No Communication is running */
589  printf( " IO-Communication is not running, so all function\n"
590  " returning an error !.\n");
591 
592  }
593 
594  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
595  /* Read the hole send area to update internal data */
596  if ( (sRet = DevGetInfo( usBoardNumber, /* DeviceNumber */
597  GET_IO_SEND_DATA, /* InfoArea */
598  sizeof(tIOSendData), /* Size of bytes to read */
599  (void*)&tIOSendData[0])) != DRV_NO_ERROR ) {/* Pointer to user buffer */
600 
601  printf( " DevGetInfo (IO_SEND_DATA) RetWert = %5d \n", sRet );
602 
603  } else {
604 
605  /* Write test data to Send buffer */
606  tIOSendData[0] = 0xC7;
607  tIOSendData[1] = 0xFF;
608  tIOSendData[2] = 2;
609  tIOSendData[3] = 3;
610 
611  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
612  /* Run ExchangeIO */
613  if ( (sRet = DevExchangeIO ( usBoardNumber,
614  0, /* usSendOffset */
615  4, /* usSendSize */
616  &tIOSendData[0], /* *pvSendData */
617  0, /* usReceiveOffset */
618  4, /* usReceiveSize */
619  &tIORecvData[0], /* *pvReceiveData */
620  100L )) != DRV_NO_ERROR ) { /* ulTimeout */
621 
622  printf( "DevExchangeIO RetWert = %5d \n", sRet );
623 
624  } else {
625 
626  /* Data exchange is done, print some information */
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]);
633  }
634  }
635  }
636  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
637  /* Wait for user response */
638  printf( "\nPress RETURN to continue .... \n");
639  getchar();
640 
641  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
642  /* Signal board, application is not running */
643  if ( (sRet = DevSetHostState( usBoardNumber, /* DeviceNumber */
644  HOST_NOT_READY, /* Mode */
645  0L)) != DRV_NO_ERROR ) { /* Pointer to user buffer */
646 
647  printf( "DevSetHostState (HOST_NOT_READY) RetWert = %5d \n", sRet );
648  }
649 
650  printf( "\n*** Close communication driver ***\n\n");
651 
652  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
653  /* Close communication */
654 
655  sRet = DevExitBoard( usBoardNumber); /* Device number */
656  printf( "DevExitBoard RetWert = %5d \n", sRet );
657 
658  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
659  /* Close Driver */
660 
661  sRet = DevCloseDriver();
662  printf( "DevCloseDriver RetWert = %5d \n", sRet );
663  }
664 
665  return(0);
666 }
667 
668 #endif
int devGetInfo(int info)
unsigned short usBoardNumber
Definition: rlhilschercif.h:64
virtual ~rlHilscherCIF()
void printFirmwareInfo()
ASC_PARAMETER aParameter
Definition: rlhilschercif.h:67
int devGetMessage(int timeout)
int devExchangeIO(int sendOffset, int sendSize, unsigned char *sendData, int receiveOffset, int receiveSize, unsigned char *receiveData, int timeout)
#define WARMSTART
int main()
Definition: rlcorba.cpp:18
int devSetHostState(int mode)
RCS_MESSAGETELEGRAM_10 tMessage
Definition: rlhilschercif.h:69
int devPutMessage(int timeout)
unsigned char abInfo[300]
Definition: rlhilschercif.h:66
int devPutTaskParameter()