drivers/can_anagate_win32/can_anagate_win32.c
changeset 703 00600dcc1dee
parent 631 08b6b903f84a
equal deleted inserted replaced
702:8be1c1e5fb17 703:00600dcc1dee
    82 	WaitForSingleObject(pAnaGatePort->hFesticalRecAcknowledge,INFINITE);
    82 	WaitForSingleObject(pAnaGatePort->hFesticalRecAcknowledge,INFINITE);
    83 }
    83 }
    84 
    84 
    85 
    85 
    86 /*********functions which permit to communicate with the board****************/
    86 /*********functions which permit to communicate with the board****************/
    87 UNS8 canReceive_driver(CAN_HANDLE fd0, Message *m)
    87 UNS8 __stdcall canReceive_driver(CAN_HANDLE fd0, Message *m)
    88 {
    88 {
    89 	SAnaGatePort*  pAnaGatePort = (SAnaGatePort*)fd0;
    89 	SAnaGatePort*  pAnaGatePort = (SAnaGatePort*)fd0;
    90    int            i;
    90    int            i;
    91 
    91 
    92 	WaitForSingleObject(			// Wait for receive event
    92 	WaitForSingleObject(			// Wait for receive event
   106 
   106 
   107 	return 0;
   107 	return 0;
   108 }
   108 }
   109 
   109 
   110 /***************************************************************************/
   110 /***************************************************************************/
   111 UNS8 canSend_driver(CAN_HANDLE fd0, Message const *m)
   111 UNS8 __stdcall canSend_driver(CAN_HANDLE fd0, Message const *m)
   112 {
   112 {
   113 	SAnaGatePort*  pAnaCanPort = (SAnaGatePort*)fd0;
   113 	SAnaGatePort*  pAnaCanPort = (SAnaGatePort*)fd0;
   114 	char cErrorMsg[100];
   114 	char cErrorMsg[100];
   115 	int nRetCode;
   115 	int nRetCode;
   116 	int nMsgTyp;
   116 	int nMsgTyp;
   150  
   150  
   151 	return 0x0000;
   151 	return 0x0000;
   152 }
   152 }
   153 /****************************************************************************/
   153 /****************************************************************************/
   154 
   154 
   155 UNS8 canChangeBaudRate_driver( CAN_HANDLE fd0, char* baud)
   155 UNS8 __stdcall canChangeBaudRate_driver( CAN_HANDLE fd0, char* baud)
   156 {
   156 {
   157    int nRetCode;
   157    int nRetCode;
   158    char cErrorMsg[100];
   158    char cErrorMsg[100];
   159    struct SAnaGatePort*  pAnaGatePort = (struct SAnaGatePort*)fd0;
   159    struct SAnaGatePort*  pAnaGatePort = (struct SAnaGatePort*)fd0;
   160    
   160    
   161    if (nRetCode = CANSetGlobals (pAnaGatePort->hHandle, TranslateBaudeRate(baud), 0, 0, 1) ) 
   161    if (nRetCode = CANSetGlobals (pAnaGatePort->hHandle, TranslateBaudeRate(baud), 0, 0, 1, 0) ) 
   162    {
   162    {
   163       CANErrorMessage( nRetCode, cErrorMsg ,100 ); // Convert returncode to error messge
   163       CANErrorMessage( nRetCode, cErrorMsg ,100 ); // Convert returncode to error messge
   164       fprintf(stderr, "canChangeBaudRate_drive (AnaGate_Win32): %s\n", cErrorMsg);
   164       fprintf(stderr, "canChangeBaudRate_drive (AnaGate_Win32): %s\n", cErrorMsg);
   165       printf("canChangeBaudRate_drive (AnaGate_Win32): %s\n", cErrorMsg);
   165       printf("canChangeBaudRate_drive (AnaGate_Win32): %s\n", cErrorMsg);
   166       return 1;
   166       return 1;
   172 /* To open a connection to AnaGate CAN the s_BOARD board->busname must be 
   172 /* To open a connection to AnaGate CAN the s_BOARD board->busname must be 
   173  the AnaGate IP-Adresse followed from the CAN-Port (A or B) you want to use 
   173  the AnaGate IP-Adresse followed from the CAN-Port (A or B) you want to use 
   174  For example "192.168.1.254:A"
   174  For example "192.168.1.254:A"
   175 */
   175 */
   176 
   176 
   177 CAN_HANDLE canOpen_driver(s_BOARD *board)
   177 CAN_HANDLE __stdcall canOpen_driver(s_BOARD *board)
   178 {
   178 {
   179 	int PortNr;
   179 	int PortNr;
   180 	char cErrorMsg[100];
   180 	char cErrorMsg[100];
   181 	int nRetCode;
   181 	int nRetCode;
   182 	char sIPAddress[16];
   182 	char sIPAddress[16];
   246 	// Inizial Baudrate
   246 	// Inizial Baudrate
   247 	if (nRetCode = CANSetGlobals (pNewAnaGatePort->hHandle, 
   247 	if (nRetCode = CANSetGlobals (pNewAnaGatePort->hHandle, 
   248 							   TranslateBaudeRate(board->baudrate), 
   248 							   TranslateBaudeRate(board->baudrate), 
   249 							   0,/*OperatingMode = normal*/ 
   249 							   0,/*OperatingMode = normal*/ 
   250 							   0,/*CAN-Termination = off*/ 
   250 							   0,/*CAN-Termination = off*/ 
   251 							   1 /*HighSpeedMode = on*/) ) 
   251 							   1, /*HighSpeedMode = on*/
       
   252 							   0 /*Timestamps = off*/) ) 
   252 	{
   253 	{
   253 		CANErrorMessage( nRetCode, cErrorMsg ,100 ); // Convert returncode to error messge
   254 		CANErrorMessage( nRetCode, cErrorMsg ,100 ); // Convert returncode to error messge
   254 		fprintf(stderr, "canOpen_driver (AnaGate_Win32): %s @ %s\n", cErrorMsg,sIPAddress);
   255 		fprintf(stderr, "canOpen_driver (AnaGate_Win32): %s @ %s\n", cErrorMsg,sIPAddress);
   255 		//printf("canOpen_driver (AnaGate_Win32): %s @ %s\n", cErrorMsg,sIPAddress);
   256 		//printf("canOpen_driver (AnaGate_Win32): %s @ %s\n", cErrorMsg,sIPAddress);
   256 		return (CAN_HANDLE) NULL;
   257 		return (CAN_HANDLE) NULL;
   283 
   284 
   284   return (CAN_HANDLE)pNewAnaGatePort;
   285   return (CAN_HANDLE)pNewAnaGatePort;
   285 }
   286 }
   286 
   287 
   287 /***************************************************************************/
   288 /***************************************************************************/
   288 int canClose_driver(CAN_HANDLE fd0)
   289 int __stdcall canClose_driver(CAN_HANDLE fd0)
   289 {
   290 {
   290 	SAnaGatePort*  pAnaCanPort = (SAnaGatePort*)fd0;
   291 	SAnaGatePort*  pAnaCanPort = (SAnaGatePort*)fd0;
   291 	char cErrorMsg[100];
   292 	char cErrorMsg[100];
   292 	int nRetCode;
   293 	int nRetCode;
   293 
   294