TX2 serial problem

When i use Tx2 serial1(ttyHS1), there is no problem when i send information, but when i try to receive information form other device, the data completely wrong. (the serial code is full tested in my intel ubuntu PC).
Can anybody share your serial code for tx2? Thanks

I can’t answer, but most of the time when data is wrong it is because both sides are not set to the same speed.

thank you for your answer, the baud speed of both side is 115200.


In addition to speed, consider configurations like ‘parity’, ‘stop bit’ and ‘flow control’

the data completely wrong. (the serial code is full tested in my intel ubuntu PC).
Can you elaborate what this means? I interpret this as, you’re receiving data, but it’s not the data you expect (i.e. scrambled ASCII text).

That’s a good point…if one side is expecting different stop bits, then you might have an off by 1 bit issue (I’ve never tried to purposely set the two ends differently, but it illustrates that there are more settings than speed).

I suppose display of characters can also be an issue…if you are looking at actual bytes this can’t be a problem, but if you are viewing characters in one computer as 8-bit ASCII (or UTF-8), then using a different LOCALE and character set at the other side could also make correct bytes appear as scrambled as it maps the wrong character set.

Thanks you for your reply, I will check the stop bit, it is a good point (And I view the data by Hexadecimal)

Meanwhile, i wll use cutecom to ensure my hardware working fine, maybe I just use a faulty hardware

Hardware for this usually completely fails when hardware is at fault, or it works if hardware is not at fault. There is one exception…the cabling being used. Is this shielded and twisted pair? How long is it?

I have check the cable, and i don’t use shielded wire, the length of cable is around 15cm. I will check again, thanks!

Also, when you say that “the data is wrong,” it would be useful to see a few lines of hex dump of what you’re sending, and what you’re receiving. There are many ways that data can be wrong.

In general, it’s safe for the sender to have more stop bits than the receiver (in fact, this is often more robust) but not vice versa.

For your short cable length at least make it twisted pair…hand twisting will help. Better yet, if you have some ethernet cable, this is very high quality and you could use any of the pairs inside which are twisted.

My problem solved when I change sender stop bit to 2 bit, and receiver (TX2) change too, the receive data of TX2 correct. Thanks you all guys!