AP_SerialManager: added SERIAL5_* support

This commit is contained in:
Andrew Tridgell 2016-04-19 13:48:57 +10:00
parent 6120631977
commit 0baf8ee2eb
2 changed files with 29 additions and 11 deletions

View File

@ -27,11 +27,11 @@
extern const AP_HAL::HAL& hal; extern const AP_HAL::HAL& hal;
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V4 #ifdef CONFIG_ARCH_BOARD_PX4FMU_V4
#define SERIAL4_PROTOCOL SerialProtocol_MAVLink #define SERIAL5_PROTOCOL SerialProtocol_MAVLink
#define SERIAL4_BAUD 921600 #define SERIAL5_BAUD 921600
#else #else
#define SERIAL4_PROTOCOL SerialProtocol_GPS #define SERIAL5_PROTOCOL SerialProtocol_None
#define SERIAL4_BAUD AP_SERIALMANAGER_GPS_BAUD/1000 #define SERIAL5_BAUD AP_SERIALMANAGER_MAVLINK_BAUD/1000
#endif #endif
@ -46,7 +46,7 @@ const AP_Param::GroupInfo AP_SerialManager::var_info[] = {
// @Param: 1_PROTOCOL // @Param: 1_PROTOCOL
// @DisplayName: Telem1 protocol selection // @DisplayName: Telem1 protocol selection
// @Description: Control what protocol to use on the Telem1 port. Note that the Frsky options require external converter hardware. See the wiki for details. // @Description: Control what protocol to use on the Telem1 port. Note that the Frsky options require external converter hardware. See the wiki for details.
// @Values: 1:GCS Mavlink, 3:Frsky D-PORT, 4:Frsky S-PORT, 5:GPS, 7:Alexmos Gimbal Serial, 8:SToRM32 Gimbal Serial, 9:Lidar // @Values: -1:None, 1:GCS Mavlink, 3:Frsky D-PORT, 4:Frsky S-PORT, 5:GPS, 7:Alexmos Gimbal Serial, 8:SToRM32 Gimbal Serial, 9:Lidar
// @User: Standard // @User: Standard
AP_GROUPINFO("1_PROTOCOL", 1, AP_SerialManager, state[1].protocol, SerialProtocol_MAVLink), AP_GROUPINFO("1_PROTOCOL", 1, AP_SerialManager, state[1].protocol, SerialProtocol_MAVLink),
@ -60,7 +60,7 @@ const AP_Param::GroupInfo AP_SerialManager::var_info[] = {
// @Param: 2_PROTOCOL // @Param: 2_PROTOCOL
// @DisplayName: Telemetry 2 protocol selection // @DisplayName: Telemetry 2 protocol selection
// @Description: Control what protocol to use on the Telem2 port. Note that the Frsky options require external converter hardware. See the wiki for details. // @Description: Control what protocol to use on the Telem2 port. Note that the Frsky options require external converter hardware. See the wiki for details.
// @Values: 1:GCS Mavlink, 3:Frsky D-PORT, 4:Frsky S-PORT, 5:GPS, 7:Alexmos Gimbal Serial, 8:SToRM32 Gimbal Serial, 9:Lidar // @Values: -1:None, 1:GCS Mavlink, 3:Frsky D-PORT, 4:Frsky S-PORT, 5:GPS, 7:Alexmos Gimbal Serial, 8:SToRM32 Gimbal Serial, 9:Lidar
// @User: Standard // @User: Standard
AP_GROUPINFO("2_PROTOCOL", 3, AP_SerialManager, state[2].protocol, SerialProtocol_MAVLink), AP_GROUPINFO("2_PROTOCOL", 3, AP_SerialManager, state[2].protocol, SerialProtocol_MAVLink),
@ -74,7 +74,7 @@ const AP_Param::GroupInfo AP_SerialManager::var_info[] = {
// @Param: 3_PROTOCOL // @Param: 3_PROTOCOL
// @DisplayName: Serial 3 (GPS) protocol selection // @DisplayName: Serial 3 (GPS) protocol selection
// @Description: Control what protocol Serial 3 (GPS) should be used for. Note that the Frsky options require external converter hardware. See the wiki for details. // @Description: Control what protocol Serial 3 (GPS) should be used for. Note that the Frsky options require external converter hardware. See the wiki for details.
// @Values: 1:GCS Mavlink, 3:Frsky D-PORT, 4:Frsky S-PORT, 5:GPS, 7:Alexmos Gimbal Serial, 8:SToRM32 Gimbal Serial, 9:Lidar // @Values: -1:None, 1:GCS Mavlink, 3:Frsky D-PORT, 4:Frsky S-PORT, 5:GPS, 7:Alexmos Gimbal Serial, 8:SToRM32 Gimbal Serial, 9:Lidar
// @User: Standard // @User: Standard
AP_GROUPINFO("3_PROTOCOL", 5, AP_SerialManager, state[3].protocol, SerialProtocol_GPS), AP_GROUPINFO("3_PROTOCOL", 5, AP_SerialManager, state[3].protocol, SerialProtocol_GPS),
@ -88,16 +88,30 @@ const AP_Param::GroupInfo AP_SerialManager::var_info[] = {
// @Param: 4_PROTOCOL // @Param: 4_PROTOCOL
// @DisplayName: Serial4 protocol selection // @DisplayName: Serial4 protocol selection
// @Description: Control what protocol Serial4 port should be used for. Note that the Frsky options require external converter hardware. See the wiki for details. // @Description: Control what protocol Serial4 port should be used for. Note that the Frsky options require external converter hardware. See the wiki for details.
// @Values: 1:GCS Mavlink, 3:Frsky D-PORT, 4:Frsky S-PORT, 5:GPS, 7:Alexmos Gimbal Serial, 8:SToRM32 Gimbal Serial, 9:Lidar // @Values: -1:None, 1:GCS Mavlink, 3:Frsky D-PORT, 4:Frsky S-PORT, 5:GPS, 7:Alexmos Gimbal Serial, 8:SToRM32 Gimbal Serial, 9:Lidar
// @User: Standard // @User: Standard
AP_GROUPINFO("4_PROTOCOL", 7, AP_SerialManager, state[4].protocol, SERIAL4_PROTOCOL), AP_GROUPINFO("4_PROTOCOL", 7, AP_SerialManager, state[4].protocol, SerialProtocol_GPS2),
// @Param: 4_BAUD // @Param: 4_BAUD
// @DisplayName: Serial 4 Baud Rate // @DisplayName: Serial 4 Baud Rate
// @Description: The baud rate used for Serial4. The APM2 can support all baudrates up to 115, and also can support 500. The PX4 can support rates of up to 1500. If you setup a rate you cannot support on APM2 and then can't connect to your board you should load a firmware from a different vehicle type. That will reset all your parameters to defaults. // @Description: The baud rate used for Serial4. The APM2 can support all baudrates up to 115, and also can support 500. The PX4 can support rates of up to 1500. If you setup a rate you cannot support on APM2 and then can't connect to your board you should load a firmware from a different vehicle type. That will reset all your parameters to defaults.
// @Values: 1:1200,2:2400,4:4800,9:9600,19:19200,38:38400,57:57600,111:111100,115:115200,500:500000,921:921600,1500:1500000 // @Values: 1:1200,2:2400,4:4800,9:9600,19:19200,38:38400,57:57600,111:111100,115:115200,500:500000,921:921600,1500:1500000
// @User: Standard // @User: Standard
AP_GROUPINFO("4_BAUD", 8, AP_SerialManager, state[4].baud, SERIAL4_BAUD), AP_GROUPINFO("4_BAUD", 8, AP_SerialManager, state[4].baud, AP_SERIALMANAGER_GPS_BAUD/1000),
// @Param: 5_PROTOCOL
// @DisplayName: Serial4 protocol selection
// @Description: Control what protocol Serial4 port should be used for. Note that the Frsky options require external converter hardware. See the wiki for details.
// @Values: -1:None, 1:GCS Mavlink, 3:Frsky D-PORT, 4:Frsky S-PORT, 5:GPS, 7:Alexmos Gimbal Serial, 8:SToRM32 Gimbal Serial, 9:Lidar
// @User: Standard
AP_GROUPINFO("5_PROTOCOL", 9, AP_SerialManager, state[5].protocol, SERIAL5_PROTOCOL),
// @Param: 5_BAUD
// @DisplayName: Serial 4 Baud Rate
// @Description: The baud rate used for Serial4. The APM2 can support all baudrates up to 115, and also can support 500. The PX4 can support rates of up to 1500. If you setup a rate you cannot support on APM2 and then can't connect to your board you should load a firmware from a different vehicle type. That will reset all your parameters to defaults.
// @Values: 1:1200,2:2400,4:4800,9:9600,19:19200,38:38400,57:57600,111:111100,115:115200,500:500000,921:921600,1500:1500000
// @User: Standard
AP_GROUPINFO("5_BAUD", 10, AP_SerialManager, state[5].baud, SERIAL5_BAUD),
AP_GROUPEND AP_GROUPEND
}; };
@ -128,11 +142,14 @@ void AP_SerialManager::init()
state[2].uart = hal.uartD; // serial2, uartD, normally telem2 state[2].uart = hal.uartD; // serial2, uartD, normally telem2
state[3].uart = hal.uartB; // serial3, uartB, normally 1st GPS state[3].uart = hal.uartB; // serial3, uartB, normally 1st GPS
state[4].uart = hal.uartE; // serial4, uartE, normally 2nd GPS state[4].uart = hal.uartE; // serial4, uartE, normally 2nd GPS
state[5].uart = hal.uartF; // serial5
// initialise serial ports // initialise serial ports
for (uint8_t i=1; i<SERIALMANAGER_NUM_PORTS; i++) { for (uint8_t i=1; i<SERIALMANAGER_NUM_PORTS; i++) {
if (state[i].uart != NULL) { if (state[i].uart != NULL) {
switch (state[i].protocol) { switch (state[i].protocol) {
case SerialProtocol_None:
break;
case SerialProtocol_Console: case SerialProtocol_Console:
state[i].uart->begin(map_baudrate(state[i].baud), state[i].uart->begin(map_baudrate(state[i].baud),
AP_SERIALMANAGER_CONSOLE_BUFSIZE_RX, AP_SERIALMANAGER_CONSOLE_BUFSIZE_RX,

View File

@ -27,7 +27,7 @@
#include <AP_HAL/AP_HAL.h> #include <AP_HAL/AP_HAL.h>
#include <GCS_MAVLink/GCS_MAVLink.h> #include <GCS_MAVLink/GCS_MAVLink.h>
#define SERIALMANAGER_NUM_PORTS 5 #define SERIALMANAGER_NUM_PORTS 6
// console default baud rates and buffer sizes // console default baud rates and buffer sizes
#ifdef HAL_SERIAL0_BAUD_DEFAULT #ifdef HAL_SERIAL0_BAUD_DEFAULT
@ -70,6 +70,7 @@ class AP_SerialManager {
public: public:
enum SerialProtocol { enum SerialProtocol {
SerialProtocol_None = -1,
SerialProtocol_Console = 0, SerialProtocol_Console = 0,
SerialProtocol_MAVLink = 1, SerialProtocol_MAVLink = 1,
SerialProtocol_MAVLink2 = 2, // do not use - use MAVLink and provide instance of 1 SerialProtocol_MAVLink2 = 2, // do not use - use MAVLink and provide instance of 1