mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +01:00
com: remove all references to PIOS_COM_ReceiveBufferUsed()
The PIOS_COM_ReceiveBufferUsed() function call is no longer necessary since the same semantics can be achieved using calls to PIOS_COM_ReceiveBuffer().
This commit is contained in:
parent
b94f4b49a4
commit
481a13609e
@ -198,10 +198,8 @@ uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t processRX() {
|
uint8_t processRX() {
|
||||||
while (PIOS_COM_ReceiveBufferUsed(PIOS_COM_TELEM_USB) >= 63) {
|
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
||||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
processComand(mReceive_Buffer);
|
||||||
processComand(mReceive_Buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -249,10 +249,8 @@ uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count) {
|
|||||||
|
|
||||||
uint8_t processRX() {
|
uint8_t processRX() {
|
||||||
if (ProgPort == Usb) {
|
if (ProgPort == Usb) {
|
||||||
while (PIOS_COM_ReceiveBufferUsed(PIOS_COM_TELEM_USB) >= 63) {
|
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
||||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
processComand(mReceive_Buffer);
|
||||||
processComand(mReceive_Buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (ProgPort == Serial) {
|
} else if (ProgPort == Serial) {
|
||||||
|
|
||||||
@ -277,15 +275,12 @@ void SSP_CallBack(uint8_t *buf, uint16_t len) {
|
|||||||
fifoBuf_putData(&ssp_buffer, buf, len);
|
fifoBuf_putData(&ssp_buffer, buf, len);
|
||||||
}
|
}
|
||||||
int16_t SSP_SerialRead(void) {
|
int16_t SSP_SerialRead(void) {
|
||||||
if (PIOS_COM_ReceiveBufferUsed(PIOS_COM_TELEM_RF) > 0) {
|
uint8_t byte;
|
||||||
uint8_t byte;
|
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_RF, &byte, 1, 0) == 1) {
|
||||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_RF, &byte, 1, 0) == 1) {
|
return byte;
|
||||||
return byte;
|
} else {
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void SSP_SerialWrite(uint8_t value) {
|
void SSP_SerialWrite(uint8_t value) {
|
||||||
PIOS_COM_SendChar(PIOS_COM_TELEM_RF, value);
|
PIOS_COM_SendChar(PIOS_COM_TELEM_RF, value);
|
||||||
|
@ -204,10 +204,8 @@ uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t processRX() {
|
uint8_t processRX() {
|
||||||
while (PIOS_COM_ReceiveBufferUsed(PIOS_COM_TELEM_USB) >= 63) {
|
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
||||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
processComand(mReceive_Buffer);
|
||||||
processComand(mReceive_Buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -511,24 +511,6 @@ uint16_t PIOS_COM_ReceiveBuffer(uint32_t com_id, uint8_t * buf, uint16_t buf_len
|
|||||||
return (bytes_from_fifo);
|
return (bytes_from_fifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of bytes waiting in the buffer
|
|
||||||
* \param[in] port COM port
|
|
||||||
* \return Number of bytes used in buffer
|
|
||||||
*/
|
|
||||||
int32_t PIOS_COM_ReceiveBufferUsed(uint32_t com_id)
|
|
||||||
{
|
|
||||||
struct pios_com_dev * com_dev = (struct pios_com_dev *)com_id;
|
|
||||||
|
|
||||||
if (!PIOS_COM_validate(com_dev)) {
|
|
||||||
/* Undefined COM port for this board (see pios_board.c) */
|
|
||||||
PIOS_Assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
PIOS_Assert(com_dev->has_rx);
|
|
||||||
return (fifoBuf_getUsed(&com_dev->rx));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,6 @@ extern int32_t PIOS_COM_SendString(uint32_t com_id, const char *str);
|
|||||||
extern int32_t PIOS_COM_SendFormattedStringNonBlocking(uint32_t com_id, const char *format, ...);
|
extern int32_t PIOS_COM_SendFormattedStringNonBlocking(uint32_t com_id, const char *format, ...);
|
||||||
extern int32_t PIOS_COM_SendFormattedString(uint32_t com_id, const char *format, ...);
|
extern int32_t PIOS_COM_SendFormattedString(uint32_t com_id, const char *format, ...);
|
||||||
extern uint16_t PIOS_COM_ReceiveBuffer(uint32_t com_id, uint8_t * buf, uint16_t buf_len, uint32_t timeout_ms);
|
extern uint16_t PIOS_COM_ReceiveBuffer(uint32_t com_id, uint8_t * buf, uint16_t buf_len, uint32_t timeout_ms);
|
||||||
extern int32_t PIOS_COM_ReceiveBufferUsed(uint32_t com_id);
|
|
||||||
|
|
||||||
#endif /* PIOS_COM_H */
|
#endif /* PIOS_COM_H */
|
||||||
|
|
||||||
|
@ -792,13 +792,8 @@ void apiconfig_process(void)
|
|||||||
else
|
else
|
||||||
if (apiconfig_usb_comms)
|
if (apiconfig_usb_comms)
|
||||||
{ // we're using the USB for comms - keep the USART rx buffer empty
|
{ // we're using the USB for comms - keep the USART rx buffer empty
|
||||||
int32_t bytes = PIOS_COM_ReceiveBufferUsed(PIOS_COM_SERIAL);
|
uint8_t c;
|
||||||
while (bytes > 0)
|
while (PIOS_COM_ReceiveBuffer(PIOS_COM_SERIAL, &c, 1, 0) > 0);
|
||||||
{
|
|
||||||
uint8_t c;
|
|
||||||
PIOS_COM_ReceiveBuffer(PIOS_COM_SERIAL, &c, 1, 0);
|
|
||||||
bytes--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
apiconfig_previous_com_port = apiconfig_comm_port; // remember the current comm-port we are using
|
apiconfig_previous_com_port = apiconfig_comm_port; // remember the current comm-port we are using
|
||||||
|
|
||||||
@ -808,20 +803,9 @@ void apiconfig_process(void)
|
|||||||
// fetch the data received via the comm-port
|
// fetch the data received via the comm-port
|
||||||
|
|
||||||
// get the number of data bytes received down the comm-port
|
// get the number of data bytes received down the comm-port
|
||||||
int32_t com_num = PIOS_COM_ReceiveBufferUsed(apiconfig_comm_port);
|
uint16_t buf_avail = sizeof(apiconfig_rx_buffer) - apiconfig_rx_buffer_wr;
|
||||||
|
|
||||||
// limit number of bytes we will get to how much space we have in our RX buffer
|
PIOS_COM_ReceiveBuffer(apiconfig_comm_port, &(apiconfig_rx_buffer[apiconfig_rx_buffer_wr]), buf_avail, 0);
|
||||||
if (com_num > sizeof(apiconfig_rx_buffer) - apiconfig_rx_buffer_wr)
|
|
||||||
com_num = sizeof(apiconfig_rx_buffer) - apiconfig_rx_buffer_wr;
|
|
||||||
|
|
||||||
|
|
||||||
while (com_num > 0)
|
|
||||||
{ // fetch a byte from the comm-port RX buffer and save it into our RX buffer
|
|
||||||
uint8_t c;
|
|
||||||
PIOS_COM_ReceiveBuffer(apiconfig_comm_port, &c, 1, 0);
|
|
||||||
apiconfig_rx_buffer[apiconfig_rx_buffer_wr++] = c;
|
|
||||||
com_num--;
|
|
||||||
}
|
|
||||||
|
|
||||||
apiconfig_processTx();
|
apiconfig_processTx();
|
||||||
apiconfig_processRx();
|
apiconfig_processRx();
|
||||||
|
@ -89,13 +89,8 @@ void trans_process(void)
|
|||||||
else
|
else
|
||||||
if (usb_comms)
|
if (usb_comms)
|
||||||
{ // we're using the USB for comms - keep the USART rx buffer empty
|
{ // we're using the USB for comms - keep the USART rx buffer empty
|
||||||
int32_t bytes = PIOS_COM_ReceiveBufferUsed(PIOS_COM_SERIAL);
|
uint8_t c;
|
||||||
while (bytes > 0)
|
while (PIOS_COM_ReceiveBuffer(PIOS_COM_SERIAL, &c, 1, 0) > 0);
|
||||||
{
|
|
||||||
uint8_t c;
|
|
||||||
PIOS_COM_ReceiveBuffer(PIOS_COM_SERIAL, &c, 1, 0);
|
|
||||||
bytes--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trans_previous_com_port = comm_port; // remember the current comm-port we are using
|
trans_previous_com_port = comm_port; // remember the current comm-port we are using
|
||||||
@ -112,9 +107,6 @@ void trans_process(void)
|
|||||||
// free space size in the RF packet handler tx buffer
|
// free space size in the RF packet handler tx buffer
|
||||||
uint16_t ph_num = ph_putData_free(connection_index);
|
uint16_t ph_num = ph_putData_free(connection_index);
|
||||||
|
|
||||||
// get the number of data bytes received down the comm-port
|
|
||||||
int32_t com_num = PIOS_COM_ReceiveBufferUsed(comm_port);
|
|
||||||
|
|
||||||
// set the USART RTS handshaking line
|
// set the USART RTS handshaking line
|
||||||
if (!usb_comms)
|
if (!usb_comms)
|
||||||
{
|
{
|
||||||
@ -127,16 +119,12 @@ void trans_process(void)
|
|||||||
SERIAL_RTS_SET; // release the USART RTS line
|
SERIAL_RTS_SET; // release the USART RTS line
|
||||||
|
|
||||||
// limit number of bytes we will get to the size of the temp buffer
|
// limit number of bytes we will get to the size of the temp buffer
|
||||||
if (com_num > sizeof(trans_temp_buffer1))
|
if (ph_num > sizeof(trans_temp_buffer1))
|
||||||
com_num = sizeof(trans_temp_buffer1);
|
ph_num = sizeof(trans_temp_buffer1);
|
||||||
|
|
||||||
// limit number of bytes we will get to the size of the free space in the RF packet handler TX buffer
|
|
||||||
if (com_num > ph_num)
|
|
||||||
com_num = ph_num;
|
|
||||||
|
|
||||||
// copy data received down the comm-port into our temp buffer
|
// copy data received down the comm-port into our temp buffer
|
||||||
register uint16_t bytes_saved = 0;
|
register uint16_t bytes_saved = 0;
|
||||||
bytes_saved = PIOS_COM_ReceiveBuffer(comm_port, trans_temp_buffer1, com_num, 0);
|
bytes_saved = PIOS_COM_ReceiveBuffer(comm_port, trans_temp_buffer1, ph_num, 0);
|
||||||
|
|
||||||
// put the received comm-port data bytes into the RF packet handler TX buffer
|
// put the received comm-port data bytes into the RF packet handler TX buffer
|
||||||
if (bytes_saved > 0)
|
if (bytes_saved > 0)
|
||||||
@ -147,12 +135,8 @@ void trans_process(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // empty the comm-ports rx buffer
|
{ // empty the comm-ports rx buffer
|
||||||
int32_t com_num = PIOS_COM_ReceiveBufferUsed(comm_port);
|
uint8_t c;
|
||||||
while (com_num > 0) {
|
while (PIOS_COM_ReceiveBuffer(comm_port, &c, 1, 0) > 0);
|
||||||
uint8_t c;
|
|
||||||
PIOS_COM_ReceiveBuffer(comm_port, &c, 1, 0);
|
|
||||||
com_num--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ********************
|
// ********************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user