Skip to content Skip to sidebar Skip to footer

Reverse Bit Order Python? Esc/pos Dle Eot Printer Status Escpos

I am having issues decoding DLE EOT 1 im thinking its the bit order and the lack of leading zeros import serial x = 1 while x: time.sleep(3) ser.write('\x10\x04\x01'.encode()

Solution 1:

 print(bin(data[0])[2:].zfill(8)[::-1])

this will add leading zeros and reverse the bits. The result: status online:

                            /---------Bit 3
00010110  -> reversed =  01101000
0xx1xx10b -> reversed = b01xx1xx0
                            ^---------Bit 3

Post a Comment for "Reverse Bit Order Python? Esc/pos Dle Eot Printer Status Escpos"