More investigation. Its definitely \r\n that causes this, or specifically 
the hexadecimal 0d 0a. Whenever this is received in this combination the 
ParseFromString falls over. Any ideas? I've got no print statements in the 
C that is sending this binary over USB, and these are received mid message, 
I suspect due to the line-up of bytes.

On Thursday, 7 October 2021 at 21:06:40 UTC+1 Matthew Walker wrote:

> Hi all,
>
> Trying to push data via USB serial onto python application. Fails 
> intermittently seemingly only ever due to the \r\n combination found within 
> the received bytes (shown below).
> Any ideas whats going on here?
>
> [image: Screenshot from 2021-10-07 21-01-16.png][image: Screenshot from 
> 2021-10-07 21-03-33.png]
> Code snippet from application:
>             len_ = ser.read_until(size = 2)
>             # Unpack as uint16 with big endianness
>             bytes_to_read = struct.unpack('>H',len_)[0]
>             print("PB bytes incoming: {}".format(bytes_to_read))
>             message = bytearray(ser.read(size=bytes_to_read))
>             print(message)
>             print(message.hex(' '))
>             print(len(message))
>             try:
>                 telemetry.ParseFromString(message)
>             except:
>                  print("Bad decode!")
>
> Cheers,
> Matt.                   
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/d944917e-1ac9-41d7-ba5a-d10135c48357n%40googlegroups.com.

Reply via email to