Ruby thread is buggy while using serialport

Hi all ,
      I am using following gems .

    gem1.8 list

*** LOCAL GEMS ***

actionmailer (2.3.2)
actionpack (2.3.2)
activesupport (2.3.2)
ruby-ole (1.2.8.2)
ruby-serialport (0.7.0)
spreadsheet (0.6.3.1)
xml-simple (1.0.12)

     I am using modem . By using the serialport I am accessing the modem
port .

while using the <modemobject>.sysread or read get blocked although I
set <modemobject>.read_timeout = -1

But in fork it is working properly .

log is ,irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'serialport'
=> true
irb(main):003:0> sp = SerialPort.new( "/dev/ttyPS1" , 115200 )
=> #<SerialPort:0xb796b074>
irb(main):004:0> sp.read_timout
NoMethodError: undefined method `read_timout' for
#<SerialPort:0xb796b074>
        from (irb):4
irb(main):005:0> sp.read_timeout
=> 0
irb(main):006:0> sp.read_timeout = -1
=> -1
irb(main):007:0> sp.sysread 45
EOFError: end of file reached
        from (irb):7:in `sysread'
        from (irb):7
irb(main):008:0> sp.sysread 45
EOFError: end of file reached
        from (irb):8:in `sysread'
        from (irb):8
irb(main):009:0> sp.sysread 45
EOFError: end of file reached
        from (irb):9:in `sysread'
        from (irb):9
irb(main):010:0> sp.sysread 45
EOFError: end of file reached
        from (irb):10:in `sysread'
        from (irb):10
irb(main):011:0> sp.sysread 45
EOFError: end of file reached
        from (irb):11:in `sysread'
        from (irb):11
irb(main):012:0> fork {
irb(main):013:1* sp.sysread 45
irb(main):014:1> }
(irb):13:in `sysread': end of file reached (EOFError)
        from (irb):13:in `irb_binding'
        from (irb):12:in `fork'
        from (irb):12:in `irb_binding'
        from /usr/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'
        from /usr/lib/ruby/1.8/irb/workspace.rb:52
=> 9425
irb(main):015:0> Thread.new(sp){ |sp|
irb(main):016:1* sp.sysread 43
irb(main):017:1> }
=> #<Thread:0xb7955620 sleep>
irb(main):018:0> Thread.new(sp){ |sp|
irb(main):019:1* p "before"
irb(main):020:1> sp.sysread 43
irb(main):021:1> p "asdf"
irb(main):022:1> }
"before"=> #<Thread:0xb794e8d4 run>
< blocked>

Can any one help me to resolve this?

cheers ,
ashikali

···

--
Posted via http://www.ruby-forum.com/.

