docs: def to_bytes(self):
          r'''
          Create bytes from properties
  
          >>> message = EncapsulatedControlMessage(payload='Dummy')
          >>> message.to_bytes()
          '\x80\x00\x00\x00Dummy'
          '''
          # Verify that properties make sense
          self.sanitize()
  
          # Start with the type
          bitstream = BitArray('uint:4=%d' % self.message_type)
  
          # Add the flags
          bitstream += BitArray('bool=%d, bool=%d' % (self.security,
                                                      self.ddt_originated))
  
          # Add padding
          bitstream += self._reserved1
  
          # Determine payload
          payload = self.payload
          if hasattr(payload, 'to_bytes'):
              payload = payload.to_bytes()
  
          return bitstream.bytes + payload