How to deal with binary data between Python and Arduino

This PyQt code sends to Arduino payload binary information prepended by two bytes. 1st byte is function mode and 2nd byte is payload length. This code is able to receive binary information, to add CRC at the end or request a CRC calculation from Arduino.

How to run in Linux (it has been tested on Debian Jessie):

$ ./ /dev/ttyUSB0 9600

How to run in Windows (it has not been tested):

>  python \\.\COM1 9600

pyQt screenshot

PyQt and Arduino code