Skip to content

Commit

Permalink
check ubx send status and actually return payload
Browse files Browse the repository at this point in the history
  • Loading branch information
EricPedley committed Apr 12, 2024
1 parent a3d3b0d commit b9ef6ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion gps_ubxm8_i2c/gps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const GpsUbxM8I2c::State GpsUbxM8I2c::GetState() { return _state; }
*/
const GpsUbxM8I2c::PollResult GpsUbxM8I2c::PollUpdate() {
if (_state == GpsUbxM8I2c::State::REQUEST_NOT_SENT) {
sendUBX(_ubxMessage);
if(!sendUBX(_ubxMessage)) {
return GpsUbxM8I2c::PollResult::REQUEST_SEND_FAILED;
}
_state = GpsUbxM8I2c::State::POLLING_RESPONSE;
}

Expand Down Expand Up @@ -143,6 +145,8 @@ UCIRP_GPS_PAYLOAD ConvertPayloadToECEF(UBX_NAV_PVT_PAYLOAD pvtPayload) {
double velD = (double)pvtPayload.velD / 1000;

Ned2EcefVel(lat, lon, alt, velN, velE, velD, payload.ecefVX, payload.ecefVY, payload.ecefVZ);

return payload;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion gps_ubxm8_i2c/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class GpsUbxM8I2c {
NO_UBX_DATA, // data read successfully but no UBX start bytes found
DATA_LEN_POLL_FAILED, // there was a failure in the I2C mem read for getting the quantity of data available
DATA_RECEIVE_I2C_FAILED, // there was a failure in the I2C receive to read the available data from the GPS
DATA_RECEIVE_CHECKSUM_FAILED // we received UBX data but the checksum didn't match the message.
DATA_RECEIVE_CHECKSUM_FAILED, // we received UBX data but the checksum didn't match the message.
REQUEST_SEND_FAILED // the request to the GPS failed (probably i2c transmit error)
};
GpsUbxM8I2c(GPIO_TypeDef* gpioResetPort, uint16_t gpioResetPin, I2C_HandleTypeDef* i2c, uint8_t* ubxMessage);
void Init();
Expand Down

0 comments on commit b9ef6ea

Please sign in to comment.