# Controlling USB-RS232 interface

**URL:** <https://www.ruby-forum.com/t/controlling-usb-rs232-interface/67442>\
**Category:** Ruby\
**Created:** [September 4, 2006, 2:43pm UTC](https://www.ruby-forum.com/t/controlling-usb-rs232-interface/67442 "2006-09-04T14:43:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 4, 2006, 2:43pm UTC](https://www.ruby-forum.com/t/controlling-usb-rs232-interface/67442/1 "2006-09-04T14:43:58Z")

</div>

Before reverting to C, et al, can I use Ruby to do this?

I have a ccd camera which has a 4 pin serial interface (pwr, gnd, txd,  
rxd).  
I have a board that provides a 9-pin rs232 connector which is used to  
interface to it.  
I want to control it with a notebook (Toshiaba Satellite) which has no  
rs232 ports  
and 3 USB-2 connectors. I have a USB-R232 (9-pin male) cable which can  
connect  
to the camera board. The cameral comes with a canned gui frontend app  
which  
interfaces to the camera and allows you to take pictures at different  
resolutions,  
but is basically just to verify that the system is working. I can only  
run this software  
on my old (circa 1999) desktop because it has a serial connector and  
the software is  
hardwired to use COM1. It’s a simple windows program that I’m runnning  
under Win 98,  
and can also run under Linux (PCLinuxOS) using WINE. So I can take  
pictures and  
verify that the camera works under different resolutions under both  
OSes.

I need to access the camera and take full control of its features and  
functionality.  
Thus, I need to fully control the command interface to the camers,  
which requires  
sending/receiving commands (6 byte codes) and receiving images. This  
requires  
controllnig the rs232 interface to the camera.

So, can anyone provide or direct me to code for controlling an old  
rs232 serial port and a new  
USB-RS232 serial connection?

Thanks in advance.

Jabari

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 4, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/controlling-usb-rs232-interface/67442/2 "2006-09-04T14:44:03Z")

</div>

Hello

On 9/3/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> USB-RS232 serial connection?  
> The driver for your usb-serial adapter should make it appear as a  
> standard serial port to your applications.

If you searched the web for ruby and serial ports you should have  
found some of the earlier discussions on the topic such as this:

[http://groups.google.com/group/comp.lang.ruby/msg/1f72a79dd9760dc1?hl=en&](http://groups.google.com/group/comp.lang.ruby/msg/1f72a79dd9760dc1?hl=en&)

I would first try to use the real serial port to test the  
communication. The USB-RS232 adapters tend to be less compatible than  
the good old hardware for some reason.

Thanks

Michal

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 4, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/controlling-usb-rs232-interface/67442/3 "2006-09-04T14:44:06Z")

</div>

Do the contents of the following thread help:  
[http://groups.google.com/group/comp.lang.ruby/browse\_frm/thread/21d9ef82f56346a/1f72a79dd9760dc1?lnk=gst&q=serial&rnum=1#1f72a79dd9760dc1](http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/21d9ef82f56346a/1f72a79dd9760dc1?lnk=gst&q=serial&rnum=1#1f72a79dd9760dc1)

Or do any of these search results help:  
[http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb?key=serial+port+programming&cginame=namazu.rb&submit=Search&dbname=ruby-talk&max=50&whence=0](http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb?key=serial+port+programming&cginame=namazu.rb&submit=Search&dbname=ruby-talk&max=50&whence=0)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 4, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/controlling-usb-rs232-interface/67442/4 "2006-09-04T14:44:06Z")

</div>

removed\_email\_address@domain.invalid wrote:

/ …

> So, can anyone provide or direct me to code for controlling an old  
> rs232 serial port and a new  
> USB-RS232 serial connection?

AFAIK as to Ruby, all such serial interfaces and their drivers, of the  
old  
and new varieties, are platform-specific. You will have to make system  
calls to get the results you are after, and the calls will vary by  
platform.
