host/stream_comm.c
/** Function used to receive the packet header and process it.
  * \return Message ID (i.e. command type) of packet.
  */
Function used to receive the packet header and process it.
\return Message ID  of packet.
Function used to receive the packet header and process it . \ return Message ID of packet .
static uint16_t receivePacketHeader(void)
{
	uint8_t buffer[4];
	uint16_t message_id;
	getBytesFromStream(buffer, 2);
	if ((buffer[0] != '#') || (buffer[1] != '#'))
		fatalError(); 
	getBytesFromStream(buffer, 2);
	message_id = (uint16_t)(((uint16_t)buffer[0] << 8) | ((uint16_t)buffer[1]));
	getBytesFromStream(buffer, 4);
	payload_length = readU32BigEndian(buffer);
	main_input_stream.bytes_left = payload_length;
	return message_id;
}
static uint16_t receivePacketHeader ( void ) { uint8_t buffer [ 4 ] ; uint16_t message_id ; getBytesFromStream ( buffer , 2 ) ; if ( ( buffer [ 0 ] != ' ' ) || ( buffer [ 1 ] != ' ' ) ) fatalError ( ) ; getBytesFromStream ( buffer , 2 ) ; message_id = ( uint16_t ) ( ( ( uint16_t ) buffer [ 0 ] << 8 ) | ( ( uint16_t ) buffer [ 1 ] ) ) ; getBytesFromStream ( buffer , 4 ) ; payload_length = readU32BigEndian ( buffer ) ; main_input_stream . bytes_left = payload_length ; return message_id ; }
Function used to receive the packet header and process it.
Function used to receive the packet header and process it .
/* invalid header */ /* TODO: size_t not generally uint32_t */ /* TODO: necessary a timer or not? */