jeudi 16 avril 2015

Formatting a Python String to ASCII

I have a String in Python:



message = "$GPGSA,A,3,31,27,14,09,04,02,12,25,29,,,,2.46,1.24,2.12*06"


I am new to ASCII and reformatting Strings. How would I go about formatting this message such that it meets the following criteria?



The string ends with a carriage return and line feed combination (Hex 0D 0A, ASCII ‘\r\n’)



and



The data sent is all in printable ASCII form (data bit 7 is always zero, and all characters should be between ASCII HEX 20 and HEX 7E) For example "$" (0x24).



I have seen several examples regarding converting single characters to ASCII hex, but not of this scale.


Aucun commentaire:

Enregistrer un commentaire