# Does Ruby have support for serial connections - RS232?

**URL:** <https://www.ruby-forum.com/t/does-ruby-have-support-for-serial-connections-rs232/66928>\
**Category:** Ruby\
**Created:** [August 30, 2006, 12:24pm UTC](https://www.ruby-forum.com/t/does-ruby-have-support-for-serial-connections-rs232/66928 "2006-08-30T12:24:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisfinne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f1d935/32.png) [@chrisfinne](https://www.ruby-forum.com/u/chrisfinne)\
**Post date:** [August 30, 2006, 12:24pm UTC](https://www.ruby-forum.com/t/does-ruby-have-support-for-serial-connections-rs232/66928/1 "2006-08-30T12:24:18Z")

</div>

Hi everyone,

I would love to stick to Ruby with this problem - but is it possible in  
Ruby to interface with a device through a RS232 serial connection?

I want to connect my Windows XP computer with a medical device through  
RS232 - get data from the device and send it messages.

Any help greatly appreciated,  
Chris

---

<div class="post-metadata">

**Author:** ![chrisfinne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f1d935/32.png) [@chrisfinne](https://www.ruby-forum.com/u/chrisfinne)\
**Post date:** [August 30, 2006, 12:40pm UTC](https://www.ruby-forum.com/t/does-ruby-have-support-for-serial-connections-rs232/66928/2 "2006-08-30T12:40:51Z")

</div>

On 8/30/06, Chris F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

ruby-serialport might be what you are looking for:

[http://rubyforge.org/projects/ruby-serialport/](http://rubyforge.org/projects/ruby-serialport/)

Tom

---

<div class="post-metadata">

**Author:** ![chrisfinne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f1d935/32.png) [@chrisfinne](https://www.ruby-forum.com/u/chrisfinne)\
**Post date:** [August 31, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/does-ruby-have-support-for-serial-connections-rs232/66928/3 "2006-08-31T21:02:54Z")

</div>

Thomas Beckett wrote:

> > Chris  
> > Tom  
> > I have tried ruby-serialport for my win32 project without success.

In the package there is serialport.so that don’t works with my ruby  
installation (ruby 1.8.4 (2005-12-24) [i386-mswin32]).

To compile the file serialport.c in a dll with Visual Studio is not a  
problem, if you rember to use #define mswin in the code. When I tested  
my dll with miniterm.rb I get:  
(eval):1: (eval):1:in `private_class_method': undefined method`create’  
for clas  
s `Class' (NameError) from (eval):1 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in`re  
quire’  
from miniterm.rb:2

On miniterm.rb:2 there is only:  
require “serialport”

I don’t know how to fix it, but I have created a simple dll in C++,  
that works only in windows, to open a serial port and get some data on  
it (there are many free serial implementation that target win32 in  
C++). I have used Swig to export a function to get data.  
If you know the module Win32API you don’t need to create a dll.

---

<div class="post-metadata">

**Author:** ![chrisfinne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f1d935/32.png) [@chrisfinne](https://www.ruby-forum.com/u/chrisfinne)\
**Post date:** [September 1, 2006, 3:15am UTC](https://www.ruby-forum.com/t/does-ruby-have-support-for-serial-connections-rs232/66928/4 "2006-09-01T03:15:34Z")

</div>

It was easy to get this working.

[http://raa.ruby-lang.org/project/win32serial/](http://raa.ruby-lang.org/project/win32serial/)

Harry
