First of all, I'm very newbie in python, I've readed python documentation and I still don't understand how to that.
So, I need to send that structure: UDP_PAQUET:
unsigned char type
char ext[5]
char data[50]
I tried to do this:
UDP_PKT = pack('BC5C50',"0x00", "2501", "user05")
but I'm getting a:
bad char in stuct format
Could someone help me a little?
Thanks!
First, there's no uppercase C
format specifier in the struct module.
After that, I think that you want to use the s
specifier for the ext
and data
members, and not pass in that first 0x00
value as a string, like:
UDP_PKT = pack('B5s50s', 0x00, "2501", "user05")
(Note that the size/repeat count appears before the format specifier.)
...which generates a packed string like:
'\x002501\x00user05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'