00001 package com.github.c77.base_driver.husky; 00002 00003 import org.apache.commons.codec.binary.Hex; 00004 00008 public class HuskyPacket { 00009 public static final char TYPE_ENCODER_DATA = (char)0x8800; 00010 public static final char TYPE_ENCODER_DATA_RAW = (char)0x8801; 00011 00012 byte soh; 00013 byte length; 00014 byte lengthComplement; 00015 byte version; 00016 int timestamp; 00017 byte flags; 00018 char messageType; 00019 byte stx; 00020 byte[] payload; 00021 char checksum; 00022 00023 public byte getLength() { 00024 return length; 00025 } 00026 00027 public int getTimestamp() { 00028 return timestamp; 00029 } 00030 00031 public byte getFlags() { 00032 return flags; 00033 } 00034 00035 public byte[] getPayload() { 00036 return payload; 00037 } 00038 00039 public char getMessageType() { 00040 return messageType; 00041 } 00042 00043 public byte getVersion() { 00044 return version; 00045 } 00046 00047 @Override 00048 public String toString() { 00049 return "HuskyPacket{" + 00050 Integer.toHexString(messageType) + ":" + 00051 new String(Hex.encodeHex(payload)) + 00052 '}'; 00053 } 00054 }