yy1717
2021-01-12 683b1595260e638d1d3c6cc0d6543a72f6d6f925
lib/src/main/cpp/master/comm_if.cpp
@@ -22,6 +22,7 @@
#include <vector>
#include <list>
#include <semaphore.h>
#include <unistd.h>
#define DEBUG(fmt, args...)     LOGD("<comm_if> <%s>: " fmt, __func__, ##args)
@@ -74,6 +75,8 @@
#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
@@ -121,16 +124,26 @@
        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);
            }
        }
    }
}
@@ -646,6 +659,7 @@
{
    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;
@@ -1971,9 +1985,28 @@
                                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);
@@ -2063,3 +2096,25 @@
    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());
}