Serial Receives Unintended Data "0xFD"- Hardware Interface
Setup:
- usb to rs485 half duplex transceiver/adapter.
- Microcontroller through rs485 transceiver.
- linux 18.04
- libserial (from source)
- Ros Melodic
When receiving Data on the PC end, I get lots of 0xFD. Only very seldom do I get to read just the message, which is correct and not corrupted itself, but most times lead on by many 0xFDs. I sent commands to the mc to be answered. The timing is not yet fully worked out, might this characters be a linux intern "nothing received" or "message sent" feedback that Iam not aware of? Does anybody have a clue what does 0xFD Data mean, and why it ends up in the serial input buffer? Is it a kind of controlcharacter? Even if the microcontroller is switched of the Read function receives this bytes/characters. They vary in number though. Something wrong with the Termios? Iam using libserial build from source. Any help would be appreciated.
Asked by Dragonslayer on 2019-09-18 06:55:09 UTC
Answers
Embarrassing, but it was the baudrate, at least in parts. Still get this data with nothing attached to the usb/rs485 transceiver, but when everything is online, it works. Just one more case of using quality components with serious documentation would have saved a lot of annoyance. 1Mbaud did the trick, 2Mbaud was to much for the wit-motion.com
"quality" product, with love from china. Extra bought the most expensive one, what a waste.
Asked by Dragonslayer on 2019-09-18 13:04:50 UTC
Comments
Good to hear you figured it out.
Still get this data with nothing attached to the usb/rs485 transceiver
that could be a configuration issue: RS485 can be configured to mirror all bytes written to the read buffers.
Asked by gvdhoorn on 2019-09-18 13:08:47 UTC
Comments
This SO post seems similar.
Asked by gvdhoorn on 2019-09-18 07:17:18 UTC
Thanks gvdhoorn, but Iam receiving the correct messages just additional 0xfd´s. To force it to work I can do a .ReadByte loop until I find the message ID(begin) and siff through the "garbage" but thats not a nice solution. Something like that is very likely to come back and bite me I think :)
Asked by Dragonslayer on 2019-09-18 07:34:31 UTC
Serial connections are a really "low" (or close-to-the-metal) type of transport. Anything fishy with the electro-mechanical interfaces, baud-rates or communication parameters will often immediately show up in data you read from the port.
Have you made sure all of that is OK? Do other libraries / ways of reading from/writing to the port work correctly? Is the problem only with
libserial
(is it actually wiki/serial)?If other libraries/tools also cannot use your RS485 port successfully, then that would be something to fix first.
Asked by gvdhoorn on 2019-09-18 07:39:26 UTC
Thanks again. No Iam using link text this library. Thanks for the advise. I can use the serial port sucessfully, besides the additional "garbage data". And it doesnt intermingle with the data packages, so I think it all does what it should just that it does something Iam not aware of as well. But what, is the question?
Asked by Dragonslayer on 2019-09-18 07:51:18 UTC
Then this does not appear to be a ROS question, but a more general "why am I seeing this behaviour from my RS485 port in combination with this library?". With more than 45000 questions here on ROS Answers, we must stay on-topic as much as possible.
I would recommend you post this question on a forum more appropriate for this type of topic.
if you do post somewhere else, it'd be appreciated if you could comment here with a link to your new post, so we can keep things connected.
Asked by gvdhoorn on 2019-09-18 08:00:07 UTC
OK, I thought I start here because to me it seems to be not really a bug or failure (unknown data has structure and consistancy), but more of a settings issue. Which likely could have been encountered or be known by others doing serial HW interfacing for ROS. Is your linked serial library somehow specialy for ROS?
Asked by Dragonslayer on 2019-09-18 08:14:37 UTC
No, but it is a ROS package. If the problem was with that specifically, that would make the question somewhat on-topic.
Asked by gvdhoorn on 2019-09-18 08:17:43 UTC