mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 16:42:47 +08:00
[udp] fix put_buffer for UDP devices
udp_send_raw doesn't add to the "normal" transmit buffer, but rather directly send the whole buffer passed to it. But put_buffer is supposted to multiple bytes to the current transmit buffer where a message is being assembled, so actually do that in a udp_put_buffer function.
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "mcu_periph/udp.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Print the configurations */
|
||||
#if USE_UDP0
|
||||
struct udp_periph udp0;
|
||||
@@ -63,7 +65,7 @@ void udp_periph_init(struct udp_periph *p, char *host, int port_out, int port_in
|
||||
p->device.periph = (void *)p;
|
||||
p->device.check_free_space = (check_free_space_t) udp_check_free_space;
|
||||
p->device.put_byte = (put_byte_t) udp_put_byte;
|
||||
p->device.put_buffer = (put_buffer_t) udp_send_raw;
|
||||
p->device.put_buffer = (put_buffer_t) udp_put_buffer;
|
||||
p->device.send_message = (send_message_t) udp_send_message;
|
||||
p->device.char_available = (char_available_t) udp_char_available;
|
||||
p->device.get_byte = (get_byte_t) udp_getch;
|
||||
@@ -98,3 +100,12 @@ void WEAK udp_put_byte(struct udp_periph *p, long fd __attribute__((unused)), ui
|
||||
p->tx_insert_idx++;
|
||||
}
|
||||
|
||||
void WEAK udp_put_buffer(struct udp_periph *p, long fd __attribute__((unused)), const uint8_t *data, uint16_t len)
|
||||
{
|
||||
if (p->tx_insert_idx + len >= UDP_TX_BUFFER_SIZE) {
|
||||
return; // no room
|
||||
}
|
||||
|
||||
memcpy(&(p->tx_buf[p->tx_insert_idx]), data, len);
|
||||
p->tx_insert_idx += len;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ extern void udp_arch_periph_init(struct udp_periph *p, char *host, int port_
|
||||
extern void udp_send_message(struct udp_periph *p, long fd);
|
||||
extern void udp_send_raw(struct udp_periph *p, long fd, uint8_t *buffer, uint16_t size);
|
||||
extern void udp_receive(struct udp_periph *p);
|
||||
extern void udp_put_buffer(struct udp_periph *p, long fd, const uint8_t *data, uint16_t len);
|
||||
|
||||
#if USE_UDP0
|
||||
extern struct udp_periph udp0;
|
||||
|
||||
Reference in New Issue
Block a user