provides software and services that enable enterprises
Live Chat 1-888-673-6564
The Enterprise Open Source Blog
  • Home
  • Search
  • Contact Us
  • Products and Support
  • Services
  • Enterprise OSS Blog
  • Wazi Technical Blog
  • Resources Library
  • Cloud Services
  • Partners
  • Customers
  • Community
  • Company
  • Careers
  • News and Events

Subscribe by Email

Your email:

Most Popular Posts

  • Enterprise Apache Tomcat 7 Clustering - Designing an Efficient, Reliable and Productive Application Server Cluster
  • Open Source Virtual Whiteboards and Dimdim Review
  • An Enterprise Apache Tomcat Clustering Guide
  • Supporting CentOS In The Cloud With Windows Azure
  • VLC License Change: A lesson in perseverance
  • An In-Depth Look at Tomcat’s Clustering Mechanisms
  • Apache HTTP Server: New Features for Version 2.4
  • Why Closed Source is Better Than Open Source
  • Access Serial Ports through Ruby
  • JBoss AS7 Clustering Using mod_cluster and http 2.4 (Part 1)

Connect With Us!

Current Articles | RSS Feed RSS Feed

Access Serial Ports through Ruby

Posted by Aaron Mandelbaum on Fri, Apr 11, 2008
  
Email This Email Article  
Tweet  
  

Ruby is a great programming language for many purposes, however, it's weak when it comes to device support for embedded projects. That said, one package that helps bridge the gap is the Ruby-SerialPort which, as its name implies, provides the classes needed to access a system's serial port from Ruby. Ruby SerialPort works very well with Mac OS X, Leopard on an Intel or PPC Mac (I've tested both), even though it hasn't been updated since 8/27/2003. Versions of Ruby SerialPort are said to work fine on Windows and Linux, though I've only tested it on Mac OS X. You can download Ruby-serialport from http://rubyforge.org/frs/?group_id=61&release_id=308 There are two steps to installing it. First you need to compile the C code that comes with the download. Assuming you have the GNU compiler installed (for Mac OS X, just make sure your XCode tools DVD is installed), it's as simple as this procedure: ruby extconf.rb make && sudo make install Here's an example of building Ruby SerialPort on OS X Leopard:  Then, to test it out, connect your serial device, identify the device port on your host system ("COM1:" for windows or "/dev/tty.KeyspanSerial1" for example on a *nix type box). Next take a look at the example code here that uses Ruby SerialPort to talk to an Arduino (another piece of open source hardware I've mentioned in the past): http://www.arduino.cc/playground/Interfacing/Ruby Modify the port_str variable in the example to point to the device port on your system, adjust any baud rate or framing attributes, and run it with ruby. I hooked up a KeySpan USB to Serial adapter to connect my Mac to a serial GPS and was able to see NMEA sentences flowing in through the ruby test application. Very nice, very handy. On my workbench, I have multiple serial GPS's, a Nokia LCD that's driven by serial, several LANtronix devices that translate serial to IP data and I'm sure if I dug through the archeology on my bench, I'd find other examples. Part of the reason I was looking for a Ruby serial solution was that I am working on a serial multiplexor to combine up to 5 serial data streams into one so microcontrollers with one serial port can still talk to many serial devices. I wrote the firmware for a Propeller ( a cool 32-bit 8-way multi-processor microcontroller - and a topic for another post sometime) to multiplex the data from devices like GPSs. I used Ruby SerialPort and Ruby code on my Mac to parse the multiplexed packets in and out of the propeller. As a basis for some of the firmware, I used the FullDuplexSerial.spin code that's open source (MIT). Here's a picture of my prototype serial multiplexor - the Propeller board is the blue board and some test serial devices are connected to it:

FYI - Because serial data devices are still so ubiquitous (in the form of RS232, TTL, USB, SPI, I2C), an excellent book on serial port software and hardware development is:


"Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems (Complete Guides series)" (Jan Axelson)

Long live serial. And thanks to the Ruby SerialPort project for making a cool add-on to Ruby.Follow @openlogic
Follow @OSCloudServices

This work is licensed under a Creative Commons Attribution 3.0 Unported License
Creative Commons License.
Tags: Open Source Trends

