Csr location class shows location and satellite information, which supports H13467 + ST F103RB/NXP LCP1549 boards now.
Dependents: CsrLocationDemo CsrLocationDemo
Fork of CsrLocation by
Diff: CsrLocation.cpp
- Revision:
- 1:bbaf9b8d646a
- Parent:
- 0:aba381fc8158
- Child:
- 2:d4fe184925f2
--- a/CsrLocation.cpp Mon Mar 24 08:23:25 2014 +0000 +++ b/CsrLocation.cpp Tue Mar 25 05:26:26 2014 +0000 @@ -8,15 +8,15 @@ #include "CsrLocation.h" -const static CsrUint8 sOspStopReq[] = {0xa0, 0xa2, 0x00, 0x02, 0xcd, 0x10, 0x00, 0xdd, 0xb0, 0xb3}; -const static CsrUint8 sOspVerReq[] = {0xA0, 0xA2, 0x00, 0x02, 0x84, 0x00, 0x00, 0x84, 0xB0, 0xB3}; -const static CsrUint8 sOspLpmReq[] = {0xA0, 0xA2, 0x00, 0x2A, 0xDA, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x01, 0x00, 0x78, 0x00, 0x1E, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x63, 0xB0, 0xB3}; -const static CsrUint8 sOspFpmReq[] = {0xA0, 0xA2, 0x00, 0x03, 0xDA, 0x00, 0x00, 0x00, 0xDA, 0xB0, 0xB3}; -const static CsrUint8 sOspSwitch2NmeaReq[] = {0xA0, 0xA2, 0x00, 0x18, 0x81, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x05, 0x01, 0x01, 0x01, 0x00, +static CsrUint8 sOspStopReq[] = {0xa0, 0xa2, 0x00, 0x02, 0xcd, 0x10, 0x00, 0xdd, 0xb0, 0xb3}; +static CsrUint8 sOspVerReq[] = {0xA0, 0xA2, 0x00, 0x02, 0x84, 0x00, 0x00, 0x84, 0xB0, 0xB3}; +static CsrUint8 sOspLpmReq[] = {0xA0, 0xA2, 0x00, 0x2A, 0xDA, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x01, 0x00, 0x78, 0x00, 0x1E, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x63, 0xB0, 0xB3}; +static CsrUint8 sOspFpmReq[] = {0xA0, 0xA2, 0x00, 0x03, 0xDA, 0x00, 0x00, 0x00, 0xDA, 0xB0, 0xB3}; +static CsrUint8 sOspSwitch2NmeaReq[] = {0xA0, 0xA2, 0x00, 0x18, 0x81, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x05, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x12, 0xC0, 0x01, 0x64, 0xB0, 0xB3}; -const static CsrCharString sNmeaSwitch2OspReq[] = "$PSRF100,0,115200,8,1,0*04\r\n"; +static CsrCharString sNmeaSwitch2OspReq[] = "$PSRF100,0,115200,8,1,0*04\r\n"; CsrLocation::CsrLocation(tCsrLocConfig *pLocConfig) { @@ -74,6 +74,9 @@ _CsrLocHwOnoff(); csrLocInst.locState = CSR_LOC_STATE_RUN; + csrLocInst.bPwrModeRsp = FALSE; + csrLocInst.bVerRsp = FALSE; + } else { @@ -137,9 +140,6 @@ memset(pLocInst->serialBuf, 0 , MAX_SERIAL_BUF_LEN); memset(pLocInst->serialPkt, 0 , MAX_SERIAL_PKT_LEN); - pLocInst->isOspHeader = FALSE; - pLocInst->isNmeaHeader = FALSE; - pLocInst->checksum = 0; pLocInst->msgSize = 0; pLocInst->decodeIndex = 0; @@ -175,14 +175,10 @@ break; default: /* Discard received data */ - pLocInst->out = pLocInst->in; + //pLocInst->out = pLocInst->in; break; } } - else - { - wait_ms(1); - } } void CsrLocation::_CsrLocDetProtoOsp(CsrUint8 data) @@ -420,6 +416,8 @@ pLocInst->protoState = PROTO_STATE_DET_OK; pLocInst->appEventCb(CSR_LOC_EVENT_START_RESULT, 0); } + +// pLocInst->bRawOspPktReady = TRUE; _CsrLocProcessRawOspPkt(); pLocInst->protoDetState = STATE_START1; } @@ -446,6 +444,12 @@ CsrUint32 msgSize; CsrResult result; +// if(!pLocInst->bRawOspPktReady) +// { +// return; +// } + +// pLocInst->bRawOspPktReady = FALSE; msgSize = _CsrLocCalcMsgSize(); if(msgSize > 0) { @@ -734,21 +738,29 @@ break; case OSP_MSG_HW_CONFIG_REQ: CSR_LOG_INFO("hw config req.\r\n"); - if(csrLocInst.pwrMode == PWR_PTF) - { + if(!csrLocInst.bVerRsp); + { _CsrLocSendData(SEND_DATA_TYPE_OSP_VER_REQ); - _CsrLocSendData(SEND_DATA_TYPE_OSP_LPM_REQ); } - else + + if(!csrLocInst.bPwrModeRsp) { - _CsrLocSendData(SEND_DATA_TYPE_OSP_FPM_REQ); - _CsrLocSendData(SEND_DATA_TYPE_OSP_VER_REQ); + if(csrLocInst.pwrMode == PWR_PTF) + { + _CsrLocSendData(SEND_DATA_TYPE_OSP_LPM_REQ); + } + else + { + _CsrLocSendData(SEND_DATA_TYPE_OSP_FPM_REQ); + } } break; case OSP_MSG_PWR_MODE_LPM_RSP: + csrLocInst.bPwrModeRsp = TRUE; CSR_LOG_INFO("lpm response.\r\n"); break; case OSP_MSG_PWR_MODE_FPM_RSP: + csrLocInst.bPwrModeRsp = TRUE; CSR_LOG_INFO("fpm response.\r\n"); break; default: @@ -770,7 +782,7 @@ pLocInst->in &= (MAX_SERIAL_BUF_LEN-1); if(pLocInst->in == pLocInst->out) { - CSR_LOG_INFO("rx overwritten.\r\n"); + CSR_LOG_INFO("rx overwritten %d %d.\r\n", pLocInst->in, pLocInst->out); } } @@ -815,7 +827,6 @@ { for (i = 0; i < size; i++) { - while(pLocInst->pSerialLoc->writeable() == 0) {} pLocInst->pSerialLoc->putc(pData[i]); } }