cancel
Showing results for 
Search instead for 
Did you mean: 

(Solved) Can't transfer specific byte sequence over VCP

iforce2d
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions
iforce2d
Associate III

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 );

View solution in original post

6 REPLIES 6

19 = 0x13 is XOFF. You have set software handshake at some layer in Linux...

JW

Ozone
Lead II

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/

iforce2d
Associate III

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 );

Ons KOOLI
Senior III

Hi,

Can you please mark this question as solved ?

Best Regards,

Ons.

I thought I already did (changed the title).

Is there some other way to mark it that I should use?

Hi,

It is marked as solved now after you selected the answer as best.

Thank you,

Ons.