Reading rs485 with Ruby

Discussion in 'Ruby' started by iosubueno, Dec 19, 2012.

  1. iosubueno

    iosubueno Guest

    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.
    iosubueno, Dec 19, 2012
    1. Advertisements

  2. iosubueno


    Dec 21, 2012
    Likes Received:
    Code (Text):

    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
          port = $port.to_i - 1
      baud = $baud
      $sp =,'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
    sevk, Dec 21, 2012
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads