[racket] open-input-output-file, serial port, threads and Windows

From: Christophe Scholliers (cfscholl at vub.ac.be)
Date: Tue Apr 10 15:15:18 EDT 2012

Hello everyone,

I am struggling with the behavior of open-input-output-file on Windows for communicating with the serial port.
It seems to me that write operations on the output-port are blocked when issuing a read operation on the input-port (in a different thread).
Only when something is read on the input-port the write operation is performed.
On OSX and Linux this problem does not manifest itself as write operations are not blocked by read operations in a different thread.

In my particular application I worked around this problem by adjusting the software on the external device which is connected to the serial port. 
This device is currently adjusted to send dummy data in order to make sure that there is always something to read (from the computer's point of view).
By doing this the write operations from the computer to the external device are no longer blocked and  seemingly instantaneous.
As you can imagine, sending this dummy data is just a hack and I would like to find a more structured way to solve this problem.

Any suggestions for solving this problem are welcomed :)  

Finally, I would also like to report that when opening a serial port (only on windows) with a number greater than 9 
so for example "COM12" a file is created instead of opening the serial port. 
I guess this should be an easy fix ...

If anybody would have experienced that problem you can currently work around that problem by assigning a different (lower than 9 of course) number to the serial port via the device manager. 


Thanks,
Christophe

When searching for a solution I saw that other people had problems with setting the baud-rate of the serial port.
With my setup the following commands configure the serial port (where port-name is for example "COM1"): 

//Windows
(system (string-append  "mode " port-name ": baud=57600 parity=N data=8 stop=1")) 

//Mac OSX
(system (string-append  "stty -f " port-name " 57600 cs8 cread clocal"))

//Linux 
(system (string-append  "stty -F " port-name " 57600 -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts -ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8 -opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke"))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120410/29a383d3/attachment.html>

Posted on the users mailing list.