mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
LP-391 This fixes issue with negative size (-1) passing from PIOS_Board_configure_com() to PIOS_COM_Init().
This commit is contained in:
parent
1647982fca
commit
107aa2170e
@ -112,7 +112,7 @@ static void PIOS_COM_UnblockTx(struct pios_com_dev *com_dev, bool *need_yield);
|
||||
* \param[in] id
|
||||
* \return < 0 if initialisation failed
|
||||
*/
|
||||
int32_t PIOS_COM_Init(uint32_t *com_id, const struct pios_com_driver *driver, uint32_t lower_id, uint8_t *rx_buffer, uint16_t rx_buffer_len, uint8_t *tx_buffer, uint16_t tx_buffer_len)
|
||||
int32_t PIOS_COM_Init(uint32_t *com_id, const struct pios_com_driver *driver, uint32_t lower_id, uint8_t *rx_buffer, size_t rx_buffer_len, uint8_t *tx_buffer, size_t tx_buffer_len)
|
||||
{
|
||||
PIOS_Assert(com_id);
|
||||
PIOS_Assert(driver);
|
||||
|
@ -55,7 +55,7 @@ struct pios_com_driver {
|
||||
#define COM_CTRL_LINE_RTS_MASK 0x02
|
||||
|
||||
/* Public Functions */
|
||||
extern int32_t PIOS_COM_Init(uint32_t *com_id, const struct pios_com_driver *driver, uint32_t lower_id, uint8_t *rx_buffer, uint16_t rx_buffer_len, uint8_t *tx_buffer, uint16_t tx_buffer_len);
|
||||
extern int32_t PIOS_COM_Init(uint32_t *com_id, const struct pios_com_driver *driver, uint32_t lower_id, uint8_t *rx_buffer, size_t rx_buffer_len, uint8_t *tx_buffer, size_t tx_buffer_len);
|
||||
extern int32_t PIOS_COM_ChangeBaud(uint32_t com_id, uint32_t baud);
|
||||
extern int32_t PIOS_COM_SetCtrlLine(uint32_t com_id, uint32_t mask, uint32_t state);
|
||||
extern int32_t PIOS_COM_RegisterCtrlLineCallback(uint32_t usart_id, pios_com_callback_ctrl_line ctrl_line_cb, uint32_t context);
|
||||
|
@ -31,7 +31,6 @@
|
||||
#ifndef PIOS_COM_PRIV_H
|
||||
#define PIOS_COM_PRIV_H
|
||||
|
||||
extern int32_t PIOS_COM_Init(uint32_t *com_id, const struct pios_com_driver *driver, uint32_t lower_id, uint8_t *rx_buffer, uint16_t rx_buffer_len, uint8_t *tx_buffer, uint16_t tx_buffer_len);
|
||||
|
||||
#endif /* PIOS_COM_PRIV_H */
|
||||
|
||||
|
@ -101,9 +101,9 @@ uintptr_t pios_user_fs_id = 0;
|
||||
|
||||
/*
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes.
|
||||
* tx size of -1 make the port rx only
|
||||
* rx size of -1 make the port tx only
|
||||
* having both tx and rx size of -1 is not valid and will fail further down in PIOS_COM_Init()
|
||||
* tx size <= 0 make the port rx only
|
||||
* rx size <= 0 make the port tx only
|
||||
* having both tx and rx size <= 0 is not valid and will fail further down in PIOS_COM_Init()
|
||||
*/
|
||||
static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg, size_t rx_buf_len, size_t tx_buf_len,
|
||||
const struct pios_com_driver *com_driver, uint32_t *pios_com_id)
|
||||
@ -544,7 +544,7 @@ void PIOS_Board_Init(void)
|
||||
break;
|
||||
case HWSETTINGS_CC_MAINPORT_GPS:
|
||||
#if defined(PIOS_INCLUDE_GPS)
|
||||
PIOS_Board_configure_com(&pios_usart_generic_main_cfg, PIOS_COM_GPS_RX_BUF_LEN, -1, &pios_usart_com_driver, &pios_com_gps_id);
|
||||
PIOS_Board_configure_com(&pios_usart_generic_main_cfg, PIOS_COM_GPS_RX_BUF_LEN, 0, &pios_usart_com_driver, &pios_com_gps_id);
|
||||
#endif /* PIOS_INCLUDE_GPS */
|
||||
break;
|
||||
case HWSETTINGS_CC_MAINPORT_DSM:
|
||||
@ -556,7 +556,7 @@ void PIOS_Board_Init(void)
|
||||
case HWSETTINGS_CC_MAINPORT_DEBUGCONSOLE:
|
||||
#if defined(PIOS_INCLUDE_COM)
|
||||
#if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
|
||||
PIOS_Board_configure_com(&pios_usart_generic_main_cfg, -1, PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_debug_id);
|
||||
PIOS_Board_configure_com(&pios_usart_generic_main_cfg, 0, PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_debug_id);
|
||||
#endif /* PIOS_INCLUDE_DEBUG_CONSOLE */
|
||||
#endif /* PIOS_INCLUDE_COM */
|
||||
break;
|
||||
@ -570,7 +570,7 @@ void PIOS_Board_Init(void)
|
||||
PIOS_Board_configure_com(&pios_usart_generic_main_cfg, 0, PIOS_COM_MAVLINK_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_mavlink_id);
|
||||
break;
|
||||
case HWSETTINGS_CC_MAINPORT_OSDHK:
|
||||
PIOS_Board_configure_com(&pios_usart_hkosd_main_cfg, -1, PIOS_COM_HKOSD_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_hkosd_id);
|
||||
PIOS_Board_configure_com(&pios_usart_hkosd_main_cfg, 0, PIOS_COM_HKOSD_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_hkosd_id);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -597,7 +597,7 @@ void PIOS_Board_Init(void)
|
||||
break;
|
||||
case HWSETTINGS_CC_FLEXIPORT_GPS:
|
||||
#if defined(PIOS_INCLUDE_GPS)
|
||||
PIOS_Board_configure_com(&pios_usart_generic_flexi_cfg, PIOS_COM_GPS_RX_BUF_LEN, -1, &pios_usart_com_driver, &pios_com_gps_id);
|
||||
PIOS_Board_configure_com(&pios_usart_generic_flexi_cfg, PIOS_COM_GPS_RX_BUF_LEN, 0, &pios_usart_com_driver, &pios_com_gps_id);
|
||||
#endif /* PIOS_INCLUDE_GPS */
|
||||
break;
|
||||
case HWSETTINGS_CC_FLEXIPORT_PPM:
|
||||
@ -698,7 +698,7 @@ void PIOS_Board_Init(void)
|
||||
case HWSETTINGS_CC_FLEXIPORT_DEBUGCONSOLE:
|
||||
#if defined(PIOS_INCLUDE_COM)
|
||||
#if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
|
||||
PIOS_Board_configure_com(&pios_usart_generic_flexi_cfg, -1, PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_debug_id);
|
||||
PIOS_Board_configure_com(&pios_usart_generic_flexi_cfg, 0, PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_debug_id);
|
||||
#endif /* PIOS_INCLUDE_DEBUG_CONSOLE */
|
||||
#endif /* PIOS_INCLUDE_COM */
|
||||
break;
|
||||
@ -712,7 +712,7 @@ void PIOS_Board_Init(void)
|
||||
#endif /* PIOS_INCLUDE_I2C */
|
||||
break;
|
||||
case HWSETTINGS_CC_FLEXIPORT_OSDHK:
|
||||
PIOS_Board_configure_com(&pios_usart_hkosd_flexi_cfg, -1, PIOS_COM_HKOSD_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_hkosd_id);
|
||||
PIOS_Board_configure_com(&pios_usart_hkosd_flexi_cfg, 0, PIOS_COM_HKOSD_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_hkosd_id);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -279,9 +279,9 @@ uintptr_t pios_user_fs_id;
|
||||
|
||||
/*
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes.
|
||||
* tx size of -1 make the port rx only
|
||||
* rx size of -1 make the port tx only
|
||||
* having both tx and rx size of -1 is not valid and will fail further down in PIOS_COM_Init()
|
||||
* tx size <= 0 make the port rx only
|
||||
* rx size <= 0 make the port tx only
|
||||
* having both tx and rx size <= 0 is not valid and will fail further down in PIOS_COM_Init()
|
||||
*/
|
||||
static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg, size_t rx_buf_len, size_t tx_buf_len,
|
||||
const struct pios_com_driver *com_driver, uint32_t *pios_com_id)
|
||||
|
@ -286,9 +286,9 @@ uintptr_t pios_user_fs_id;
|
||||
|
||||
/*
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes.
|
||||
* tx size of -1 make the port rx only
|
||||
* rx size of -1 make the port tx only
|
||||
* having both tx and rx size of -1 is not valid and will fail further down in PIOS_COM_Init()
|
||||
* tx size <= 0 make the port rx only
|
||||
* rx size <= 0 make the port tx only
|
||||
* having both tx and rx size <= 0 is not valid and will fail further down in PIOS_COM_Init()
|
||||
*/
|
||||
static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg, size_t rx_buf_len, size_t tx_buf_len,
|
||||
const struct pios_com_driver *com_driver, uint32_t *pios_com_id)
|
||||
|
@ -233,9 +233,9 @@ uintptr_t pios_user_fs_id;
|
||||
|
||||
/*
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes.
|
||||
* tx size of -1 make the port rx only
|
||||
* rx size of -1 make the port tx only
|
||||
* having both tx and rx size of -1 is not valid and will fail further down in PIOS_COM_Init()
|
||||
* tx size <= 0 make the port rx only
|
||||
* rx size <= 0 make the port tx only
|
||||
* having both tx and rx size <= 0 is not valid and will fail further down in PIOS_COM_Init()
|
||||
*/
|
||||
static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg, size_t rx_buf_len, size_t tx_buf_len,
|
||||
const struct pios_com_driver *com_driver, uint32_t *pios_com_id)
|
||||
|
@ -348,7 +348,7 @@ uintptr_t pios_user_fs_id;
|
||||
uint32_t pios_com_vcp_id = 0;
|
||||
|
||||
/*
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes. tx size of -1 make the port rx only
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes. tx size <= 0 make the port rx only
|
||||
*/
|
||||
static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg, size_t rx_buf_len, size_t tx_buf_len,
|
||||
const struct pios_com_driver *com_driver, uint32_t *pios_com_id)
|
||||
@ -361,7 +361,7 @@ static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg
|
||||
|
||||
uint8_t *rx_buffer = (uint8_t *)pios_malloc(rx_buf_len);
|
||||
PIOS_Assert(rx_buffer);
|
||||
if (tx_buf_len != (size_t)-1) { // this is the case for rx/tx ports
|
||||
if (tx_buf_len > 0) { // this is the case for rx/tx ports
|
||||
uint8_t *tx_buffer = (uint8_t *)pios_malloc(tx_buf_len);
|
||||
PIOS_Assert(tx_buffer);
|
||||
|
||||
@ -690,7 +690,7 @@ void PIOS_Board_Init(void)
|
||||
break;
|
||||
|
||||
case HWSETTINGS_RV_GPSPORT_GPS:
|
||||
PIOS_Board_configure_com(&pios_usart_gps_cfg, PIOS_COM_GPS_RX_BUF_LEN, -1, &pios_usart_com_driver, &pios_com_gps_id);
|
||||
PIOS_Board_configure_com(&pios_usart_gps_cfg, PIOS_COM_GPS_RX_BUF_LEN, 0, &pios_usart_com_driver, &pios_com_gps_id);
|
||||
break;
|
||||
|
||||
case HWSETTINGS_RV_GPSPORT_COMAUX:
|
||||
|
@ -79,7 +79,7 @@ uintptr_t pios_uavo_settings_fs_id;
|
||||
uintptr_t pios_user_fs_id;
|
||||
|
||||
/*
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes. tx size of -1 make the port rx only
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes. tx size <= 0 make the port rx only
|
||||
*/
|
||||
static void PIOS_Board_configure_com(const struct pios_udp_cfg *usart_port_cfg, size_t rx_buf_len, size_t tx_buf_len,
|
||||
const struct pios_com_driver *com_driver, uint32_t *pios_com_id)
|
||||
@ -92,7 +92,7 @@ static void PIOS_Board_configure_com(const struct pios_udp_cfg *usart_port_cfg,
|
||||
|
||||
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(rx_buf_len);
|
||||
PIOS_Assert(rx_buffer);
|
||||
if (tx_buf_len != -1) { // this is the case for rx/tx ports
|
||||
if (tx_buf_len > 0) { // this is the case for rx/tx ports
|
||||
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(tx_buf_len);
|
||||
PIOS_Assert(tx_buffer);
|
||||
|
||||
|
@ -238,9 +238,9 @@ uintptr_t pios_user_fs_id;
|
||||
|
||||
/*
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes.
|
||||
* tx size of -1 make the port rx only
|
||||
* rx size of -1 make the port tx only
|
||||
* having both tx and rx size of -1 is not valid and will fail further down in PIOS_COM_Init()
|
||||
* tx size <= 0 make the port rx only
|
||||
* rx size <= 0 make the port tx only
|
||||
* having both tx and rx size <= 0 is not valid and will fail further down in PIOS_COM_Init()
|
||||
*/
|
||||
static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg, size_t rx_buf_len, size_t tx_buf_len,
|
||||
const struct pios_com_driver *com_driver, uint32_t *pios_com_id)
|
||||
|
Loading…
Reference in New Issue
Block a user