Go Back   The macosxhints Forums > OS X Help Requests > Hardware and Peripherals



Reply
 
Thread Tools Rate Thread Display Modes
Old 04-29-2012, 01:30 PM   #1
astrotrf
Prospect
 
Join Date: Apr 2012
Posts: 5
Question USB serial virtual device

A web search reveals that this question is oft misunderstood, so I'll carefully describe my situation.

I am working with a Mac application on Snow Leopard and Lion. This application wants to speak to an external gadget which speaks RS-232. To that end, the application developers wrote their application to speak to a USB-to-serial converter plugged into the Mac; they're not particular as to which brand or model of USB-to-serial converter, they just expect one to be there.

Unfortunately, they are former Windows programmers who do not grok the idea of device-independent I/O at all. *All* the application will speak to is a USB-to-serial converter; you can't, for example, tell it to talk to a pty instead. As nearly as I can discern, they are using some bit of MacOS magic that scans the USB devices for the correct device type (which comes down to devices with major number 18, as far as I can tell). They then present that as a menu of the only connection options available.

My problem is that the external RS-232 gadget I need to speak with is some hundreds of feet away over a network. So what I would like to have is a piece of software that looks like a real USB-serial device but in actuality makes a TCP connection to a remote hostort of my choosing.

You can stop reading here if you understand what I'm talking about. Below is further explanation in case I have not been sufficiently clear above.

When you plug a USB-serial device into a Mac, the OS notices a new device, establishes that it *is* a USB-serial device, and creates device nodes in /dev. For the Arduino, for example, it creates two devices, /dev/tty.usbmodemxxxxx and /dev/cu.usbmodemxxxxx. These are major device number 18 and some pair of consecutive minor device numbers.

The userland software can then open /dev/tty.usbmodemxxxxx and speak to the Arduino. In my particular case, the application I'm working with recognizes the /dev/tty.usbmodemxxxxx device and offers to connect to it.

What I *need* is a piece of software that accomplishes the same thing without an actual piece of USB hardware, causing the OS to create an appropriate /dev node pair that will fool the application into allowing me to communicate with the piece of software rather than an actual hardware USB-serial device.

I would need this piece of software in source-code form so I can hack it to suit.

Let me note parenthetically here that I am not completely opposed to a hardware solution; it's just not what I prefer. If there is some USB gizmo out there that pretends to be a USB-serial converter but actually accepts an Ethernet cable and speaks TCP to the network rather than RS-232 to a serial cable, that would be great.

I actually have the Arduino I mentioned doing this. Unfortunately, the Arduino reboots when you open its /dev/tty.usbmodemxxxxx port, which means you have to delay for 2 or 3 seconds before attempting to talk to the Arduino. The application I an working with has no concept of such a delay, of course, so it times out trying to contact the remote gadget before the Arduino is even ready to begin relaying data.

OK, this was long. But I've read a number of web threads with a question essentially identical to mine, and they all started with an exchange of messages from potential respondents who failed to understand the original problem from a quick description. Thanks if you've read this far, and thanks also if you can point me to a piece of software that creates such a virtual USB-serial device.
astrotrf is offline   Reply With Quote
Old 04-30-2012, 07:39 PM   #2
gsahli
MVP
 
Join Date: Apr 2004
Location: Chicago
Posts: 1,263
Does this help at all?
http://en.wikipedia.org/wiki/COM_port_redirector
gsahli is offline   Reply With Quote
Old 05-01-2012, 08:49 AM   #3
vanakaru
All Star
 
Join Date: Oct 2006
Posts: 634
Look into Arduino. These boards can connect to your mac as USB-serial devices and talk TCP. Arduino+network module(shield) may be rather good cost effective solution.
vanakaru is offline   Reply With Quote
Old 05-01-2012, 04:37 PM   #4
astrotrf
Prospect
 
Join Date: Apr 2012
Posts: 5
As a matter of fact, I've already set up and programmed an Arduino Uno and Ethernet shield to do that very thing. The unfortunate bit is that the Arduino *reboots* when you open the serial port to it, which means you have to wait 2 or 3 seconds before beginning serial communications. The application I'm fighting with is completely unprepared to do this, of course, and so declares a communications failure and gives up.

I could do lots of other things on the hardware front, of course, including using a true USB-to-serial gadget and plugging it into a terminal server configured to use reverse TELNET to talk to a second terminal server at the remote end (which I would need in any case) and connecting it to the RS-232 device in question. A pure software solution on the host side would greatly simplify things, however, which is why I'm looking into it.

A MacOS version of a COM port redirector, so long as the COM port is defined as a virtual USB-to-serial device that the application can recognize and speak to, is precisely what I need. If the application was written with just a bit more sanity and could talk to a pty, I'd be done -- I've got code that I wrote years ago to convert that into a TCP connection.
astrotrf is offline   Reply With Quote
Reply

Tags
device, serial, usb, virtual

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 04:19 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.