can anyone help with gpio to serial in software?

Started by drspastic, February 19, 2013, 08:30:08 PM

Previous topic - Next topic

drspastic

i want to emulate an rs232 port using the gpio pins on my 233 micro and software.
i need to run software that requires access to a /dev/tty device, but its not to transmit and receive serial data, just to read and write a logic value at two of the control lines (rts or dtr  as output and cts, dsr, or dcd as input) and i really dont want to alter the software.

can anyone think of how to do this? does it entail writing some kind of driver?

jlumme

Hmm, I'm not 100% sure here, but aren't those U_DEBUG pins a serial port? They are not in RS232 levels, but otherwise it's my understanding that it is a serial port.
If you could take over from kernel (by default they are used by the console) the control of those pins, I guess you could use them (and you'll need a level shifter to convert from TTL levels to RS232).

Fadil Berisha

Hi drspastic,

I assume that you have application software running in PC and communicating with some external hardware via RS232 interface using flow control pins (RTS, CTS and DCD).

Best way to run that application on olinuxino board is to use  USB to RS232 bridge attached on olinuxino USB port. You may consider products based on Silicon Labs CP2102. Here is quote from CP2102 Data Sheet (read PC as olinuxino board):

"Application software running on the PC accesses the CP2102-based device
as it would access a standard hardware COM port. However, actual data transfer between the PC and the CP2102
device is performed over the USB interface. Therefore, existing COM port applications may be used to transfer
data via the USB to the CP2102-based device without modifying the application"

Make sure that USB/RS232 bridge has exposed flow control pins on RS232 connector and activate CP2102 virtual COM driver on your kernel. Here is link to such $5 device: http://www.ebay.ca/itm/Mini-USB-To-TTL-COM-Converter-Module-build-in-CP2102-/190370706355?pt=LH_DefaultDomain_0&hash=item2c52fa73b3

Hope this help

Fadil Berisha


 

drspastic

it seems what i need is a virtual com port that i can patch those hardware control lines to gpio.
a usb com port is not an option, its almost as big as the 233 micro itself, also i do not need rs232 levels, so then i would need another board to take it back to ttl. you see my point?
i will read up on virtual com ports but i fear most writing is about use over interweb rather than controlling hardware directly, so i look forward to your continued input.

Evgeny Boger

Actually, patching the kernel UART driver to emulate control lines via GPIO doesn't seem very complicated.

You could also consider using i2c/spi to uart bridge ICs like NXP SC16ISxxx or MAX310x. They are small, inexpensive and easy to operate. MAX310x should be supported by vanilla kernel.