* This function implements the main thread loop and enough decision logic so that it knows which device to take messages from and which device to send the messages to.\r
* \r
*/\r
-void* CAN_GW_thread(void* arg){\r
+static void* CAN_GW_thread(void* arg){\r
int fd_in, fd_out;\r
int res;\r
unsigned long int *total, *succ, *err;\r
return 1;\r
}\r
\r
-// pthread_detach(CAN_B_to_A_thread);\r
-// pthread_detach(CAN_A_to_B_thread);\r
+ /* detach is needed so that the threads call clean up handlers automatically. */\r
+ pthread_detach(CAN_B_to_A_thread);\r
+ pthread_detach(CAN_A_to_B_thread);\r
\r
/* Threads are started and running at this point. */\r
return 0;\r
printf("Attempting to stop thread 1\n");\r
res = pthread_cancel(CAN_A_to_B_thread);\r
if (res != 0){\r
- printf("Failed./n");\r
+ printf("Failed.\n");\r
/* Not sure what to do with error here, will have to figure out later. */\r
}\r
printf("Attempting to stop thread 2\n");\r
res = pthread_cancel(CAN_B_to_A_thread);\r
if (res != 0){\r
- printf("Failed./n");\r
+ printf("Failed.\n");\r
/* Not sure what to do with error here, will have to figure out later. */\r
}\r
sleep(1);\r