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
    1. Advertisements

  2. iosubueno

    sevk

    Joined:
    Dec 21, 2012
    Messages:
    4
    Likes Received:
    0
    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
       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
                 
     
    sevk, Dec 21, 2012
    #2
    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
Loading...