equal
deleted
inserted
replaced
25 */ |
25 */ |
26 |
26 |
27 #include <stdio.h> |
27 #include <stdio.h> |
28 #include <unistd.h> |
28 #include <unistd.h> |
29 |
29 |
|
30 #define NEED_PRINT_MESSAGE |
30 #include "can_driver.h" |
31 #include "can_driver.h" |
31 #include "def.h" |
32 #include "def.h" |
32 |
33 |
33 #define MAX_NB_CAN_PIPES 16 |
34 #define MAX_NB_CAN_PIPES 16 |
34 |
35 |
45 if(read(((CANPipe*)fd0)->pipe[0], m, sizeof(Message)) != (ssize_t)sizeof(Message)) |
46 if(read(((CANPipe*)fd0)->pipe[0], m, sizeof(Message)) != (ssize_t)sizeof(Message)) |
46 { |
47 { |
47 return 1; |
48 return 1; |
48 } |
49 } |
49 return 0; |
50 return 0; |
50 } |
|
51 |
|
52 #define MyCase(fc) case fc: printf(#fc);break; |
|
53 void print_message(Message *m) |
|
54 { |
|
55 int i; |
|
56 switch(m->cob_id.w >> 7) |
|
57 { |
|
58 MyCase(SYNC) |
|
59 MyCase(TIME_STAMP) |
|
60 MyCase(PDO1tx) |
|
61 MyCase(PDO1rx) |
|
62 MyCase(PDO2tx) |
|
63 MyCase(PDO2rx) |
|
64 MyCase(PDO3tx) |
|
65 MyCase(PDO3rx) |
|
66 MyCase(PDO4tx) |
|
67 MyCase(PDO4rx) |
|
68 MyCase(SDOtx) |
|
69 MyCase(SDOrx) |
|
70 MyCase(NODE_GUARD) |
|
71 MyCase(NMT) |
|
72 } |
|
73 printf(" rtr:%d", m->rtr); |
|
74 printf(" len:%d", m->len); |
|
75 for (i = 0 ; i < m->len ; i++) |
|
76 printf(" %02x", m->data[i]); |
|
77 printf("\n"); |
|
78 } |
51 } |
79 |
52 |
80 /***************************************************************************/ |
53 /***************************************************************************/ |
81 UNS8 canSend_driver(CAN_HANDLE fd0, Message *m) |
54 UNS8 canSend_driver(CAN_HANDLE fd0, Message *m) |
82 { |
55 { |