mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
com: mark tx buffer as const throughout API
The com layer transmit functions should provide guarantees that they will not modify the buffer that you're transmitting. Declaring the parameter as a pointer to const keeps the underlying implementations honest. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1001 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
1cc6981ee5
commit
71e491e3c1
@ -102,7 +102,7 @@ int32_t PIOS_COM_ChangeBaud(uint8_t port, uint32_t baud)
|
||||
* caller should retry until buffer is free again
|
||||
* \return 0 on success
|
||||
*/
|
||||
int32_t PIOS_COM_SendBufferNonBlocking(uint8_t port, uint8_t *buffer, uint16_t len)
|
||||
int32_t PIOS_COM_SendBufferNonBlocking(uint8_t port, const uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
struct pios_com_dev * com_dev;
|
||||
|
||||
@ -130,7 +130,7 @@ int32_t PIOS_COM_SendBufferNonBlocking(uint8_t port, uint8_t *buffer, uint16_t l
|
||||
* \return -1 if port not available
|
||||
* \return 0 on success
|
||||
*/
|
||||
int32_t PIOS_COM_SendBuffer(uint8_t port, uint8_t *buffer, uint16_t len)
|
||||
int32_t PIOS_COM_SendBuffer(uint8_t port, const uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
struct pios_com_dev * com_dev;
|
||||
|
||||
@ -185,7 +185,7 @@ int32_t PIOS_COM_SendChar(uint8_t port, char c)
|
||||
* caller should retry until buffer is free again
|
||||
* \return 0 on success
|
||||
*/
|
||||
int32_t PIOS_COM_SendStringNonBlocking(uint8_t port, char *str)
|
||||
int32_t PIOS_COM_SendStringNonBlocking(uint8_t port, const char *str)
|
||||
{
|
||||
return PIOS_COM_SendBufferNonBlocking(port, (uint8_t *)str, (uint16_t)strlen(str));
|
||||
}
|
||||
@ -198,7 +198,7 @@ int32_t PIOS_COM_SendStringNonBlocking(uint8_t port, char *str)
|
||||
* \return -1 if port not available
|
||||
* \return 0 on success
|
||||
*/
|
||||
int32_t PIOS_COM_SendString(uint8_t port, char *str)
|
||||
int32_t PIOS_COM_SendString(uint8_t port, const char *str)
|
||||
{
|
||||
return PIOS_COM_SendBuffer(port, (uint8_t *)str, strlen(str));
|
||||
}
|
||||
@ -213,7 +213,7 @@ int32_t PIOS_COM_SendString(uint8_t port, char *str)
|
||||
* caller should retry until buffer is free again
|
||||
* \return 0 on success
|
||||
*/
|
||||
int32_t PIOS_COM_SendFormattedStringNonBlocking(uint8_t port, char *format, ...)
|
||||
int32_t PIOS_COM_SendFormattedStringNonBlocking(uint8_t port, const char *format, ...)
|
||||
{
|
||||
uint8_t buffer[128]; // TODO: tmp!!! Provide a streamed COM method later!
|
||||
|
||||
@ -233,7 +233,7 @@ int32_t PIOS_COM_SendFormattedStringNonBlocking(uint8_t port, char *format, ...)
|
||||
* \return -1 if port not available
|
||||
* \return 0 on success
|
||||
*/
|
||||
int32_t PIOS_COM_SendFormattedString(uint8_t port, char *format, ...)
|
||||
int32_t PIOS_COM_SendFormattedString(uint8_t port, const char *format, ...)
|
||||
{
|
||||
uint8_t buffer[128]; // TODO: tmp!!! Provide a streamed COM method later!
|
||||
va_list args;
|
||||
|
@ -385,7 +385,7 @@ int32_t PIOS_USART_TxBufferGet(uint8_t usart)
|
||||
* \return -3 if USART not supported by USARTTxBufferPut Routine
|
||||
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
|
||||
*/
|
||||
int32_t PIOS_USART_TxBufferPutMoreNonBlocking(uint8_t usart, uint8_t *buffer, uint16_t len)
|
||||
int32_t PIOS_USART_TxBufferPutMoreNonBlocking(uint8_t usart, const uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
struct pios_usart_dev * usart_dev;
|
||||
|
||||
@ -437,7 +437,7 @@ int32_t PIOS_USART_TxBufferPutMoreNonBlocking(uint8_t usart, uint8_t *buffer, ui
|
||||
* \return -3 if USART not supported by USARTTxBufferPut Routine
|
||||
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
|
||||
*/
|
||||
int32_t PIOS_USART_TxBufferPutMore(uint8_t usart, uint8_t *buffer, uint16_t len)
|
||||
int32_t PIOS_USART_TxBufferPutMore(uint8_t usart, const uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
int32_t rc;
|
||||
|
||||
|
@ -146,7 +146,7 @@ int32_t PIOS_USB_HID_CheckAvailable(uint8_t id)
|
||||
* \return -1 if too many bytes to be send
|
||||
* \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions
|
||||
*/
|
||||
int32_t PIOS_USB_HID_TxBufferPutMoreNonBlocking(uint8_t id, uint8_t *buffer, uint16_t len)
|
||||
int32_t PIOS_USB_HID_TxBufferPutMoreNonBlocking(uint8_t id, const uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
if(len > PIOS_USB_HID_DATA_LENGTH) {
|
||||
/* Cannot send all requested bytes */
|
||||
@ -173,7 +173,7 @@ int32_t PIOS_USB_HID_TxBufferPutMoreNonBlocking(uint8_t id, uint8_t *buffer, uin
|
||||
* \return -1 if too many bytes to be send
|
||||
* \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions
|
||||
*/
|
||||
int32_t PIOS_USB_HID_TxBufferPutMore(uint8_t id, uint8_t *buffer, uint16_t len)
|
||||
int32_t PIOS_USB_HID_TxBufferPutMore(uint8_t id, const uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
int32_t error;
|
||||
|
||||
|
@ -32,12 +32,12 @@ extern int32_t PIOS_COM_Init(void);
|
||||
extern int32_t PIOS_COM_ChangeBaud(uint8_t port, uint32_t baud);
|
||||
extern int32_t PIOS_COM_SendCharNonBlocking(uint8_t port, char c);
|
||||
extern int32_t PIOS_COM_SendChar(uint8_t port, char c);
|
||||
extern int32_t PIOS_COM_SendBufferNonBlocking(uint8_t port, uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_COM_SendBuffer(uint8_t port, uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_COM_SendStringNonBlocking(uint8_t port, char *str);
|
||||
extern int32_t PIOS_COM_SendString(uint8_t port, char *str);
|
||||
extern int32_t PIOS_COM_SendFormattedStringNonBlocking(uint8_t port, char *format, ...);
|
||||
extern int32_t PIOS_COM_SendFormattedString(uint8_t port, char *format, ...);
|
||||
extern int32_t PIOS_COM_SendBufferNonBlocking(uint8_t port, const uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_COM_SendBuffer(uint8_t port, const uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_COM_SendStringNonBlocking(uint8_t port, const char *str);
|
||||
extern int32_t PIOS_COM_SendString(uint8_t port, const char *str);
|
||||
extern int32_t PIOS_COM_SendFormattedStringNonBlocking(uint8_t port, const char *format, ...);
|
||||
extern int32_t PIOS_COM_SendFormattedString(uint8_t port, const char *format, ...);
|
||||
extern uint8_t PIOS_COM_ReceiveBuffer(uint8_t port);
|
||||
extern int32_t PIOS_COM_ReceiveBufferUsed(uint8_t port);
|
||||
|
||||
@ -46,8 +46,8 @@ extern int32_t PIOS_COM_ReceiveHandler(void);
|
||||
struct pios_com_driver {
|
||||
void (*init)(uint8_t id);
|
||||
void (*set_baud)(uint8_t id, uint32_t baud);
|
||||
int32_t (*tx_nb)(uint8_t id, uint8_t *buffer, uint16_t len);
|
||||
int32_t (*tx)(uint8_t id, uint8_t *buffer, uint16_t len);
|
||||
int32_t (*tx_nb)(uint8_t id, const uint8_t *buffer, uint16_t len);
|
||||
int32_t (*tx)(uint8_t id, const uint8_t *buffer, uint16_t len);
|
||||
int32_t (*rx)(uint8_t id);
|
||||
int32_t (*rx_avail)(uint8_t id);
|
||||
};
|
||||
|
@ -42,8 +42,8 @@ extern int32_t PIOS_USART_RxBufferPut(uint8_t usart, uint8_t b);
|
||||
|
||||
extern int32_t PIOS_USART_TxBufferFree(uint8_t usart);
|
||||
extern int32_t PIOS_USART_TxBufferGet(uint8_t usart);
|
||||
extern int32_t PIOS_USART_TxBufferPutMoreNonBlocking(uint8_t usart, uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_USART_TxBufferPutMore(uint8_t usart, uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_USART_TxBufferPutMoreNonBlocking(uint8_t usart, const uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_USART_TxBufferPutMore(uint8_t usart, const uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_USART_TxBufferPutNonBlocking(uint8_t usart, uint8_t b);
|
||||
extern int32_t PIOS_USART_TxBufferPut(uint8_t usart, uint8_t b);
|
||||
|
||||
|
@ -40,8 +40,8 @@
|
||||
extern int32_t PIOS_USB_HID_Init(uint32_t mode);
|
||||
extern int32_t PIOS_USB_HID_ChangeConnectionState(uint32_t Connected);
|
||||
extern int32_t PIOS_USB_HID_CheckAvailable(uint8_t id);
|
||||
extern int32_t PIOS_USB_HID_TxBufferPutMoreNonBlocking(uint8_t id, uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_USB_HID_TxBufferPutMore(uint8_t id, uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_USB_HID_TxBufferPutMoreNonBlocking(uint8_t id, const uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_USB_HID_TxBufferPutMore(uint8_t id, const uint8_t *buffer, uint16_t len);
|
||||
extern int32_t PIOS_USB_HID_RxBufferGet(uint8_t id);
|
||||
extern int32_t PIOS_USB_HID_RxBufferUsed(uint8_t id);
|
||||
extern int32_t PIOS_USB_HID_CB_Data_Setup(uint8_t RequestNo);
|
||||
|
Loading…
x
Reference in New Issue
Block a user