I have done a fair bit of searching and reading around but haven't found an exact clear answer. I am making python application which will communicate with another over the serial port. I have been using PySerial to accomplish this. The types of packets I want to send are status information and data readings.
I am proposing to form of my packets as follows:

```
[ Start Byte ][ Length ][ Message ][ End Byte ][ Checksum ]

```

Although I don't think I need the end byte since have a length in there. Am I correct?

I am thinking of shaping the 'Message' part of the packet for status info like so:

```
[ MsgTypeID ][ PacketID ][ Status Bits ][ Timestamp ]

```

The message ID here is just to differentiate that this is a status packet rather than a data packet. The status information itself is made up of 16 bits, representing the state of a number of subsystems in the sending application. For some of these subsystems, a single bit will provide enough info ('0' to say the subsystem is off/low/false, '1' for on/high/true). Others will require 2 or 3 bits (representing states and such). Prototyping the system up, I have been simply constructing a string concatenating the bits up to form a something like `'1001110101101100'` and sending this out the serial port, with the checksum being a modulo 256 of the status bits.

I am pretty new to Python and serial communication but I know this is probably a waste of bandwidth. I know that PySerial has to send strings but representing each bit as a '0' or '1' like this is using a full string representation for each bit. I was wondering what is the best way to send these bits to reduce the bandwidth?

For example, would I take each 8 bits, convert them to hex and send concatenated hex bytes, as in:

```
'10011101' + '01101100'

```

represented as

```
'\x9d' + '\x6c'

```

or should I send them as ASCII? I've also seen mentions of the Struct module. Should I be going down that route instead?

The other thing I am wondering is how to represent the timestamp parts of the message.

Any help, suggestions you can give me would be greatly appreciated.

Thanks very much :)