Send timeout is set to 10 ms. Without timeout PLC can be blocked by CAN driver: if CAN bus is not connected to controller CAN driver never returns and therfore PLC application halts. This is a temporary solution.
authorbmakuc <blaz.makuc@smarteh.si>
Fri, 24 Mar 2017 10:52:38 +0100
changeset 796 1c87f7a8cb8a
parent 795 8dc7a42d38b1
child 797 12340b4ea907
Send timeout is set to 10 ms. Without timeout PLC can be blocked by CAN driver: if CAN bus is not connected to controller CAN driver never returns and therfore PLC application halts. This is a temporary solution.
drivers/can_socket/can_socket.c
--- a/drivers/can_socket/can_socket.c	Fri Nov 27 16:27:46 2015 +0100
+++ b/drivers/can_socket/can_socket.c	Fri Mar 24 10:52:38 2017 +0100
@@ -175,6 +175,7 @@
   int err;
   CAN_HANDLE fd0 = malloc (sizeof (int));
 #ifdef RTCAN_SOCKET
+  nanosecs_rel_t tx_timeout;
   can_baudrate_t *baudrate;
   can_mode_t *mode;
 #endif
@@ -236,6 +237,16 @@
     }
 
 #ifdef RTCAN_SOCKET
+  tx_timeout = 10000000;    /* XXX Timeout is temporarily set to 10 ms */
+  err = CAN_IOCTL (*(int *) fd0, RTCAN_RTIOC_SND_TIMEOUT, &tx_timeout);
+  if (err)
+    {
+      fprintf (stderr,
+          "Setting TX timeout %d failed: %s\n",
+          *baudrate, strerror (CAN_ERRNO (err)));
+      goto error_close;
+    }
+
   baudrate = (can_baudrate_t *) & ifr.ifr_ifru;
   *baudrate = TranslateBaudRate (board->baudrate);
   if (!*baudrate)