mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +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() {
|
||||
while (PIOS_COM_ReceiveBufferUsed(PIOS_COM_TELEM_USB) >= 63) {
|
||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
||||
processComand(mReceive_Buffer);
|
||||
}
|
||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
||||
processComand(mReceive_Buffer);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -249,10 +249,8 @@ uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count) {
|
||||
|
||||
uint8_t processRX() {
|
||||
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) {
|
||||
processComand(mReceive_Buffer);
|
||||
}
|
||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
||||
processComand(mReceive_Buffer);
|
||||
}
|
||||
} else if (ProgPort == Serial) {
|
||||
|
||||
@ -277,15 +275,12 @@ void SSP_CallBack(uint8_t *buf, uint16_t len) {
|
||||
fifoBuf_putData(&ssp_buffer, buf, len);
|
||||
}
|
||||
int16_t SSP_SerialRead(void) {
|
||||
if (PIOS_COM_ReceiveBufferUsed(PIOS_COM_TELEM_RF) > 0) {
|
||||
uint8_t byte;
|
||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_RF, &byte, 1, 0) == 1) {
|
||||
return byte;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
uint8_t byte;
|
||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_RF, &byte, 1, 0) == 1) {
|
||||
return byte;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
void SSP_SerialWrite(uint8_t 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() {
|
||||
while (PIOS_COM_ReceiveBufferUsed(PIOS_COM_TELEM_USB) >= 63) {
|
||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
||||
processComand(mReceive_Buffer);
|
||||
}
|
||||
if (PIOS_COM_ReceiveBuffer(PIOS_COM_TELEM_USB, mReceive_Buffer, 63, 0) == 63) {
|
||||
processComand(mReceive_Buffer);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
/**
|
||||
|
@ -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_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 int32_t PIOS_COM_ReceiveBufferUsed(uint32_t com_id);
|
||||
|
||||
#endif /* PIOS_COM_H */
|
||||
|
||||
|
@ -792,13 +792,8 @@ void apiconfig_process(void)
|
||||
else
|
||||
if (apiconfig_usb_comms)
|
||||
{ // we're using the USB for comms - keep the USART rx buffer empty
|
||||
int32_t bytes = PIOS_COM_ReceiveBufferUsed(PIOS_COM_SERIAL);
|
||||
while (bytes > 0)
|
||||
{
|
||||
uint8_t c;
|
||||
PIOS_COM_ReceiveBuffer(PIOS_COM_SERIAL, &c, 1, 0);
|
||||
bytes--;
|
||||
}
|
||||
uint8_t c;
|
||||
while (PIOS_COM_ReceiveBuffer(PIOS_COM_SERIAL, &c, 1, 0) > 0);
|
||||
}
|
||||
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
|
||||
|
||||
// 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
|
||||
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--;
|
||||
}
|
||||
PIOS_COM_ReceiveBuffer(apiconfig_comm_port, &(apiconfig_rx_buffer[apiconfig_rx_buffer_wr]), buf_avail, 0);
|
||||
|
||||
apiconfig_processTx();
|
||||
apiconfig_processRx();
|
||||
|
@ -89,13 +89,8 @@ void trans_process(void)
|
||||
else
|
||||
if (usb_comms)
|
||||
{ // we're using the USB for comms - keep the USART rx buffer empty
|
||||
int32_t bytes = PIOS_COM_ReceiveBufferUsed(PIOS_COM_SERIAL);
|
||||
while (bytes > 0)
|
||||
{
|
||||
uint8_t c;
|
||||
PIOS_COM_ReceiveBuffer(PIOS_COM_SERIAL, &c, 1, 0);
|
||||
bytes--;
|
||||
}
|
||||
uint8_t c;
|
||||
while (PIOS_COM_ReceiveBuffer(PIOS_COM_SERIAL, &c, 1, 0) > 0);
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
if (!usb_comms)
|
||||
{
|
||||
@ -127,16 +119,12 @@ void trans_process(void)
|
||||
SERIAL_RTS_SET; // release the USART RTS line
|
||||
|
||||
// limit number of bytes we will get to the size of the temp buffer
|
||||
if (com_num > sizeof(trans_temp_buffer1))
|
||||
com_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;
|
||||
if (ph_num > sizeof(trans_temp_buffer1))
|
||||
ph_num = sizeof(trans_temp_buffer1);
|
||||
|
||||
// copy data received down the comm-port into our temp buffer
|
||||
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
|
||||
if (bytes_saved > 0)
|
||||
@ -147,12 +135,8 @@ void trans_process(void)
|
||||
}
|
||||
else
|
||||
{ // empty the comm-ports rx buffer
|
||||
int32_t com_num = PIOS_COM_ReceiveBufferUsed(comm_port);
|
||||
while (com_num > 0) {
|
||||
uint8_t c;
|
||||
PIOS_COM_ReceiveBuffer(comm_port, &c, 1, 0);
|
||||
com_num--;
|
||||
}
|
||||
uint8_t c;
|
||||
while (PIOS_COM_ReceiveBuffer(comm_port, &c, 1, 0) > 0);
|
||||
}
|
||||
|
||||
// ********************
|
||||
|
Loading…
Reference in New Issue
Block a user