prob with struct and byte order

John Machin sjmachin at lexicon.net
Mon Jul 24 20:36:47 EDT 2006


nephish at xit.net wrote:
> ok. indeed i did do '' instead of ' '.
> here is an example of a message
> 'STX\x00\x00\x004\x00\x00\x00\xc8stateman\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00state1man\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00ENX'
>
> tohex gave me '53 54 58 00 00 00 34 00 00 00 c8 70 69 76 6f 74 72 61 63
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 74 72 61 63 31 70 69 76
> 6f 74 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 4e 58'

It may well have given you that, but *NOT* from the 'STXetcetc' string
you quote above.

>
> this is the login message (message type 200)

Perhaps you might consider giving examples of some other message
type(s) e.g. ones that have more data and less possibly sensitive info
than what are presumably usernames and passwords.

>
> i will try out your code sample when i get to work in the morning.

Do you actually have documentation of the individual fields in each
message type (like what is the maximum length of each of those
NUL-padded text fields in the login message")?
How many different message types are there?
Note that given a reasonably well laid out soft copy of the docs for
each message type, it would be quite within reason to write a fairly
short script to *generate* correct legible runnable Python code ...
it's scarcely a novel concept.

Cheers,
John




More information about the Python-list mailing list