bool RunRadarDataList() {
	const int c_PerComDataSize = 1024;
	unsigned char com_data[1024];
	int act_com_size;
	bool ok_com;
	char config_path[255];
	int port_num;
	int baud_rate;

	GetConfigPath(config_path, sizeof(config_path));
	GetPortNumOfSerialInterface(config_path, &port_num);
	GetBaudRateOfSerialInterface(config_path, &baud_rate);
	ok_com = OpenComport(port_num, baud_rate);
	if (false == ok_com) {
		LOG("OpenComport() error!\n");
		return false;
	}
	else {
		while (true) {
			act_com_size = ReadComport(com_data, c_PerComDataSize);
			if (0 == act_com_size)
				continue;
			else
				AnalyseComData(com_data, act_com_size);
		}
		CloseComport();
		return true;
	}
}
Exemple #2
0
void COil::P_ThreadRecv()
{
	char szReadBuf[2048] = {0};
	int  iBufLen = sizeof(szReadBuf);
	char szFrame[2048] = {0};
	int  iReadLen = 0;
	int  i = 0;

	while(!g_bProgExit)
	{
		iReadLen = read(m_iComPort, szReadBuf, iBufLen);
		
		if(iReadLen > iBufLen)
		{
			PRTMSG(MSG_ERR,"Com Read Over Buf!\n");
			memset(szReadBuf, 0, sizeof(szReadBuf));
			iReadLen = 0;
			
			continue;
		}		
		
		if( iReadLen > 0 )
		{
   			//PRTMSG(MSG_DBG, "COil recv data: ");
   			//PrintString(szReadBuf, iReadLen);

			AnalyseComData(szReadBuf, iReadLen);
		}
	}
}