Reading rs485 with Ruby


I

iosubueno

Im looking for a way to communicate via rs485 with ruby, after searching I couldnt find any gem or even comments in any forum .
Anybody knows if someone already made this or if its even possible? Thanks.
 
Ad

Advertisements

Joined
Dec 21, 2012
Messages
4
Reaction score
0
Code:
gem list 
serialport (1.1.0)


========================
#!/usr/bin/env ruby -w
# -*- coding: ascii-8bit -*-

require 'serialport'
require 'platform.rb'

module SerialCom
   if $port.class == String and $port[0] == '/'
      port = $port
   else
      port = $port.to_i - 1
   end
  baud = $baud
  $sp = SerialPort.new(port,'parity'=>0,'baud'=>baud,'stop_bits'=>1,'data_bits'=>8) rescue (puts $!.message; sleep 2)
  $sp.read_timeout = 80#30
  $sp.write_timeout = 80 if win_platform?
  p $sp.get_modem_params
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top