Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python Serial port access

Status
Not open for further replies.

markwalker84

Programmer
Jul 18, 2006
6
GB
Hi!

Im really struggling here...

Im trying to communicate with a piece of hardware that accepts a specific package format for control.

I need to be able to send an 8 bit data word via a serial connection from my Python program.

I have been using USPP & PySerial so far but have found a problem. Both those modules rely on file-style operation... writing strings etc. So so far i have been converting my 8bits of data to the relevant ASCII character and writing that to the port.

The problem occurs when i need to send a packet that has a value of less than 0x20... as from this point the relevant character is no longer printable (carriage return, tab etc) and so it cant be written as such.

Does anybody know of a way to send raw data in binary form to the serial port?


Many thanks,


Mark

 
Why does the character have to be printable? You can still store it in a string, right?

Code:
>>> chr(3)
'\x03'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top