Comments

Currently, there are no comments. Be the first to post one!
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

Allowed tags: <a> link, <b> bold, <i> italics

Loading...
Error sending email
Email sent successfully

Email article
Email To : 
Your name : 
Message : (maximum 200 characters)

Enterprise OSS Blog Policy

If you read a post on The Enterprise OSS Blog, please leave a comment. Let us know what you think, even if it's just a few words. Comments do not require approval, but they are moderated.OpenLogic reserves the right to remove any comments it deems inappropriate.

 

click-to-chat-with-a-live-open-source-expert

get-a-quote-on-support

download-the-support-evaluation-kit

Browse by Tag

  • 2013 (2)
  • Agile (1)
  • Apache (2)
  • apache tomcat (1)
  • AS 7 (1)
  • as7 (1)
  • Auditing (5)
  • Azure (2)
  • Budget (1)
  • BusyBox (1)
  • CentOS (3)
  • Closed Source Software (1)
  • cloud (4)
  • clustering (1)
  • CMS (1)
  • Code Scanning (1)
  • commercial distribution (1)
  • Community (4)
  • compliance (40)
  • C-Suite (1)
  • Database (1)
  • developers (2)
  • DevOps (15)
  • diploma (1)
  • Drupal (1)
  • enterprise software (2)
  • foss (5)
  • Gitbhub (1)
  • GNU-Bash (1)
  • Governance (36)
  • guide (1)
  • Hadoop (2)
  • HBase (2)
  • http 2.4 (1)
  • httpd 2.4 (1)
  • Java (1)
  • javascript (1)
  • jboss (3)
  • JBoss Cluster (1)
  • Joomla (1)
  • Legal (21)
  • Legal & Compliance (62)
  • Legal and Compliance (2)
  • license compliance (1)
  • Licenses (12)
  • Linux (4)
  • lisp code (1)
  • martin fowler (1)
  • Mobile (3)
  • mod_cluster (2)
  • MySQL (1)
  • Neal Ford (1)
  • open source (19)
  • open source compliance (1)
  • open source components (1)
  • open source events (1)
  • Open Source Governance (2)
  • open source legal issues (1)
  • Open Source Licensing (3)
  • Open Source Management (38)
  • Open Source Policy (3)
  • open source software (15)
  • Open Source Software Adoption (4)
  • open source software policy (1)
  • Open Source Training (1)
  • Open Source Trends (337)
  • Open Source vs. Commercial Software (3)
  • OSS (5)
  • OSS Packages (2)
  • PaaS (1)
  • paredit (1)
  • picketlink (1)
  • Policy (4)
  • PostgreSQL (1)
  • Presentations (1)
  • Programming (2)
  • red hat (1)
  • RHEL (1)
  • Ruby (1)
  • Scanning (27)
  • Scanning & Governance (12)
  • Scanning & Provisioning (30)
  • Security (13)
  • Shibboleth (1)
  • software compliance (1)
  • Software Development (2)
  • Software Development Lifecycle (7)
  • software infrastructure (1)
  • Solr (1)
  • struts (1)
  • Support (48)
  • Support & Services (2)
  • SUSE (1)
  • Technical Governance (1)
  • The Cloud (35)
  • The C-Suite (2)
  • tomcat (4)
  • Training (10)
  • Ubuntu (1)
  • Uncategorized (69)
  • Windows (1)
  • Windows Azure (1)
  • Wordpress (1)
  • Zookeeper (1)
Home | Search | Contact Us | Products and Support | Services | Enterprise OSS Blog | Wazi Technical Blog | Resources Library | Cloud Services | Partners | Customers | Community | Company | Careers | News and Events
Products
OpenLogic Exchange (OLEX)
License Compliance Module
OSS Discovery
OSS Deep Discovery
OpenUpdate
Services
Open Source Support
CentOS Support
Scanning & Compliance
Open Source Training
Professional Services
Solutions
Support & Indemnification
Open Source Governance
Open Source Scanning
Open Source Provisioning
Consulting & Training
Contact Us
1-888-673-6564


© 2013 OpenLogic, Inc. All rights reserved.
Site Map  |  Privacy Policy