Skip to main content
ABask.1
Associate II
Nov 19, 2022 5:42 PM UTC
Solved

Why USB Virtual Com Device miss Empty Byte?

I have created project USB Virtual Com Device on STM 32F407. I set size of parcel = 32 byte. When i send parcel and befor parcel ends byte will be "0" STM 32 don't read bytes after "0". If no "0" byte always is OK. What doe's it mean? How get full parcel with "0" bytes inside parcel?

0693W00000WItotQAD.png 

0693W00000WItp3QAD.png

This topic has been closed for replies.
Pavel A.
Pavel A.Best answer
Nov 20, 2022 3:43 PM UTC

On your screenshot, line 285: is this a strncpy?

Do not use string functions on raw (binary) data.

6 replies

AScha.3
Super User
Nov 20, 2022 8:51 AM UTC

 "0" is "end of string" sign in C.

so if data is a string of characters, NULL is signal for end of string ( and transmission).

If you feel a post has answered your question, please click on " Best Answer ".
ABask.1
ABask.1Author
Associate II
Nov 20, 2022 2:29 PM UTC

That is, it turns out that I cannot send the DEC array = {1, 10, 0, 0, 0, 75, 255, 117 , 256, 128}.

Will I have to reformat the array to a char? So this will increase the size of my package. How then to define "0"?

ABask.1
ABask.1Author
Associate II
Nov 20, 2022 2:02 PM UTC

That is, it turns out that I cannot send the DEC array = {1, 10, 0, 0, 0, 75, 255, 117 , 256, 128}.

Will I have to reformat the array to a char? So this will increase the size of my package. How then to define "0"?

AScha.3
Super User
Nov 20, 2022 3:36 PM UTC

why not send data as ascii ? so 0x0 -> 0x30 ;

If you feel a post has answered your question, please click on " Best Answer ".
Pavel A.
Pavel A.Best answer
Nov 20, 2022 3:43 PM UTC

On your screenshot, line 285: is this a strncpy?

Do not use string functions on raw (binary) data.

ABask.1
ABask.1Author
Associate II
Nov 21, 2022 10:01 AM UTC

memcpy solved the problem, thanks a lot