Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I doubt this answers your question, but I think it will help.</p> <p>In void SerialManager::asyncRead(byte*, const size_t&amp;, bool&amp;), there are two bugs:</p> <ol> <li><p>You're using the value of errno (and printing messages based on it using perror) when read returns success, not only when it errors out (return value &lt; 0). On success, errno is not specified to have any particular value. So you're effectively using garbage data; the EBUSY you're getting probably doesn't mean anything whatsoever. errno is only defined to have a particular value when a particular error has occurred. See 'man errno' on a Linux system, which on my Debian system says in relevant part: "Its value is significant only when the return value of the call indi‐cated an error (i.e., -1 from most system calls; -1 or NULL from most library functions); a function that succeeds is allowed to change errno.". Note the "is allowed to", rather than "must".</p></li> <li><p>You read into a temp buffer, then copy it byte-by-byte into the destination buffer which the caller passed. This is a pointless waste of CPU cycles and memory bandwidth. You could just read straight into the caller's buffer. Even if you must (for some strange reason) read into a temp buffer then copy it elsewhere, you should copy it elsewhere using memcpy(3) or perhaps memmove(3), not using your own byte-by-byte loop.</p></li> </ol> <p>Regarding the design, I don't understand the point of having multiple readers or writers when there is only one serial port. Are you trying to achieve parallelism? I don't see how you can, with only one serial port. If you want asynchronicity but not parallelism, you should investigate fcntl(fd, F_SETFL, existing_flags &amp; O_ASYNC) (although signals are rather old and ugly), or perhaps just set the fd non-blocking, then call select() in the inner event loop of your application and handle any I/O (if any) that's available.</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload