in over my head ascii

Terry Reedy tjreedy at udel.edu
Mon Feb 6 13:40:17 EST 2006


<nephish at xit.net> wrote in message 
news:1139245216.350356.272170 at z14g2000cwz.googlegroups.com...
> for example , to send a request, the first three bytes have to be ascii
> "STX"
> then there has to be  4 bytes that show the length of the message
> then the actual message
> then the last three bytes have to be "ENX"
>
> also all int variables must me unsigned long-int (32 bit).
>
> so here is what i need to know,
> 1 how do i make something in ascii bytes to send off to this server ?

Python strings are full 8-bit byte strings.  Whether you should retrict 
bytes to ASCII bytes only depends on the situation.  According to what you 
said above, the server wants the number in binary rather than as ascii 
digits.

Other than that, send "STX", the number, your message, and "ENX"

> 2 how can i make sure something is a 32bit unsigned long int. ?

Look at the struct and/or array modules.  I suspect that you may have to 
pay attention to whether the server want the binary in big or little endian 
format.

Terry Jan Reedy






More information about the Python-list mailing list