docs: def to_bytes(self):
          r'''
          Create bytes from properties
  
          >>> message = DataPacket(nonce='XyZ', instance_id=1234,
          ...                      payload='SomeDummyPayloadData')
          >>> message.to_bytes()
          '\x88XyZ\x00\x04\xd2\x00SomeDummyPayloadData'
          '''
          # Verify that properties make sense
          self.sanitize()
  
          # Set the flags in the first 8 bits
          bitstream = BitArray('bool=%d, bool=%d, bool=%d, bool=%d, bool=%d'
                               % (self.nonce is not None,
                                  self.lsb is not None,
                                  self.echo_nonce_request,
                                  (self.source_map_version is not None or
                                   self.destination_map_version is not None),
                                  self.instance_id is not None))
  
          # Add padding
          bitstream += BitArray(3)
  
          # Add the 24 bit nonce or the map-versions if present
          if self.nonce is not None:
              # Nonce
              bitstream += BitArray(bytes=self.nonce)
          elif self.source_map_version is not None \
          or self.destination_map_version is not None:
              # Map versions
              bitstream += BitArray(('uint:12=%d, uint:12=%d')
                                    % (self.source_map_version,
                                       self.destination_map_version))
          else:
              # Padding
              bitstream += BitArray(24)
  
          # Add instance-id if present
          if self.instance_id is not None:
              bitstream += BitArray('uint:24=%d' % self.instance_id)
              lsb_bits = 8
          else:
              lsb_bits = 32
  
          # Add LSBs if present
          if self.lsb is not None:
              flags = map(lambda f: f and 'bool=1' or 'bool=0',
                          self.lsb[::-1])
              bitstream += BitArray(','.join(flags))
          else:
              bitstream += BitArray(lsb_bits)
  
          return bitstream.bytes + bytes(self.payload)