Cynerd opened a new pull request, #17283:
URL: https://github.com/apache/nuttx/pull/17283

   
   ## Summary
   
   This adds ioctl to NuttX's CAN that allows control of the read behavior.
   
   ## Impact
   
   The old behavior of reading multiple frames with a single read is preserved. 
The new ioctl just adds the ability to limit it. That includes not only 
disabilities but also more versatile limitations based on the size, which 
allows for multiple frames to be read.
   
   ## Testing
   
   Tested on a custom SAMv7 board.
   
   ```c
     int fd = open("/dev/can0", O_RDWR);
     if (fd < 0) {
       syslog(LOG_ERR, "Failed to open can: %s", strerror(errno));
       return -1;
     }
     size_t iw = SIZE_MAX;
     ioctl(fd, CANIOC_SET_IWATERMARK, &iw);
     while (true) {
       sleep(1); /* Give us some time to use cansend multiple times*/
       struct can_msg_s frame;
       size_t n = read(fd, &frame, sizeof frame);
       syslog(LOG_INFO, "Read %d id%d", n, frame.cm_hdr.ch_id);
     }
   ```
   ```
   for i in {0..4}; do cansend can0 "00$i##0"; done
   ```
   
   For `iw == SIZE_MAX`:
   ```
   [1762352028.612600] startup_main: Read 4 id0
   [1762352029.613000] startup_main: Read 16 id1
   ```
   for `iw == 0`:
   ```
   [1762352153.185100] startup_main: Read 4 id0
   [1762352154.185500] startup_main: Read 4 id1
   [1762352155.185900] startup_main: Read 4 id2
   [1762352156.186300] startup_main: Read 4 id3
   [1762352157.186700] startup_main: Read 4 id4
   ```
   for `iw == 5`:
   ```
   [1762352293.124000] startup_main: Read 4 id0
   [1762352294.124400] startup_main: Read 8 id1
   [1762352295.124900] startup_main: Read 8 id3
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to