diff --git a/GPS/GpsModel.cpp b/GPS/GpsModel.cpp index f5c9fcb066774b3350623c8b39d938ee40b4c8f5..c2bbcf8310db975448c299adf4bea8db53086342 100755 --- a/GPS/GpsModel.cpp +++ b/GPS/GpsModel.cpp @@ -1157,7 +1157,7 @@ BOOL GpsModel::setTime(const std::string &strBuf, SYSTEMTIME &sysTime) timeinfo2.tm_min = sysTime.wMinute; timeinfo2.tm_sec = sysTime.wSecond; time_t timestamp = mktime(&timeinfo2); - std::cout <<"时间戳:" << timestamp << std::endl; + std::cout << "时间戳:" << timestamp << std::endl; return bResult; } @@ -1350,7 +1350,7 @@ void GpsModel::run(void *pdata) char data[2048]; m_pGPSCom->recvGPS(data, 2048); string strText = string(data); - // cout << "GpsModel strText: " << strText << endl; + cout << "GpsModel strText: " << strText << endl; // 解析 ParseGpsData(strText, pCommonData); setTime(strText, sysTime); diff --git a/aiboxhttp/CATCommand.cpp b/aiboxhttp/CATCommand.cpp index 206f36c355923fd391f7216287a7e3a737627b33..8dfd405bac030813f37adf3071a0e2c819758893 100755 --- a/aiboxhttp/CATCommand.cpp +++ b/aiboxhttp/CATCommand.cpp @@ -5,21 +5,21 @@ int g_connect_fd; CATCommand::CATCommand(/* args */) { - OpenATChannel(); + OpenATChannel(); } CATCommand::~CATCommand() { - if (pInstance != nullptr) + if (pInstance != nullptr) { delete pInstance; - pInstance = nullptr; + pInstance = nullptr; } } bool CATCommand::OpenATChannel() { - int rst; + int rst; g_connect_fd = socket(PF_UNIX, SOCK_STREAM, 0); if (g_connect_fd < 0) { @@ -29,23 +29,23 @@ bool CATCommand::OpenATChannel() srv_addr.sun_family = AF_UNIX; strcpy(srv_addr.sun_path, SERVER_NAME); srv_addr.sun_path[0] = 0; - server_len = strlen(SERVER_NAME) + offsetof(struct sockaddr_un, sun_path); + server_len = strlen(SERVER_NAME) + offsetof(struct sockaddr_un, sun_path); - rst = ::connect(g_connect_fd, (struct sockaddr *)&srv_addr, server_len); + rst = ::connect(g_connect_fd, (struct sockaddr *)&srv_addr, server_len); if (rst == -1) { perror("Cannot connect to the server, this line is37"); close(g_connect_fd); return false; - } + } return true; } int CATCommand::cmdSend(int iCmd) { - printf("pCmd:%d\n", iCmd); - return Sendcmd(g_connect_fd, iCmd, NULL); + printf("pCmd:%d\n", iCmd); + return Sendcmd(g_connect_fd, iCmd, NULL); } int CATCommand::Sendcmd(int fd, int cmd, ...) @@ -57,7 +57,7 @@ int CATCommand::Sendcmd(int fd, int cmd, ...) char *p; int len; int cmdlen; - int i; + // int i; buf[0] = 'H'; buf[1] = 'T'; @@ -71,7 +71,7 @@ int CATCommand::Sendcmd(int fd, int cmd, ...) while (1) { para = va_arg(argp, char *); - if (para <= 0) + if (para <= 0) break; len = strlen(para); *p = len >> 8; @@ -87,8 +87,8 @@ int CATCommand::Sendcmd(int fd, int cmd, ...) *(p + 1) = 0; cmdlen += 2; - if (write(fd, buf, cmdlen) == -1) - return -1; + if (write(fd, buf, cmdlen) == -1) + return -1; return 0; } @@ -104,59 +104,59 @@ bool CATCommand::cmdrecv(char *out_buf) recv_buf[num] = 0; memset(out_buf, 0, num); - if (num < 0) + if (num < 0) { - return false; + return false; } - if(!memcmp(recv_buf,"HTR",3)) - { - msg = (*(recv_buf+3)<<8) + *(recv_buf+4); - state = (*(recv_buf+5)<<8) + *(recv_buf+6); - - switch (msg) - { - case CMD_GET_IMEI: - if(state == CMD_OK) - { - len = strlen(recv_buf + 7); - if (len > 2) - { - memcpy(out_buf, recv_buf + 7, len); - bret = true; - } - } - else if(state == CMD_ERR_BUSY) - { - printf("IMEI:busy...\n"); - } - else - { - printf("IMEI:error!\n"); - } - break; - default: - printf("msg = %d,state= %d,msg= %s\n",msg,state,recv_buf+7); - break; - } - } + if (!memcmp(recv_buf, "HTR", 3)) + { + msg = (*(recv_buf + 3) << 8) + *(recv_buf + 4); + state = (*(recv_buf + 5) << 8) + *(recv_buf + 6); + + switch (msg) + { + case CMD_GET_IMEI: + if (state == CMD_OK) + { + len = strlen(recv_buf + 7); + if (len > 2) + { + memcpy(out_buf, recv_buf + 7, len); + bret = true; + } + } + else if (state == CMD_ERR_BUSY) + { + printf("IMEI:busy...\n"); + } + else + { + printf("IMEI:error!\n"); + } + break; + default: + printf("msg = %d,state= %d,msg= %s\n", msg, state, recv_buf + 7); + break; + } + } return bret; } string CATCommand::GetATCommand(int cmd) { - m_cmdret.clear(); - m_bgetcmdret = false; + m_cmdret.clear(); + m_bgetcmdret = false; - GetCMDReply(cmd); - if (m_bgetcmdret) - { - m_cmdret = m_recv_buf; - m_bgetcmdret = false; - } + GetCMDReply(cmd); + if (m_bgetcmdret) + { + m_cmdret = m_recv_buf; + m_bgetcmdret = false; + } - return m_cmdret; + return m_cmdret; } void CATCommand::GetCMDReply(int cmd) @@ -166,12 +166,12 @@ void CATCommand::GetCMDReply(int cmd) if (!m_bgetcmdret) { memset(m_recv_buf, 0, 1024); - cmdSend(cmd); + cmdSend(cmd); m_bgetcmdret = cmdrecv(m_recv_buf); - if(m_bgetcmdret) - { - break; - } + if (m_bgetcmdret) + { + break; + } } sleep(1); } diff --git a/tmptime.sh b/tmptime.sh old mode 100644 new mode 100755