Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can you flush a write using a file descriptor?
    primarykey
    data
    text
    <blockquote> <p>It turns out this whole misunderstanding of the open() versus fopen() stems from a buggy I2C driver in the Linux 2.6.14 kernel on an ARM. Backporting a working bit bashed driver solved the root cause of the problem I was trying to address here.</p> </blockquote> <p>I'm trying to figure out an issue with a serial device driver in Linux (I2C). It appears that by adding timed OS pauses (sleeps) between writes and reads on the device things work ... (much) better. </p> <blockquote> <p>Aside: <em>The nature of I2C is that each byte read or written by the master is acknowledged by the device on the other end of the wire (slave) - the pauses improving things encourage me to think of the driver as working asynchronously - something that I can't reconcile with how the bus works. Anyhoo ...</em></p> </blockquote> <p>I'd either like to <strong>flush</strong> the write to be sure (rather than using fixed duration pause), <strong><em>or</em></strong> somehow test that the write/read transaction has <strong>completed</strong> in an multi-threaded friendly way. </p> <p>The trouble with using <code>fflush(fd);</code> is that it requires 'fd' to be stream pointer (not a file descriptor) i.e.</p> <pre><code>FILE * fd = fopen("filename","r+"); ... // do read and writes fflush(fd); </code></pre> <p>My problem is that I require the use of the <code>ioctl()</code>, which doesn't use a stream pointer. i.e.</p> <pre><code>int fd = open("filename",O_RDWR); ioctl(fd,...); </code></pre> <p>Suggestions?</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.
 

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