tcp_cmd
add pbuf_copy_partial moc so I don't need if TESTING preprocessor directive
This commit is contained in:
@@ -149,3 +149,8 @@ size_t tcp_sndbuf(void* pcb) {
|
||||
void pbuf_free(struct pbuf* p) {
|
||||
UNUSED(p);
|
||||
}
|
||||
|
||||
uint16_t pbuf_copy_partial(const struct pbuf* buf, void* dataptr, uint16_t len, uint16_t offset) {
|
||||
memcpy(dataptr, ((uint8_t*)(buf->payload)) + offset, len);
|
||||
return len;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ typedef err_t (*tcp_accept_fn)(void* arg, struct tcp_pcb* newpcb, err_t err);
|
||||
|
||||
uint32_t logger_get_timestamp(void);
|
||||
|
||||
void lcd_display_text(const char* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT* font);
|
||||
void lcd_display_text(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT* font);
|
||||
void lcd_draw_img_from_fs(char* filename, uint32_t x_pos, uint32_t y_pos);
|
||||
void lcd_draw_gif_from_fs(char* filename, uint32_t x_pos, uint32_t y_pos);
|
||||
void lcd_draw_bmp_img(uint8_t* bmp_buff, uint32_t x_pos, uint32_t y_pos);
|
||||
@@ -129,6 +129,8 @@ void pbuf_free(struct pbuf* p);
|
||||
|
||||
size_t tcp_sndbuf(void* pcb);
|
||||
|
||||
uint16_t pbuf_copy_partial(const struct pbuf* buf, void* dataptr, uint16_t len, uint16_t offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -209,11 +209,8 @@ static err_t tcp_cmd_recv_new(void* arg, struct tcp_pcb* pcb, struct pbuf* p, er
|
||||
LOG_WARN(TAG, "Command too long");
|
||||
}
|
||||
size_t len = p->tot_len >= MAX_CMD_LEN ? MAX_CMD_LEN : p->tot_len;
|
||||
#if TESTING
|
||||
memcpy(cmd, p->payload, len);
|
||||
#else
|
||||
|
||||
pbuf_copy_partial(p, cmd, len, 0);
|
||||
#endif
|
||||
cmd[len] = '\0';
|
||||
|
||||
remove_newline(cmd);
|
||||
|
||||
Reference in New Issue
Block a user