Point BinaryTree::getPoint() { Point ret; ret.x = getU8(); ret.y = getU8(); return ret; }
BinaryTreePtr FileStream::getBinaryTree() { uint8 byte = getU8(); if(byte != BINARYTREE_NODE_START) stdext::throw_exception(stdext::format("failed to read node start (getBinaryTree): %d", byte)); return BinaryTreePtr(new BinaryTree(asFileStream())); }
void itr_container::ByteStream::getU8Array(U8 *buffer, U32 length) { while (length--) { *buffer = getU8(); buffer++; } }
void parseBuffer(void){ unsigned int parsed[6]; rBptr = &returnBuffer[0]; //assign the start of the char buffer parsed[0] = getU16(); //get number of bytes transmited parsed[1] = getU8(); //get frame ID parsed[2] = getU8(); //get ID count parsed[3] = getU8(); //get ID heading = getF32(); //get compass heading parsed[4] = getU8(); //get ID pitch = getF32(); //get pitch parsed[5] = getU8(); //get ID roll = getF32(); //get pitch return; }
BinaryTreePtr FileStream::getBinaryTree() { BinaryTreePtr root = BinaryTreePtr(new BinaryTree); uint8 byte = getU8(); if(byte == BINARYTREE_NODE_START) root->unserialize(asFileStream()); else stdext::throw_exception(stdext::format("failed to read node start (getBinaryTree): %d", byte)); return root; }
bool NetworkMessage::getPosition(Position& p) { uint16_t u16; if(!getU16(u16)){ return false; } p.x = u16; if(!getU16(u16)){ return false; } p.y = u16; uint8_t u8; if(!getU8(u8)){ return false; } p.z = u8; return true; }
void LLAggregatePermissions::packMessage(LLMessageSystem* msg, const char* field) const { msg->addU8Fast(field, getU8()); }
/**************************************************************** SeaNet General Packet Format is; * '@' : Message Header = '@' (0x40). * HHHH : Hex Length of whole binary packet (excluding LF Terminator). * BB : Binary Word of above Hex Length. * SID : Packet Source Identification (Tx Node number 0 - 255). * DID : Packet Destination Identification (Rx Node number 0 -255). * COUNT : Byte Count of attached message that follows this byte. * MSG : Command / Reply Message (i.e. 'Alive' command, 'Data Reply' message). * TERM : Message Terminator = Line Feed (0Ah). * * Returns -1 if failed, 1 if correct first time, 2 if it had to * stich packets * ****************************************************************/ int sortPacket(void) { int packetFlag = 0, leFlag = 0, buffLen, //length of the recieved buffer, output from read_port() i, //counter temp[263], msgLen, binFlag; //How long was the msg, according to read() ? buffLen = read_port(); //printf("buffLen = %d\n", buffLen); rBptr = &returnBuffer[0]; //set pointer for recieved data //Store all packets into temp[] for( i = 0; i < buffLen; i++ ) { leFlag = temp[i]; temp[i] = getU8(); if(i >= 1 && temp[i] == 0x40 && temp[i-1] == 0x0a) { buffLen = i; } } //Store temp stuff into right place header = temp[0]; hLength = getU32(temp[1], temp[2], temp[3], temp[4]); bLength = getU16(temp[6], temp[5]); sID = temp[7]; dID = temp[8]; byteCount = temp[9]; term = temp[buffLen-1]; //Clear msg buffer first for(i = 0; i < 263; i++) msg[i] = NULL; msgLen = 0; //Store the msg, works for varying lengths for( i = 10; i < (buffLen-2); i ++) { msg[(i-10)] = temp[i]; msgLen ++; } //What is prinf? if(header == '@' && term == 10 && buffLen == bLength + 6) { //Prinf the packet //printf("<< "); //for(i = 0; i < buffLen; i ++) // printf("%x : ", temp[i]); //printf("\n"); packetFlag = 1; if(msg[0] == mtHeadData) { // if(byteCount == 0) // printf("Single Packet\n"); // else // printf("Multi Packet\n"); binFlag = 0; //printf("\nBearing: %f\n Bins: ", (float) getU16(temp[41], temp[40]) / 17.775 ); for(i = 44; i < buffLen-1; i++ ) { tempBinArray[i-44] = temp[i]; //printf("%d, ", temp[i]); if(temp[i] >= THRESHOLD && binFlag == 0) { bins = i-44; binFlag = 1; } } //printf("%d\n", bins * 6); bearing = getU16(temp[41], temp[40]); } //printf("%d, %d\n", byteCount, msgLen+1); } else { packetFlag = -1; } return packetFlag; }
bool InputMessage::decryptRsa(int size) { checkRead(size); g_crypt.rsaDecrypt((unsigned char*)m_buffer + m_readPos, size); return (getU8() == 0x00); }
double InputMessage::getDouble() { uint8 precision = getU8(); int32 v = getU32() - INT_MAX; return (v / std::pow((float)10, precision)); }