Discount Ed hardy tshirt (www.ebuyings.com)
Discount Ed hardy jean (www.ebuyings.com)
Discount Ed hardy shoes (www.ebuyings.com)
Discount Ed hardy handbag (www.ebuyings.com)
Discount Ed hardy other porduct (www.ebuyings.com)
Discount Nike air jordans (www.ebuyings.com)
Discount Nike Air Max 90 Sneakers (www.ebuyings.com)
Discount Nike Air Max 91 Supplier (www.ebuyings.com)
Discount Nike Air Max 95 Shoes Supplier (www.ebuyings.com)
Discount Nike Air Max 97 Trainers (www.ebuyings.com)
Discount Nike Air Max 2003 Wholesale (www.ebuyings.com)
Discount Nike Air Max 2004 Shoes Wholesale
(www.ebuyings.com)
Discount Nike Air Max 2005 Shop (www.ebuyings.com)
Discount Nike Air Max 2006 Shoes Shop (www.ebuyings.com)
Discount Nike Air Max 360 Catalogs (www.ebuyings.com)
Discount Nike Air Max Ltd Shoes Catalogs (www.ebuyings.com)
Discount Nike Air Max Tn Men's Shoes (www.ebuyings.com)
Discount Nike Air Max Tn 2 Women's Shoes (www.ebuyings.com)
Discount Nike Air Max Tn 3 Customize (www.ebuyings.com)
Discount Nike Air Max Tn 4 Shoes Customize
( www.ebuyings.com)
Discount Nike Air Max Tn 6 Supply (www.ebuyings.com)
Discount Nike Shox NZ Shoes Supply (www.ebuyings.com)
Discount Nike Shox OZ Sale (www.ebuyings.com)
Discount Nike Shox TL Store (www.ebuyings.com)
Discount Nike Shox TL 2 Shoes Store (www.ebuyings.com)
Discount Nike Shox TL 3 Distributor (www.ebuyings.com)
Discount Nike Shox Bmw Shoes Distributor (www.ebuyings.com)
Discount Nike Shox Elite Shoes Manufacturer
(www.ebuyings.com)
Discount Nike Shox Monster Manufacturer (www.ebuyings.com)
Discount Nike Shox R4 Running Shoes (www.ebuyings.com)
Discount Nike Shox R5 Mens Shoes (www.ebuyings.com)
Discount Nike Shox Ride Womens Shoes (www.ebuyings.com)
Discount Nike Shox Rival Shoes Wholesaler (www.ebuyings.com)
Discount Nike Shox Energia Wholesaler (www.ebuyings.com)
Discount Nike Shox LV Sneaker (www.ebuyings.com)
Discount Nike Shox Turbo Suppliers (www.ebuyings.com)
Discount Nike Shox Classic Shoes Suppliers
(www.ebuyings.com)
Discount Nike Shox Dendara Trainer (www.ebuyings.com)
Discount Nike Air Jordan 1 Seller (www.ebuyings.com)
Discount Nike Air Jordan 2 Shoes Seller (www.ebuyings.com)
Discount Nike Air Jordan 3 Collection (www.ebuyings.com)
Discount Nike Air Jordan 4 Shoes Collection
(www.ebuyings.com)
Discount Nike Air Jordan 5 Chaussure Shoes
(www.ebuyings.com)
Discount Nike Air Jordan 6 Catalog (www.ebuyings.com)
Discount Nike Air Jordan 7 Shoes Catalog (www.ebuyings.com)
Discount Nike Air Jordan 8 Customized (www.ebuyings.com)
Discount Nike Air Jordan 9 Shoes Customized
(www.ebuyings.com)
Discount Nike Air Jordan 10 Wholesalers (www.ebuyings.com)
Discount Nike Jordan 11 Shoes Wholesalers (www.ebuyings.com)
Discount Nike Air Jordan 12 Factory (www.ebuyings.com)
Discount Nike Air Jordan 13 Shoes Factory (www.ebuyings.com)
Discount Nike Air Jordan 14 Shoes Sell (www.ebuyings.com)
Discount Nike Air Jordan 16 Exporter (www.ebuyings.com)
Discount Nike Air Jordan 17 Shoes Exporter
(www.ebuyings.com)
Discount Nike Air Jordan 18 Offer (www.ebuyings.com)
Discount Nike Air Jordan 19 Shoes Offer (www.ebuyings.com)
Discount Nike Air Jordan 20 Manufacture (www.ebuyings.com)
Discount Nike Jordan 21 Shoes Manufacture (www.ebuyings.com)

"before"=> #<Thread:0xb794e8d4 run>
< blocked>

My guess is that serialport library has no way of knowing if it has any
data incoming [it has to poll until data arrives?]
If that's the case, then you might could use fork plus some of the
excellent fork libraries available
http://allgems.ruby-forum.com/gems?search=fork or you'd need to "fix"
serialport so that it's 1.9 compatible, and then wrap its read call in
an rb_thread_blocking_region, so that it allows other threads to
operate.
GL.
-r

···

--
Posted via http://www.ruby-forum.com/\.

Roger Pack wrote:

"before"=> #<Thread:0xb794e8d4 run>
< blocked>

