Terminal program help on cygwin

I am having a problem with writing a terminal program that runs under
cygwin ruby. The same code works on Linux. The problem is that I need a
non-blocking read to read incoming data from the serial port. I am using
the termios package to setup the serial port. Below works but is too
slow. I want to get more than one character at a time, but not block on
the read.

while @flagRunning do
    if select( [@io], nil, nil, 0.2 ) then
        c = @io.getc
        if (c >= 32) && (c <= 126) then 
            displayText( c.chr )
        end
end

I have written a C program with the desired behavior, but to get it to
work I have to do the open
with O_RDWR | O_NONBLOCK | O_NOCTTY. How do I take an open port and add
in the last two attributes?

Steve Tuckner

I hate to respond to my own post, but I think fcntl will do the trick
for me. Now if I can only get it to work…

Steve Tuckner

···

-----Original Message-----
From: Steve Tuckner [mailto:STUCKNER@MULTITECH.COM]
Sent: Wednesday, September 11, 2002 1:26 PM
To: ruby-talk ML
Subject: Terminal program help on cygwin

I am having a problem with writing a terminal program that runs under
cygwin ruby. The same code works on Linux. The problem is that I need a
non-blocking read to read incoming data from the serial port. I am using
the termios package to setup the serial port. Below works but is too
slow. I want to get more than one character at a time, but not block on
the read.

while @flagRunning do
    if select( [@io], nil, nil, 0.2 ) then
        c = @io.getc
        if (c >= 32) && (c <= 126) then 
            displayText( c.chr )
        end
end

I have written a C program with the desired behavior, but to get it to
work I have to do the open
with O_RDWR | O_NONBLOCK | O_NOCTTY. How do I take an open port and add
in the last two attributes?

Steve Tuckner