| | |
| | | #include <vector> |
| | | #include <list> |
| | | #include <semaphore.h> |
| | | #include <unistd.h> |
| | | |
| | | #define DEBUG(fmt, args...) LOGD("<comm_if> <%s>: " fmt, __func__, ##args) |
| | | |
| | |
| | | #define ID_SM_CAN_BRIEF 0x0021 |
| | | #define ID_SM_BLUETOOTH_BRIEF 0x0022 |
| | | |
| | | #define ID_SM_RTK_STATUS_BRIEF 0x0023 |
| | | |
| | | #define MA_OUT_GPS_BRIEF 0x0001 |
| | | #define MA_OUT_RTK_BRIEF 0x0002 |
| | | #define MA_OUT_CAR_BRIEF 0x0004 |
| | |
| | | |
| | | if (MessageBuffer.size() > 0) { |
| | | struct msg_2_main_t msg; |
| | | int success; |
| | | |
| | | pthread_mutex_lock(&msg_mutex); |
| | | msg = MessageBuffer.back(); |
| | | MessageBuffer.pop_back(); |
| | | pthread_mutex_unlock(&msg_mutex); |
| | | |
| | | if (msg.value.length() > 0) |
| | | SendMsgToMainProc(msg.cmd, msg.value.c_str()); |
| | | success = SendMsgToMainProc(msg.cmd, msg.value.c_str()); |
| | | else |
| | | SendMsgToMainProc(msg.cmd, NULL); |
| | | success = SendMsgToMainProc(msg.cmd, NULL); |
| | | |
| | | if (success == 0) { |
| | | pthread_mutex_lock(&msg_mutex); |
| | | MessageBuffer.pop_back(); |
| | | pthread_mutex_unlock(&msg_mutex); |
| | | } else { |
| | | // 延迟重发 |
| | | usleep(500000); |
| | | sem_post(&sem_msg_income); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | switch (cmd) { |
| | | case ID_MS_RTK_PLAT_CFG: { |
| | | DEBUG("平台信息 %s", value); |
| | | if (OnOff == 0) OnOff = MA_OUT_GPS_BRIEF + MA_OUT_RTK_BRIEF + MA_OUT_CAR_BRIEF; |
| | | |
| | | rtk_platform_cfg_t cfg; |
| | |
| | | const Value &s2 = (*itr)["tts"]; |
| | | |
| | | content[n].item = s1.GetInt(); |
| | | strcpy(content[n].tts, s2.GetString()); |
| | | n++; |
| | | content[n].tts = s2.GetString(); |
| | | } |
| | | |
| | | if (itr->HasMember("wrong_code")) { |
| | | const Value &s = (*itr)["wrong_code"]; |
| | | |
| | | content[n].wrongCode = s.GetInt(); |
| | | } |
| | | |
| | | if (itr->HasMember("process")) { |
| | | const Value& s = doc["process"]; |
| | | for(Value::ConstValueIterator itr2 = s.Begin(); itr2 != s.End(); ++itr2) { |
| | | content[n].process.push_back(itr2->GetInt()); |
| | | } |
| | | } |
| | | if (itr->HasMember("solution")) { |
| | | const Value& s = doc["solution"]; |
| | | for(Value::ConstValueIterator itr2 = s.Begin(); itr2 != s.End(); ++itr2) { |
| | | content[n].solution.push_back(itr2->GetInt()); |
| | | } |
| | | } |
| | | n++; |
| | | } |
| | | |
| | | SetDummyLightExam(n, content); |
| | |
| | | |
| | | SendMsgToMainProcIndep(ID_SM_BLUETOOTH_BRIEF, sb.GetString()); |
| | | } |
| | | |
| | | void MA_SendRtkStatus(const char *model, int status) |
| | | { |
| | | StringBuffer sb; |
| | | Writer<StringBuffer> writer(sb); |
| | | |
| | | writer.StartObject(); |
| | | |
| | | writer.Key("model"); |
| | | if (model == NULL || model[0] == 0) { |
| | | writer.String("Unknown"); |
| | | } else { |
| | | writer.String(model); |
| | | } |
| | | |
| | | writer.Key("status"); |
| | | writer.Int(status); |
| | | |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProcIndep(ID_SM_RTK_STATUS_BRIEF, sb.GetString()); |
| | | } |