reading/writing to serial port doesn't work
Hi. I use Ubuntu 16.04. In the first terminal I wait for data:
Code:
cat </dev/ttyS0 Code:
echo -e '123' > /dev/ttyS0 Additional info: dmesg | grep ttyS Code:
[ 0.684920] 00:06: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A Code:
speed 9600 baud; rows 0; columns 0; line = 0; Code:
enp0s25 Link encap:Ethernet HWaddr d0:50:99:5e:47:a7 |
Welcome to LinuxQuestions.
You need a physical loopback plug attached to the serial port connector to see data. Here is a pin out of the plug wiring. http://www.bb-elec.com/Learning-Cent...-DB9-DB25.aspx It is also easier to use a terminal program like minicom to test the serial port. With a loopback plug the characters are displayed as soon as they are typed on the keyboard. |
Is it possible to buy such connector ? My PC has a female com port so I need a male connector.
|
Since the IBM standard uses a male connector I think it would be difficult to find a male loopback to purchase. You probably need to purchase a female connect and a gender changer.
It depends on what you are actually trying to accomplish. If you disable hardware control you can jumper pins 2-3 to see characters as they are typed. |
Gender changer is easy to get, I have also found the following connector. Is it what I need ?
What do you mean by "disable hardware control"? Could you explain it ? |
probably this helps: http://tldp.org/HOWTO/Serial-HOWTO-9.html
I think that is the right connector, but you can find an interesting comment there (probably a damaged one only) |
Yes, however one of the comments shows this particular model using a strange wiring layout out which may be ok.
The RS-232 uses several wires to control data flow over the data pins. Since suggested just using a jumper to connect the RX to TX pins you need to disable hardware flow control since those pins are unused and you will be able to transmit data. https://en.wikipedia.org/wiki/RS-232 |
I have performed another test: I have connected to my pc usb to serial adapter which is connected with mentioned above loopback connector. Instead of ttyS0 I use ttyUSB0. It works but when I send some message:
Code:
echo -e '123' > /dev/ttyUSB0 Code:
cat </dev/ttyUSBO |
Yes it should work in theory.
How are you reading/writing to the serial port. Have you given permission to your regular user to read/write to the USB adapter which is typically /dev/ttyUSB0? |
Please see my answer update. I have forgotten to use ttyUSB0 instead of ttyS0
|
using echo and cat in the terminal is not very reliable for testing serial ports in my opinion. As suggested earlier use minicom. You need to configure the serial port but it will show characters as they are typed.
|
minicom with echo works fine.
|
All times are GMT -5. The time now is 05:29 AM. |