code: func Decode(data []byte) (length int, msg *Message, err error) {
  	// SOF	0x01	1	Start Of Frame
  	// ACK	0x06	6	Message Ack
  	// NAK	0x15	21	Message NAK
  	// CAN	0x18	24	Cancel - Resend request
  
  	switch data[0] {
  	case 0x01: // SOF
  		if len(data) < 2 {
  			return 2, nil, nil
  		}
  		length := int(data[1])
  		if len(data) < length+2 { // Make shure we have the full message
  			return length + 2, nil, nil
  		}
  
  		checksum := data[length+1]
  		checksumData := append(data[1:length+1], byte(0x00))
  		if checksum != GenerateChecksum(checksumData) {
  			return -1, nil, fmt.Errorf("Invalid checksum, is 0x%x should be 0x%x, (len=%d)", checksum, GenerateChecksum(checksumData), length)
  		}
  
  		msg, err := NewMessage(data)
  
  		return length + 2, msg, err
  	case 0x06, 0x15, 0x18: // ACK, NAC, CAN
  		msg, err := NewMessage(data)
  		if err != nil {
  			logrus.Error(err)
  		}
  
  		return 1, msg, nil
  	}
  	return -1, nil, nil // Not a valid start char
  }
docs: // Decode decodes serialapi raw data