Beispiel #1
0
void rpcMessage::Send(CRpcIo &rpc_io)
{
	rpc_io.Write(&m_type, 1);
	rpc_io.Write(&m_cmd,  2);
	rpc_io.Write(&m_size, 1);
	if (m_size) rpc_io.Write(m_par, m_size);
}
Beispiel #2
0
void rpc_SendRaw(CRpcIo &rpc_io, const void *x, uint32_t size)
{
	uint8_t value = RPC_TYPE_DTB_DATA;
	rpc_io.Write(&value, 1);
	rpc_io.Write(&size, 3);
	if (size) rpc_io.Write(x, size);
//	printf("Send Data [%i]\n", int(size));
}
Beispiel #3
0
void rpc_DataSink( CRpcIo & rpc_io, uint32_t size )
{
  if( size == 0 )
    return;
  CBuffer buffer( size );
  rpc_io.Read( &buffer, size );
}
Beispiel #4
0
void rpcMessage::Receive(CRpcIo &rpc_io)
{
	m_pos = 0;
	rpc_io.Read(&m_type, 1);
	if (m_type == RPC_TYPE_DTB) {}
	else if (m_type == RPC_TYPE_DTB_DATA)
	{ // remove unexpected data message from queue
		uint16_t size = 0;
		rpc_io.Read(&size, 3);
		rpc_DataSink(rpc_io, size);
		throw CRpcError(CRpcError::NO_CMD_MSG);
	}
	else if (m_type == RPC_TYPE_DTB_DATA_OLD)
	{ // remove unexpected old data message from queue
		uint8_t  chn;
		uint16_t size;
		rpc_io.Read(&chn, 1);
		rpc_io.Read(&size, 2);
		rpc_DataSink(rpc_io, size);
		throw CRpcError(CRpcError::NO_CMD_MSG);
	}
	else throw CRpcError(CRpcError::WRONG_MSG_TYPE);

	rpc_io.Read(&m_cmd, 2);
	rpc_io.Read(&m_size, 1);
	if (m_size) rpc_io.Read(m_par, m_size);
}
Beispiel #5
0
void CDataHeader::RecvHeader(CRpcIo &rpc_io)
{
	rpc_io.Read(&m_type, 1);
	if (m_type == RPC_TYPE_DTB_DATA) {}
	else if (m_type == RPC_TYPE_DTB)
	{ // remove unexpected command message from queue
		uint16_t cmd;
		uint8_t size;
		rpc_io.Read(&cmd, 2);
		rpc_io.Read(&size, 1);
		rpc_DataSink(rpc_io, size);
		throw CRpcError(CRpcError::NO_DATA_MSG);
	}
	else if (m_type == RPC_TYPE_DTB_DATA_OLD)
	{ // remove unexpected old data message from queue
		uint8_t  chn;
		uint16_t size;
		rpc_io.Read(&chn, 1);
		rpc_io.Read(&size, 2);
		rpc_DataSink(rpc_io, size);
		throw CRpcError(CRpcError::NO_CMD_MSG);
	}
	else throw CRpcError(CRpcError::WRONG_MSG_TYPE);

	m_size = 0;
	rpc_io.Read(&m_size, 3);
}
Beispiel #6
0
void rpc_Receive(CRpcIo &rpc_io, string &x)
{
	CDataHeader msg;
	msg.RecvHeader(rpc_io);
	x.clear();
	x.reserve(msg.m_size);
	char ch;
	for (uint32_t i=0; i<msg.m_size; i++)
	{
		rpc_io.Read(&ch, 1);
		x.push_back(ch);
	}
}
Beispiel #7
0
void rpc_Receive( CRpcIo & rpc_io, string & x )
{
  CDataHeader msg;
  msg.RecvHeader( rpc_io );
  x.clear(  );
  x.reserve( msg.m_size );
 //std::cout << "rpc_Receive " << msg.m_size << " bytes" << std::endl;
  char ch;
  for( uint32_t i = 0; i < msg.m_size; i++ ) {
    rpc_io.Read( &ch, 1 ); // usb.cpp Read
    x.push_back( ch );
  }
}