代码位于/libraries/AP_GPS里
代码中默认GPS1选择的是serial3,GPS2选择的是serial4
gps.set_log_gps_bit(MASK_LOG_GPS); //设定记录GPS log标志位
gps.init(serial_manager); //进行GPS函数初始化
gps.update(); //更新GPS数据
update_instance(i); //更新GPS实例的个数
detect_instance(instance); 实例化选择配置不同的GPS
如果是选择自动配置就会选择UBLOX
重点需要看以下代码:
if (now - dstate->last_baud_change_ms > GPS_BAUD_TIME_MS)
{
// try the next baud rate
// incrementing like this will skip the first element in array of bauds
// this is okay, and relied upon
dstate->current_baud++;
if (dstate->current_baud == ARRAY_SIZE(_baudrates))
{
dstate->current_baud = 0;
}
uint32_t baudrate = _baudrates[dstate->current_baud];
_port[instance]->begin(baudrate);
_port[instance]->set_flow_control(AP_HAL::UARTDriver::FLOW_CONTROL_DISABLE);
dstate->last_baud_change_ms = now;
if (_auto_config == GPS_AUTO_CONFIG_ENABLE && new_gps == nullptr) //这里选择自动配置<br /> {<br /> send_blob_start(instance, _initialisation_blob, sizeof(_initialisation_blob));<br /> }<br /> }
if (_auto_config == GPS_AUTO_CONFIG_ENABLE && new_gps == nullptr) <br /> {<br /> send_blob_update(instance);<br /> }