2020-12-10 03:56 AM
So far I have been using VCP in my project for about six months with no problems. But today I found it was not able to send a specific 'packet' of bytes.
Here is the SWV printf output from STM32CubeIDE:
Sending 10 bytes
255
254
5
0
19
0
0
0
24
106
Note the 19, which is the actual main content of the message. The first two bytes are a message header, last two bytes are a checksum.
Now here's what I receive on the computer (Fedora Linux, libserialport)
Read 9 bytes
255
254
5
0
0
0
0
24
106
The 19 is missing. If I change it to 18 or 20 there is no problem, and I cannot find any other numbers which cause a problem, only 19. This is 100% repeatable, not an occasional problem.
I am sending using CDC_Transmit_FS which returns 0 (USBD_OK).
On the computer I'm using sp_nonblocking_read, which returns 9.
Docs for the libserialport function:
https://www.sigrok.org/api/libserialport/0.1.0/a00008.html#gad7fdeeacdef532f44185cc68e166d46b
Any tips for how to investigate this further? If it was a regular serial connection I could use my logic analyzer to look at the tx/rx wires directly, but is that possible with VCP?
Solved! Go to Solution.
2020-12-10 04:40 AM
Thanks for the fast (and correct!) replies.
For those using libserialport, here is how this problem can be avoided:
sp_port_config* config;
sp_new_config( &config );
sp_get_config( port, config );
sp_set_config_xon_xoff( config, SP_XONXOFF_DISABLED );
sp_set_config( port, config );
2020-12-10 04:20 AM
19 = 0x13 is XOFF. You have set software handshake at some layer in Linux...
JW
2020-12-10 04:27 AM
Unix/Linux terminals open by default in a terminal emulation mode, that interprets control characters and escape sequences.
You need to switch it to "raw" to get all characters.
Either use a teminal application that supports a raw mode, or modify the tty attributes in your own app, like here for example:https://forum.allaboutcircuits.com/threads/serial-port-terminal-raw-mode-in-c.169317/
2020-12-10 04:40 AM
Thanks for the fast (and correct!) replies.
For those using libserialport, here is how this problem can be avoided:
sp_port_config* config;
sp_new_config( &config );
sp_get_config( port, config );
sp_set_config_xon_xoff( config, SP_XONXOFF_DISABLED );
sp_set_config( port, config );
2020-12-10 04:56 AM
Hi,
Can you please mark this question as solved ?
Best Regards,
Ons.
2020-12-10 01:39 PM
I thought I already did (changed the title).
Is there some other way to mark it that I should use?
2020-12-14 08:52 AM
Hi,
It is marked as solved now after you selected the answer as best.
Thank you,
Ons.