LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   USB device programming in Linux, how to R/W to USB DB-9 connector (https://www.linuxquestions.org/questions/programming-9/usb-device-programming-in-linux-how-to-r-w-to-usb-db-9-connector-665299/)

bapigoo9 08-25-2008 01:36 PM

USB device programming in Linux, how to R/W to USB DB-9 connector
 
This post is about a USB device that I bought that connects to the USB port and that has a DB-9 "serial" connector on it. I would like to write some Linux software to be able to read and write to the 9 pins or to whatever pins I can R/W to. I know that Linux has a device for USB, namely /dev/usb, though I would like to find out how I can write code to interact with the usb port that I connect the device to.

Anyone who has done this type of pin R/W for a USB port who can tell me how to get started would be helpful. I found a ton of websites on USB and Linux...just not one that gives answers to how to do this in software on Linux.

The device did some with a mini-cd and $$$ drivers. I want to use Linux drivers or Linux utilities to R/W to the USB, and have since tossed the mini-cd into the deep ditch.

MS3FGX 08-25-2008 03:21 PM

So then you are dealing with a USB to RS-232 adapter? In that case, you should be able to do anything you can do on a real serial port by just addressing the adapter's device node. The adapter is designed to be transparent to software, so you should really be looking into Linux serial port guides, and ignore the fact it is a USB device.

Unless there is something more advanced you are trying to do?

theNbomr 08-25-2008 04:16 PM

What MS3FGX says is true only if there is a (Linux) driver installed for the adapter. If not, you would have to locate one (from the device vendor, in all likelihood), write one, or use a different such adapter that does have driver support. Writing your own driver would be difficult at best.
--- rod.

bapigoo9 08-25-2008 04:42 PM

There is no device driver for the USB device for Linux that I have seen, unless you are aware of one? MS3FGX.

Right now, it does not follow any RS232 communication standard. It is a plain DB-9 pin connector on one end with a USB connector on the other end. So, how can I R/W to the pins on the DB9 from Linux (which would be R/W to the USB if you are understanding the device.)

MS3FGX 08-25-2008 07:43 PM

Well, again, if it is a standard USB to RS-232 adapter; then these are very common devices and are supported natively in the kernel by a number of chipset-specific drivers.

But from your description it sounds more like you have a USB male end on one side, and a DB-9 female on the other? In that case, this is some proprietary adapter that must be for a specific device which uses USB pinouts in the DB-9 formfactor. You wouldn't be able to do anything with this device, as USB only makes use of 4 wires (VCC, Ground, D+, D-), and doesn't operate on the same principles as a RS-232 port. There is no concept of bringing one of the wires "high" on USB, since the individual lines are not controlled by software; the power lines are constant and the two data lines work together.

salasi 08-26-2008 02:08 AM

There are several things about this thread that make no sense to me.
  • Is there any evidence that there is an RS 232 interface - the D-type connector used on RS 232 is a common connector and just because there is one of those does not mean that there is an RS232 interface?
  • It is unclear what the underlying objective would be; assuming that there is an RS 232 interface, why would you want to write to it? In other words, what do you hope this to achieve? If it is RS 232 normal operation will have various characters being passed back and forth and if you managed to force some line permanently high, for example, you would break normal operation, at least for the duration of the line being held high. In what way would this be an advantage to you?

MS3FGX 08-26-2008 02:50 PM

I imagine he might be interfacing a device with the computer via serial port, and rather than have a complicated digital converter decoding the binary data he would rather bring the lines high to directly trigger relays and the like.

bapigoo9 08-28-2008 09:57 AM

Quote:

you should be able to do anything you can do on a real serial port by just addressing the adapter's device node. The adapter is designed to be transparent to software, so you should really be looking into Linux serial port guides, and ignore the fact it is a USB device.
Can you give some example code of addressing the device and individual pins of the DB-9? The connectors are a standard USB "male" (same as on a Flash USB stick) and a DB-9 male, or what you called a USB to RS-232 adapter.

What are the standard chipset drivers for this device? There are no Linux vendor supplied drivers for it that shipped with the device.


All times are GMT -5. The time now is 01:38 AM.