Thursday 15 September 2011

unicode - Reading a file in python 3.x as Bytes/Strings for PySerial/Xmodem -


I am trying to read a binary file in a buffer and then transmit it using pyserial / xmodem .

My test code:

  send_buf = open ('test.py', 'rb') xmInst = XMODEM (self.getc, self.putc) xmInst.send (Send_buf)  

send xmodem code:

  ... data = stream.read (packet_size) data if not: break / total_packets + = 1 data = Data.ljust (packet_size, self.pad)  

However, when it executes the last line, then it should be 'a byte string of length 1, not a strap'. Probably a byte / string / unicode problem?

The xmodem package was written for Python 2.7, so how can I read / pass files in Python 3.4, such as xmodem can work with it?


No comments:

Post a Comment