Skip to content

Commit

Permalink
Switched to using a compatible CFG-MSG format for newer ublox version…
Browse files Browse the repository at this point in the history
… (>=5)
  • Loading branch information
achambers16 committed Feb 26, 2014
1 parent 6538222 commit e62bf23
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
6 changes: 6 additions & 0 deletions conf/ubx.xml
Expand Up @@ -124,6 +124,12 @@
<field name="Rate3" format="U1"/>
</block>
</message>

<message name="MSG_RATE" ID="0x01" length="3">
<field name="Class" format="U1"/>
<field name="MsgId" format="U1"/>
<field name="Rate" format="U1"/>
</message>

<message name="NAV" ID="0x03" length="28">
<field name="Platform" format="U1"/>
Expand Down
41 changes: 20 additions & 21 deletions sw/airborne/modules/gps/gps_ubx_ucenter.c
Expand Up @@ -158,6 +158,22 @@ void gps_ubx_ucenter_event(void)
//
// UCENTER Configuration Functions

/**
* Enable u-blox message at desired rate (Hz). Will enable the message on the port
* that this command is received on. For example, sending this configuration message
* over UART1 will cause the desired message to be published on UART1.
*
* For more information on u-blox messages, see the protocol specification.
* http://www.ublox.com/en/download/documents-a-resources.html
*
* @param class u-blox message class
* @param id u-blox message ID
* @param rate Desired rate in cycles per second (Hz)
*/
static inline void gps_ubx_ucenter_enable_msg(uint8_t class, uint8_t id, uint8_t rate)
{
UbxSend_CFG_MSG_RATE(class, id, rate);
}

static bool_t gps_ubx_ucenter_autobaud(uint8_t nr)
{
Expand All @@ -171,7 +187,7 @@ static bool_t gps_ubx_ucenter_autobaud(uint8_t nr)
case 2:
gps_ubx_ucenter.reply = GPS_UBX_UCENTER_REPLY_NONE;
GpsUartSetBaudrate(B38400); // Try the most common first?
UbxSend_CFG_MSG(UBX_NAV_ID, UBX_NAV_VELNED_ID, 0, 1, 0, 0);
gps_ubx_ucenter_enable_msg(UBX_NAV_ID, UBX_NAV_VELNED_ID, 1);
break;
case 3:
if (gps_ubx_ucenter.reply == GPS_UBX_UCENTER_REPLY_ACK)
Expand All @@ -181,7 +197,7 @@ static bool_t gps_ubx_ucenter_autobaud(uint8_t nr)
}
gps_ubx_ucenter.reply = GPS_UBX_UCENTER_REPLY_NONE;
GpsUartSetBaudrate(B9600); // Maybe the factory default?
UbxSend_CFG_MSG(UBX_NAV_ID, UBX_NAV_VELNED_ID, 0, 1, 0, 0);
gps_ubx_ucenter_enable_msg(UBX_NAV_ID, UBX_NAV_VELNED_ID, 1);
break;
case 4:
if (gps_ubx_ucenter.reply == GPS_UBX_UCENTER_REPLY_ACK)
Expand All @@ -191,7 +207,7 @@ static bool_t gps_ubx_ucenter_autobaud(uint8_t nr)
}
gps_ubx_ucenter.reply = GPS_UBX_UCENTER_REPLY_NONE;
GpsUartSetBaudrate(B57600); // The high-rate default?
UbxSend_CFG_MSG(UBX_NAV_ID, UBX_NAV_VELNED_ID, 0, 1, 0, 0);
gps_ubx_ucenter_enable_msg(UBX_NAV_ID, UBX_NAV_VELNED_ID, 1);
break;
case 5:
if (gps_ubx_ucenter.reply == GPS_UBX_UCENTER_REPLY_ACK)
Expand All @@ -201,7 +217,7 @@ static bool_t gps_ubx_ucenter_autobaud(uint8_t nr)
}
gps_ubx_ucenter.reply = GPS_UBX_UCENTER_REPLY_NONE;
GpsUartSetBaudrate(B4800); // Default NMEA baudrate finally?
UbxSend_CFG_MSG(UBX_NAV_ID, UBX_NAV_VELNED_ID, 0, 1, 0, 0);
gps_ubx_ucenter_enable_msg(UBX_NAV_ID, UBX_NAV_VELNED_ID, 1);
break;
case 6:
if (gps_ubx_ucenter.reply == GPS_UBX_UCENTER_REPLY_ACK)
Expand Down Expand Up @@ -318,23 +334,6 @@ static inline void gps_ubx_ucenter_config_sbas(void)
//UbxSend_CFG_SBAS(0x00, 0x00, 0x00, 0x00, 0x00);
}

static inline void gps_ubx_ucenter_enable_msg(uint8_t class, uint8_t id, uint8_t rate)
{
#if GPS_PORT_ID == GPS_PORT_UART1
UbxSend_CFG_MSG(class, id, 0, rate, 0, 0);
#endif
#if GPS_PORT_ID == GPS_PORT_UART2
UbxSend_CFG_MSG(class, id, 0, 0, rate, 0);
#endif
#if GPS_PORT_ID == GPS_PORT_USB
UbxSend_CFG_MSG(class, id, 0, 0, 0, rate);
#endif
#if GPS_PORT_ID == GPS_PORT_DDC
UbxSend_CFG_MSG(class, id, rate, 0, 0, 0);
#endif
}


// Text Telemetry for Debugging
#undef GOT_PAYLOAD
#include "subsystems/datalink/downlink.h"
Expand Down

0 comments on commit e62bf23

Please sign in to comment.