hparra / ruby-serialport

ruby-serialport is a Ruby library that provides a class for using RS-232 serial ports
http://rubygems.org/gems/serialport
GNU General Public License v2.0
246 stars 58 forks source link

read_timeout not working #73

Open wf5w opened 2 years ago

wf5w commented 2 years ago

I am running with: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu] on Linux Mint 20.3

I have the following code snippet, but here is what I would expect: I would expect that after say 250 ms, that if there was no input then an error would be produced. EIO? but if a character came then the loop would continue. What is actually happening is nothing, it just hangs:

bytes = []

begin
  sp.read_timeout = 250
  puts "read timeout is set to: #{sp.read_timeout}\n"

  while 1
   bytes << sp.getc
   print bytes.last
    if bytes.last == 0xFD
      break
    end
  end
rescue => e
  unless e.class == Errno::EIO
    puts error.inspect
  end
end

puts "\n\nreceived: #{bytes.join('')}"
sumitbirla commented 2 years ago

I am also having this problem. Were you able to solve this?

wf5w commented 2 years ago

No. And I haven't seen anything that says they even acknowledge there's a problem.--Sent from my Android phone with GMX Mail. Please excuse my brevity.On 10/24/22, 6:01 PM Sumit Birla @.***> wrote:

I am also having this problem. Were you able to solve this? —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

wf5w commented 1 year ago

Well ok then,

I would say this gem is Useless for anyone doing serious work. on to python I guess or C

tenderlove commented 9 months ago

Please try this gem. It's meant as a replacement. You can use regular Ruby IO method calls like wait_readable (which takes a timeout).