OpenWrt Forum Archive

Topic: Using serial port on WRT54GL

The content of this topic has been archived on 17 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi everyone

I'm actually working on a small project using WRT54GL from Linksys running under OpenWRT, and I need to know some technical things.
I saw that /dev/cua/0 and /dev/cua/1 (also called JP1 et JP2) could be used in the same way that a serial port, with small differences (RS232 in between -12V and 12V, but JP1 (wich is the JTAG port, right ?) and JP2 are between 0 and 3.3V (UART port).

Knowing that, I tried to put some control leds to know if the serial port is used as well, and I noticed that pin8 and 9 are always swithed on. I  managed once to swith on the pin4 but never managed to reproduice it.

Is there any chance of controlling it with OpenWRT ? If yes, what pins can I hope to control (I mean one by one) and how (should I use ioctl library ?) ?
For information, I disconnected serial console in inittab file to use it.

Thank you in advance

Pierre-Olivier Dybman
Responsable iTeam Securite
Ecole Centrale d'Electronique
http://blog.cr0vax.be ¦ dybman at ece.fr

I don't know if I understand what you're trying to do; but if you connect a LED between ground and the transmit line of a serial port it will of course glow (it may also get killed or kill the serial port if you do this without limiting the current...).
This is because if there is no data to transmit, the line will stay at the level for a binary '1' which translates to 3.3V on you WRT54GL. Both ttyS0 and ttyS1 are accessible at the same pin-header block. JTAG is on the other one and you only need that one for emergency recovery.
By the way: A serial port is used to transmit data bit after bit and although you could use it to directly control a LED, you'd better use one of the GPIO ports.

well in fact, I had some problem with the LEDs so that I didn't see them glowing but it now glows perfectly.
The Leds were put to know if the serial port was really working. So it does.

Now my question is : Is it possible to control a serial port pin by pin, just like a parallel port ? I mean, I have now only one LED glowing, I would like to have more LEDs on the serial port, but I need to control more pins and not only the transmit line. I heard it may be possible with ioctl library wich allows to control several pins.

My goal is to multiply the points that I can control (I already use the gpio points).

Is it really not possible to use the JTAG as a IO port ?

Thank you for your help

(Sorry for my poor english. I may be more clear in german or in french)

Pierre-Olivier Dybman
Responsable iTeam Securite
Ecole Centrale d'Electronique
http://blog.cr0vax.be ¦ dybman at ece.fr

Serial on most router (including the wrt54gl) is 4 pins (VCC, RX, TX, GND); each maps to a specific pin on the serial connector, but there is no way to control individual pins. Control of individual pins is the job of a gpio, or worst case a parallel port.

Search for mmc to see how some users are adding sd cards to their routers using gpio pins.

Thanks for your answer.
But I read here (http://www.linuxfocus.org/English/Janua … e186.shtml)
"The interesting thing about of the serial interface is that it has a number of pins which you can control via ioctl system calls."

Is this guy wrong ? Or is what you tell me a particularity of routers ?

He is right but he is dealing with a full serial port with control signal lines. The serial port here is only a 3 wire port. All you need to communicate is TX, RX & Gnd.  He is using RI, RTS, CTS which are control signals and you can't do that because those lines are not in most routers.

I'll suggest two "out there" options to get functionality out of the TX line.

Would you be able to use the leading edge of a serial message to toggle a switch. An even number of bits would do nothing as there would be an equal number of on and off pulses. An odd number of bits would change the state. The slower the baud rate the better.

Perhaps with a small capacitor you could average the voltage and distinguish between all ones and all zeros. Faster baud rates might be better here. Recall that serial messages always start with a start bit and end with the stop bit. 
http://en.wikipedia.org/wiki/Asynchrono … munication.
http://www.lvr.com/serport.htm

(Last edited by strider22 on 22 Nov 2006, 07:04)

Many thanks

pod wrote:

My goal is to multiply the points that I can control (I already use the gpio points).

You can use two gpio points to run an I2C bus. You can address many I/O expanders from this bus and light dozens or hundreds of LEDs. Depending on what you were already doing with those gpio points, you could likely reassign them to I2C I/O expander pins.

Here is some info on I2C on a WGT634U: http://openwrt.pbwiki.com/I2C . Something very similar should work on your WRT54GL but my experience is only with the WGT634U.

What a great idea !
But I begun to use a 4028 BCD to Decimal converter as a 4 to 10 multiplexer. so it's a bit late for me.
But thank you for the advice

The discussion might have continued from here.