7 #ifndef __ChrSerialPacket_h 8 #define __ChrSerialPacket_h 35 m_PacketDescriptor=packetDescriptor;
40 if( m_PacketDescriptor & 0x40 )
50 m_PacketDescriptor |= 0x40;
54 m_PacketDescriptor |= 0x40;
55 m_PacketDescriptor ^= 0x40;
61 if( m_PacketDescriptor & 0x80 )
71 m_PacketDescriptor |= 0x80;
75 m_PacketDescriptor |= 0x80;
76 m_PacketDescriptor ^= 0x80;
82 return (m_PacketDescriptor >> 2) & 0x0F;
89 m_PacketDescriptor |= (0x0F << 2);
90 m_PacketDescriptor ^= (0x0F << 2);
92 m_PacketDescriptor |= (length << 2);
97 return m_PacketDescriptor & 0x01;
102 m_PacketDescriptor |= 0x01;
103 m_PacketDescriptor ^= 0x01;
104 m_PacketDescriptor |= failed;
146 return m_Data[index];
150 m_Data[index] =
value;
160 case 3:
return m_PacketDescriptor;
161 case 4:
return m_Address;
181 case 0:
return (m_Checksum >> 8);
182 case 1:
return (m_Checksum & 0x0FF);
190 unsigned short int checksum;
194 checksum += (
unsigned char)
's';
195 checksum += (
unsigned char)
'n';
196 checksum += (
unsigned char)
'p';
197 checksum += m_PacketDescriptor;
198 checksum += m_Address;
201 for(
int i = 0;
i < dataLength;
i++ )
203 checksum += m_Data[
i];
206 m_Checksum = checksum;
210 unsigned char m_Address;
211 unsigned char m_PacketDescriptor;
212 unsigned short m_Checksum;
214 std::vector<unsigned char> m_Data;
unsigned char GetDataLength()
unsigned char GetBatchLength()
void SetBatchEnable(bool enable)
void SetHasData(bool has_data)
unsigned char GetChecksumByte(int index)
unsigned char GetPacketByte(int index)
void SetPacketDescriptor(unsigned char packetDescriptor)
void SetAddress(unsigned char address)
unsigned char GetDataByte(int index)
void SetBatchLength(unsigned char length)
unsigned char GetHeaderLength()
void SetDataByte(int index, unsigned char value)
void ComputeChecksum(void)
unsigned char GetHeaderByte(int index)
unsigned char GetPacketLength()
void SetCommandFailed(unsigned char failed)
const char const char * value
unsigned char GetAddress()
unsigned char GetChecksumLength()
unsigned char GetCommandFailed()