Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
litesom:devicetree:can [2017/06/09 22:00]
filug [SocketCAN API]
litesom:devicetree:can [2017/06/09 22:02]
filug [SocketCAN API]
Line 224: Line 224:
 struct ifreq ifr; struct ifreq ifr;
  
 +/*
 + * Open connection with CAN bus
 + */
 s = socket(PF_CAN, SOCK_RAW, CAN_RAW); s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
  
Line 234: Line 237:
 bind(s, (struct sockaddr *)&addr, sizeof(addr)); bind(s, (struct sockaddr *)&addr, sizeof(addr));
  
-/build CAN data frame+/
 + build CAN data frame 
 + */
 struct can_frame frame; struct can_frame frame;
 frame.can_id = node_id | CAN_EFF_FLAG;  // node id + extended frame format frame.can_id = node_id | CAN_EFF_FLAG;  // node id + extended frame format
Line 245: Line 250:
 frame.data[5] = 0x66;                   // data frame last byte frame.data[5] = 0x66;                   // data frame last byte
  
-/send data frame via CAN bus+/
 + send data frame via CAN bus 
 + */
 write(s, &frame, sizeof(frame)); write(s, &frame, sizeof(frame));
 </code> </code>
  • litesom/devicetree/can.txt
  • Last modified: 2021/05/12 10:08
  • by kateryna.kozakova