|
@@ -78,9 +78,9 @@ void Radio::sendProto(iv::v2r::v2r_send radio_protobuf_send)
|
|
|
strser = new char[nbytesize];
|
|
|
bser = radio_protobuf_send.SerializeToArray(strser,nbytesize);
|
|
|
if(bser) {
|
|
|
- qDebug()<<"[Radio]:ready send protobuffer"<<endl;
|
|
|
+ //qDebug()<<"[Radio]:ready send protobuffer"<<endl;
|
|
|
iv::modulecomm::ModuleSendMsg(mpmem_radio_send_addr,strser,nbytesize);
|
|
|
- qDebug()<<"[Radio]:has sended protobuffer"<<endl;
|
|
|
+ //qDebug()<<"[Radio]:has sended protobuffer"<<endl;
|
|
|
} else {
|
|
|
//mivlog->error("sendData","[%s:] radio serialize error.",__func__);
|
|
|
// gfault->SetFaultState(1, 0, "radio serialize err");
|
|
@@ -100,18 +100,18 @@ void Radio::setGpsImuMemory(gpsImuM m)
|
|
|
|
|
|
void Radio::sendResponseMessage(int type)
|
|
|
{
|
|
|
- m_responseType=type&0xFF;
|
|
|
- upRespondMessageRealtimeTraffic();
|
|
|
+ if(m_bEnTrafficBroadcast) {
|
|
|
+ m_responseType=type&0xFF;
|
|
|
+ upRespondMessageRealtimeTraffic();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
void Radio::outRealtimeTraffic(realtimeTrafficMessage realtimeTraffic)
|
|
|
{
|
|
|
if(m_bEnTrafficBroadcast) {
|
|
|
iv::v2r::v2r_send protobuf;
|
|
|
double lat=((double)realtimeTraffic.lat)/1000000.0;
|
|
|
- double lon=((double)realtimeTraffic.lng)/1000000.0;
|
|
|
- qDebug()<<"[Radio]:real time traffic lat is "<<lat<<". lng is "<<lon
|
|
|
- <<".scope is "<<realtimeTraffic.scope<<".traffic info is "<<realtimeTraffic.trafficInfo
|
|
|
- <<". speed limit is "<<realtimeTraffic.speedLimit<<endl;
|
|
|
+ double lon=((double)realtimeTraffic.lng)/1000000.0;
|
|
|
protobuf.set_radiobroadcastgpslat(lat);
|
|
|
protobuf.set_radiobroadcastgpslon(lon);
|
|
|
protobuf.set_radiobroadcastrange(realtimeTraffic.scope);
|
|
@@ -127,7 +127,7 @@ void Radio::outCollisionWarning(collisionEarlyWarningMessage collisionWarning)
|
|
|
iv::v2r::v2r_send protobuf;
|
|
|
protobuf.set_radiowarningtype(collisionWarning.warningType);
|
|
|
protobuf.set_radiowarningspeedlimit(collisionWarning.speedLimit);
|
|
|
- qDebug()<<"[Radio]:warning type is "<<collisionWarning.warningType<<".speed limit is:"<<collisionWarning.speedLimit<<endl;
|
|
|
+ //qDebug()<<"[Radio]:warning type is "<<collisionWarning.warningType<<".speed limit is:"<<collisionWarning.speedLimit<<endl;
|
|
|
sendProto(protobuf);
|
|
|
}
|
|
|
}
|
|
@@ -137,7 +137,7 @@ void Radio::outCongestionIdenti(congestionIdentificationMessage congestionIdenti
|
|
|
if(m_bEnBusyRoad) {
|
|
|
iv::v2r::v2r_send protobuf;
|
|
|
protobuf.set_radioidentistart(congestionIdenti.openCommand);
|
|
|
- qDebug()<<"[Radio]:congestion identi open command is "<<congestionIdenti.openCommand<<endl;
|
|
|
+ //qDebug()<<"[Radio]:congestion identi open command is "<<congestionIdenti.openCommand<<endl;
|
|
|
sendProto(protobuf);
|
|
|
}
|
|
|
}
|
|
@@ -189,7 +189,7 @@ void Radio::heartBeat()
|
|
|
openSerial();
|
|
|
} else {
|
|
|
decodeData();
|
|
|
- testWarningSpeedLimit();
|
|
|
+ //testWarningSpeedLimit();
|
|
|
upDataStream();
|
|
|
//if no answer,shake hands three times
|
|
|
if(m_iResponse!=-1) {
|
|
@@ -286,14 +286,14 @@ void Radio::upDataStream()
|
|
|
m_serialPort_Radio->write(sendBuf,headLen+dataLen+1);
|
|
|
m_serialPort_Radio->flush();
|
|
|
//m_serialPort_Radio->write("sendBuf");
|
|
|
- qDebug() << "[RADIO]:up vehicle message "<<endl;
|
|
|
+ //qDebug() << "[RADIO]:up vehicle message "<<endl;
|
|
|
}
|
|
|
void Radio::upVirtualVehicle(virtualVehicleM virtualVehicle)
|
|
|
{
|
|
|
m_iVirtualVehicle=0;
|
|
|
m_structMVirtualVehicle=virtualVehicle;
|
|
|
upVirtualVehicleRaw();
|
|
|
- qDebug() << "[RADIO]:up virtual vehicle message "<<endl;
|
|
|
+ //qDebug() << "[RADIO]:up virtual vehicle message "<<endl;
|
|
|
}
|
|
|
void Radio::upVirtualVehicleRaw()
|
|
|
{
|
|
@@ -339,13 +339,13 @@ void Radio::upVirtualVehicleRaw()
|
|
|
}
|
|
|
void Radio::upRespondMessage()
|
|
|
{
|
|
|
- qDebug() << "[RADIO]:up response message "<<endl;
|
|
|
+ //qDebug() << "[RADIO]:up response message "<<endl;
|
|
|
m_iResponse=0;
|
|
|
upRespondMessageRaw(0x02);
|
|
|
}
|
|
|
void Radio::upRespondMessageRealtimeTraffic()
|
|
|
{
|
|
|
- qDebug() << "[RADIO]:up response real time traffic message "<<endl;
|
|
|
+ // qDebug() << "[RADIO]:up response real time traffic message "<<endl;
|
|
|
m_iResponseRealtimeTraffic=0;
|
|
|
upRespondMessageRaw(0x01);
|
|
|
}
|
|
@@ -477,8 +477,8 @@ void Radio::decodeData()
|
|
|
if(m_data.size()>= BATH_LENTH) {
|
|
|
|
|
|
// 防包太大
|
|
|
- if (m_data.size() > 2048) {
|
|
|
- qDebug() << "size too large";
|
|
|
+ if (m_data.size() > 512) {
|
|
|
+ //qDebug() << "size too large";
|
|
|
m_data.clear();
|
|
|
return;
|
|
|
}
|
|
@@ -501,10 +501,10 @@ void Radio::decodeData()
|
|
|
int high = m_data.at(16);
|
|
|
int low = m_data.at(17);
|
|
|
int dataLen = (high << 8) | low;
|
|
|
- qDebug() << "dataLen:" << dataLen;
|
|
|
+ //qDebug() << "dataLen:" << dataLen;
|
|
|
// 长度不对
|
|
|
if ((dataLen + sizeof(packageDataHead)) > m_data.size()) {
|
|
|
- qDebug() << "message len error";
|
|
|
+ //qDebug() << "message len error";
|
|
|
return;
|
|
|
}
|
|
|
QByteArray temp = m_data.left(sizeof(packageDataHead) + dataLen + 1);
|
|
@@ -559,86 +559,93 @@ void Radio::replyMessage()
|
|
|
char *recvBuf = data.data();
|
|
|
if(len < 21 || recvBuf == NULL)
|
|
|
{
|
|
|
- qDebug() << "len error";
|
|
|
+ //qDebug() << "len error";
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- qDebug() <<"len:"<<len;
|
|
|
- qDebug() <<"recvBuf: "<<recvBuf;
|
|
|
+ //qDebug() <<"len:"<<len;
|
|
|
+ //qDebug() <<"recvBuf: "<<recvBuf;
|
|
|
|
|
|
bool is_checkok = false;
|
|
|
is_checkok = BCCDecode(recvBuf,len);
|
|
|
if(is_checkok==false) {
|
|
|
- qDebug() << "check error";
|
|
|
+ //qDebug() << "check error";
|
|
|
return;
|
|
|
} else {
|
|
|
- qDebug() << "check ok";
|
|
|
- }
|
|
|
- switch(recvBuf[5]) {
|
|
|
+ //qDebug() << "check ok";
|
|
|
+ }
|
|
|
+ switch(recvBuf[5]) {
|
|
|
case TrafficLight: {
|
|
|
lightMessage light;
|
|
|
light.lightType=recvBuf[18];
|
|
|
light.timeRemaining=(((recvBuf[19]<<8)&0xFF00)|((recvBuf[20])&0xFF));
|
|
|
- qDebug() << "[RADIO]:receive light type is "<<int(light.lightType)<<" and remaining is "<<light.timeRemaining;
|
|
|
+ //qDebug() << "[RADIO]:receive light type is "<<int(light.lightType)<<" and remaining is "<<light.timeRemaining;
|
|
|
outLight(light);
|
|
|
break;
|
|
|
}
|
|
|
- case RealtimeTraffic: {
|
|
|
- realtimeTrafficMessage realtimeTraffic;
|
|
|
- realtimeTraffic.lng=(((recvBuf[18]<<24)&0xFF000000)|((recvBuf[19]<<16)&0xFF0000)|((recvBuf[20]<<8)&0xFF00)|((recvBuf[21])&0xFF));
|
|
|
- realtimeTraffic.lat=(((recvBuf[22]<<24)&0xFF000000)|((recvBuf[23]<<16)&0xFF0000)|((recvBuf[24]<<8)&0xFF00)|((recvBuf[25])&0xFF));
|
|
|
- realtimeTraffic.scope=(((recvBuf[26]<<8)&0xFF00)|((recvBuf[27])&0xFF));
|
|
|
- realtimeTraffic.trafficInfo=recvBuf[28];
|
|
|
- realtimeTraffic.speedLimit=(recvBuf[29]&0xFF);
|
|
|
- qDebug() << "[RADIO]:receive real time traffic message "<<endl;
|
|
|
- outRealtimeTraffic(realtimeTraffic);
|
|
|
+ case RealtimeTraffic: {
|
|
|
+ if((recvBuf[4]==0x01)&&(recvBuf[3]==0x00)&&(recvBuf[2]==0x01)&&(recvBuf[1]=0x24)&&(recvBuf[0]==0x24)) {
|
|
|
+ realtimeTrafficMessage realtimeTraffic;
|
|
|
+ realtimeTraffic.lng=(((recvBuf[18]<<24)&0xFF000000)|((recvBuf[19]<<16)&0xFF0000)|((recvBuf[20]<<8)&0xFF00)|((recvBuf[21])&0xFF));
|
|
|
+ realtimeTraffic.lat=(((recvBuf[22]<<24)&0xFF000000)|((recvBuf[23]<<16)&0xFF0000)|((recvBuf[24]<<8)&0xFF00)|((recvBuf[25])&0xFF));
|
|
|
+ realtimeTraffic.scope=(((recvBuf[26]<<8)&0xFF00)|((recvBuf[27])&0xFF));
|
|
|
+ realtimeTraffic.trafficInfo=recvBuf[28];
|
|
|
+ realtimeTraffic.speedLimit=(recvBuf[29]&0xFF);
|
|
|
+ //qDebug() << "[RADIO]:receive real time traffic message "<<endl;
|
|
|
+ outRealtimeTraffic(realtimeTraffic);
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
case CollisionEarlyWarning: {
|
|
|
- collisionEarlyWarningMessage collisionWarning;
|
|
|
- char *str=new char[17];
|
|
|
- memcpy(str, recvBuf+18, 17);
|
|
|
- collisionWarning.isEnable=true;
|
|
|
- collisionWarning.vin=str;
|
|
|
- delete []str;
|
|
|
- collisionWarning.warningType=recvBuf[35];
|
|
|
- collisionWarning.speedLimit=recvBuf[36];
|
|
|
- if(collisionWarning.vin==m_sVin) {
|
|
|
- qDebug() << "[RADIO]:receive collisionEarlyWarning message "<<endl;
|
|
|
- outCollisionWarning(collisionWarning);
|
|
|
- responseCollisionEarlyWarning(collisionWarning);
|
|
|
- m_responseType=collisionWarning.warningType;
|
|
|
- m_bEnUpRespond=true;
|
|
|
- //upRespondMessage();
|
|
|
- } else {
|
|
|
- qDebug()<<"[CollisionEarlyWarning] vin error"<<endl;
|
|
|
+ qDebug()<<"[JLLTest]:INTO WARNING"<<recvBuf[0]<<recvBuf[1]<<recvBuf[2]<<recvBuf[3]<<recvBuf[4]<<recvBuf[5]<<recvBuf[35]<<recvBuf[36]<<endl;
|
|
|
+ if(recvBuf[4]==0x02) {
|
|
|
+ collisionEarlyWarningMessage collisionWarning;
|
|
|
+ char *str=new char[17];
|
|
|
+ memcpy(str, recvBuf+18, 17);
|
|
|
+ collisionWarning.isEnable=true;
|
|
|
+ collisionWarning.vin=str;
|
|
|
+ delete []str;
|
|
|
+ collisionWarning.warningType=recvBuf[35];
|
|
|
+ collisionWarning.speedLimit=recvBuf[36];
|
|
|
+ if(collisionWarning.vin==m_sVin) {
|
|
|
+ //qDebug() << "[RADIO]:receive collisionEarlyWarning message "<<endl;
|
|
|
+ outCollisionWarning(collisionWarning);
|
|
|
+ responseCollisionEarlyWarning(collisionWarning);
|
|
|
+ m_responseType=collisionWarning.warningType;
|
|
|
+ m_bEnUpRespond=true;
|
|
|
+ //upRespondMessage();
|
|
|
+ } else {
|
|
|
+ //qDebug()<<"[CollisionEarlyWarning] vin error"<<endl;
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case CongestionIdentification: {
|
|
|
- congestionIdentificationMessage congestionIdenti;
|
|
|
- char *str=new char[17];
|
|
|
- memcpy(str, recvBuf+18, 17);
|
|
|
- congestionIdenti.isEnable=true;
|
|
|
- congestionIdenti.vin=str;
|
|
|
- delete []str;
|
|
|
- congestionIdenti.openCommand=recvBuf[35];
|
|
|
- if(congestionIdenti.vin==m_sVin) {
|
|
|
- qDebug() << "[RADIO]:receive congestion identification message "<<endl;
|
|
|
- responseCongestionIdentification(congestionIdenti);
|
|
|
- outCongestionIdenti(congestionIdenti);
|
|
|
- } else {
|
|
|
- qDebug()<<"[CongestionIdentification] vin error"<<endl;
|
|
|
+ if(recvBuf[4]==0x03) {
|
|
|
+ congestionIdentificationMessage congestionIdenti;
|
|
|
+ char *str=new char[17];
|
|
|
+ memcpy(str, recvBuf+18, 17);
|
|
|
+ congestionIdenti.isEnable=true;
|
|
|
+ congestionIdenti.vin=str;
|
|
|
+ delete []str;
|
|
|
+ congestionIdenti.openCommand=recvBuf[35];
|
|
|
+ if(congestionIdenti.vin==m_sVin) {
|
|
|
+ //qDebug() << "[RADIO]:receive congestion identification message "<<endl;
|
|
|
+ responseCongestionIdentification(congestionIdenti);
|
|
|
+ outCongestionIdenti(congestionIdenti);
|
|
|
+ } else {
|
|
|
+ // qDebug()<<"[CongestionIdentification] vin error"<<endl;
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case ResponseMessage: {
|
|
|
- qDebug() << "[RADIO]:receive answer Response Message "<<endl;
|
|
|
+ //qDebug() << "[RADIO]:receive answer Response Message "<<endl;
|
|
|
m_iResponse = -1;
|
|
|
break;
|
|
|
}
|
|
|
case VirtualVehicle: {
|
|
|
- qDebug() << "[RADIO]:receive answer VirtualVehicle "<<endl;
|
|
|
+ //qDebug() << "[RADIO]:receive answer VirtualVehicle "<<endl;
|
|
|
m_iVirtualVehicle = -1;
|
|
|
break;
|
|
|
}
|
|
@@ -688,7 +695,7 @@ void Radio::ReceiveDecode(QByteArray &data)
|
|
|
static int BATH_LENTH = 22;
|
|
|
// 防包太大
|
|
|
if (data.size() > 2048) {
|
|
|
- qDebug() << "size too large";
|
|
|
+ //qDebug() << "size too large";
|
|
|
return;
|
|
|
}
|
|
|
// ##
|
|
@@ -710,10 +717,10 @@ void Radio::ReceiveDecode(QByteArray &data)
|
|
|
int high = data.at(16);
|
|
|
int low = data.at(17);
|
|
|
int dataLen = (high << 8) | low;
|
|
|
- qDebug() << "dataLen:" << dataLen;
|
|
|
+ //qDebug() << "dataLen:" << dataLen;
|
|
|
// 长度不对
|
|
|
if ((dataLen + sizeof(packageDataHead)) > data.size()) {
|
|
|
- qDebug() << "message len error";
|
|
|
+ //qDebug() << "message len error";
|
|
|
return;
|
|
|
}
|
|
|
QByteArray temp = data.left(sizeof(packageDataHead) + dataLen + 1);
|