[plt-scheme] Need low-level help: blocking on reading from serial port in Windows

From: YC (yinso.chen at gmail.com)
Date: Fri Oct 23 08:06:30 EDT 2009

On Thu, Oct 22, 2009 at 3:10 PM, Nadeem Abdul Hamid <nadeem at acm.org> wrote:

>
> First, everything works fine beautifully on Mac OS X. Then I went to try
> this on Windows XP (using PLT Scheme 4.2.2) and it would hang in this
> function. I've finally figured out that if I uncomment the "sleep"
> statement, then it does *not* hang. However, that makes performance very
> sluggish (even though LATENCY is defined as .01). So I'm wondering if
> without the sleep there is some sort of deadlock happening with the
> byte-ready? function? I suppose I could keep a counter and only "sleep"
> every 100 or 1000 failures of the byte-ready? condition, but does anyone
> have suggestions for a better way to do this? To tell the truth, I don't
> remember why I used byte-ready? to begin with -- in the morning I'll try
> without it and see what happens by just letting "read-byte" block until
> there's data.
>

Nadeem,

byte-ready? shouldn't "lock" with anything - if there are nothing to be read
in the port it returns immediately.  Could the hanging be that there are no
data coming through the port?  Because in that case your code (with sleep
commented out) will be run in a tight loop, which can appear as hanging.

I tested your function with a string port with plenty of data on WinXP and
it works.

Cheers,
yc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091023/195d26a9/attachment.html>

Posted on the users mailing list.