My guess is that serialport library has no way of knowing if it has any
data incoming [it has to poll until data arrives?]
If that's the case, then you might could use fork plus some of the
excellent fork libraries available
http://allgems.ruby-forum.com/gems?search=fork or you'd need to "fix"
serialport so that it's 1.9 compatible, and then wrap its read call in
an rb_thread_blocking_region, so that it allows other threads to
operate.
GL.
-r

No I am using frok only . It is working fine no problem .

Also while traping simultaneous SIGCLD also it does not working properly
.

Please fix it and makes rubyserial compactable with thread and Traping
signal .

cheers,
ashik ali

···

--
Posted via http://www.ruby-forum.com/\.

You are passing in the same object to different threads. So the
threads call methods on the same object.

Try creating a SerialPort.new inside the thread.

With fork, you generate a seperate ruby process with seperate objects.

···

On Aug 12, 6:40 am, Ashikali Ashikali <ashikal...@gmail.com> wrote:

Roger Pack wrote:

>> "before"=> #<Thread:0xb794e8d4 run>
>> < blocked>

> My guess is that serialport library has no way of knowing if it has any
> data incoming [it has to poll until data arrives?]
> If that's the case, then you might could use fork plus some of the
> excellent fork libraries available
>http://allgems.ruby-forum.com/gems?search=forkor you'd need to "fix"
> serialport so that it's 1.9 compatible, and then wrap its read call in
> an rb_thread_blocking_region, so that it allows other threads to
> operate.
> GL.
> -r

No I am using frok only . It is working fine no problem .

Also while traping simultaneous SIGCLD also it does not working properly

geidies@googlemail.com wrote:

> serialport so that it's 1.9 compatible, and then wrap its read call in
> an rb_thread_blocking_region, so that it allows other threads to
> operate.
> GL.
> -r

No I am using frok only . It is working fine no problem .

Also while traping simultaneous SIGCLD also it does not working properly

You are passing in the same object to different threads. So the
threads call methods on the same object.

Try creating a SerialPort.new inside the thread.

With fork, you generate a seperate ruby process with seperate objects.

I have to inform you another problem . Al though I am using Thread for
one serial
port let us say /dev/ttyPS0 .

It is blocking another serial devive /dev/ttyPS2 . I could not
understand why thread is blocking another serial device too while using
serialport library .

Please go through the attached source code . For your reference .

Attachments:
http://www.ruby-forum.com/attachment/3947/modemThread.rb

···

On Aug 12, 6:40�am, Ashikali Ashikali <ashikal...@gmail.com> wrote:

--
Posted via http://www.ruby-forum.com/\.

I have to inform you another problem . Al though I am using Thread for
one serial
port let us say /dev/ttyPS0 .

It is blocking another serial devive /dev/ttyPS2 . I could not
understand why thread is blocking another serial device too while using
serialport library .

Are they both being read from within the same process, in different threads?
-r

Roger Pack wrote:

I have to inform you another problem . Al though I am using Thread for
one serial
port let us say /dev/ttyPS0 .

It is blocking another serial devive /dev/ttyPS2 . I could not
understand why thread is blocking another serial device too while using
serialport library .

Are they both being read from within the same process, in different
threads?
-r

yes , of course .

Please have look on attached modemThread.rb file .

Attachments:
http://www.ruby-forum.com/attachment/3948/modemThread.rb

···

--
Posted via http://www.ruby-forum.com/\.

Ashikali Ashikali wrote:

Roger Pack wrote:

I have to inform you another problem . Al though I am using Thread for
one serial
port let us say /dev/ttyPS0 .

It is blocking another serial devive /dev/ttyPS2 . I could not
understand why thread is blocking another serial device too while using
serialport library .

Are they both being read from within the same process, in different
threads?
-r

yes , of course .

Please have look on attached modemThread.rb file .

  One port is in same process another one in therad .

   please go through the attached modemThread.rb in previous .

···

--
Posted via http://www.ruby-forum.com/\.