[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Serialport script hangs during sp.gets

Jordan Applewhite

6/16/2008 5:22:00 PM

Hi ruby friends!

I'm using the ruby serialport library. The OS is windows.

I'm sending command strings over serial to an epson projector. The
projector then interprets and executes the command and returns a string
based on the results.

The serial port is receiving my commands when I print them, but the
program hangs and crashes when I call gets, getc, or readline on the
serial port. Example paste here:
http://rafb.net/p/GF6...

This isn't a problem for commands like PWR ON and PWR OFF, since I can
just run those blindly and assume success. For commands like PWR? or
LAMP?, though, I need to see the return value.

The pastebin snippet isn't very comprehensive, but I have tried MANY
variations of gets, getc, readline, and with several different
(relevant, not random) record separators.

Any ideas why it is hanging and not returning a string? FYI, it does
return a string when I access the projector from Hyperterminal or
telnet.

Thanks a lot!
--
Posted via http://www.ruby-....

2 Answers

Phil Meier

6/17/2008 8:08:00 AM

0

Hi

in my experience Ruby serialport library for Windows is in most cases
not usable. I suppose the problem is Ruby's implementation of threads
(green threads) under Windows.

For serial communication under windows I now use a RS-232/422/485
connections over Ethernet (i.e. Ethernet to serial) - so from windows
(Ruby) perspective I use TCP/IP communication which works fine.

BR Philipp


Jordan Applewhite schrieb:
> Hi ruby friends!
>
> I'm using the ruby serialport library. The OS is windows.
>
> I'm sending command strings over serial to an epson projector. The
> projector then interprets and executes the command and returns a string
> based on the results.
>
> The serial port is receiving my commands when I print them, but the
> program hangs and crashes when I call gets, getc, or readline on the
> serial port. Example paste here:
> http://rafb.net/p/GF6...
>
> This isn't a problem for commands like PWR ON and PWR OFF, since I can
> just run those blindly and assume success. For commands like PWR? or
> LAMP?, though, I need to see the return value.
>
> The pastebin snippet isn't very comprehensive, but I have tried MANY
> variations of gets, getc, readline, and with several different
> (relevant, not random) record separators.
>
> Any ideas why it is hanging and not returning a string? FYI, it does
> return a string when I access the projector from Hyperterminal or
> telnet.
>
> Thanks a lot!

Jordan Applewhite

6/17/2008 1:37:00 PM

0

> in my experience Ruby serialport library for Windows is in most cases
> not usable. I suppose the problem is Ruby's implementation of threads
> (green threads) under Windows.

Someone was telling me the same thing yesterday in #ruby-lang. He was
shocked that it was working at all with ruby 1.8.6. Nevertheless, it
seems to be working today! All I had to do was set a seemingly
arbitrary read_timeout value. With the timeout, serialport.gets just
returns whatever was in the input buffer.

> For serial communication under windows I now use a RS-232/422/485
> connections over Ethernet (i.e. Ethernet to serial) - so from windows
> (Ruby) perspective I use TCP/IP communication which works fine.
>

Still, I'm very interested in your solution. Are you describing having
a cable with 8p8c on one end and dsub9 on the other, using ruby
networking lib to send the appropriate data? Could you post a link to
some example code, or perhaps specify the relevant ruby-doc pages?

Thanks! I appreciate your help!
--
Posted via http://www.ruby-....