try to fix a bug Lorenz told me about
in fwrite
This commit is contained in:
2023-12-05 22:29:15 +01:00
parent 5fd8bb3044
commit a8537ba6d4
4 changed files with 24 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ int tftp_init(struct tftp_context* context) {
return 0;
}
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_display_text(const char* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT* font) {
UNUSED(color);
UNUSED(bg_color);
UNUSED(font);

View File

@@ -93,7 +93,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(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT *font);
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_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);

View File

@@ -74,4 +74,22 @@ TEST(TFTP, custom_fwrite) {
free(write_file.data);
write_file.data = NULL;
write_file.len = 0;
}
TEST(TFTP, custom_fread_fwrite_suggested_by_Lorentz) {
write_file.data = (char*)malloc(21 * sizeof(char));
write_file.len = 21;
write_file.offset = 0;
tftp_custom_fwrite("1234567890123456789", 19, &write_file);
tftp_custom_fwrite("0987654321", 10, &write_file);
EXPECT_EQ(write_file.offset, 20);
EXPECT_EQ(write_file.len, 21);
EXPECT_EQ(memcmp(write_file.data, "12345678901234567890", 20), 0);
free(write_file.data);
char buf[21];
file.offset = 9;
tftp_custom_fread(buf, 20, &file);
EXPECT_EQ(memcmp(buf, "0", 1), 0);
}