Skip to content
Snippets Groups Projects
Commit 6e82c1e2 authored by Zach Eisele's avatar Zach Eisele
Browse files

fix decoding packet

parent f8aae1c4
No related branches found
No related tags found
3 merge requests!76lots of gui updates,!75Lost of gui updates,!74lots of gui updates among others
......@@ -267,11 +267,11 @@ size_t getSinglePacket(int fd, uint8_t * packet, int pSize){
//Get to data size bytes to find out total packet size
while(curLoc<6){
curLoc += recv(fd, packet,6,MSG_WAITALL);
curLoc += recv(fd, packet,7,MSG_WAITALL);
}
//get the total packet size
totalPacketSize = packetSize(*(packet+4)<<8 | (*(packet +5)));
totalPacketSize = packetSize(*(packet+5)<<8 | (*(packet +6)));
printf("\t\ttotal packet size %d\n",totalPacketSize);
//check that the total packet size isnt unreasonable TODO is this a valid check?
......
......@@ -20,7 +20,7 @@ ssize_t EncodePacket(
packet[BEGIN] = BEGIN_CHAR;
packet[MTYPE_L] = LSByte16(m->msg_type);
packet[MTYPE_H] = MSByte16(m->msg_type);
memcpy(packet[ID_L], m->msg_id, 2);
memcpy(&packet[ID_L], &m->msg_id, 2);
packet[DLEN_L] = LSByte16(m->data_len);
packet[DLEN_H] = MSByte16(m->data_len);
memcpy(&packet[HDR_SIZE], data, m->data_len);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment