I need to read from my rs-232 port in one thread and write in my other thread. I am using fopen, fgetc, and fputc. I plan to get the file descriptor number and opening the file in the second thread using fdopen.
One thread only reads and one thread only writes. Does anyone know if this will work? I can use mutex locks if necessary.
All of the threading and asynchronous multiplexing is handled for you by the Asio library.
But I do recognize that you have not acknowledged my earlier suggestions to use Boost for this. To do this without Asio, you will need to use a mutex. You cannot safely read and write to a single file descriptor from separate threads. There are atomicity guarantees in some circumstances (pipes for example), but I do not think it applies to serial devices.