@@ -72,7 +72,9 @@ void tx_task(void *arg)
72
72
{
73
73
for (;;)
74
74
{
75
- proto.run_tx ( 100 );
75
+ uint8_t tx_buf[4 ];
76
+ int len = proto.run_tx ( tx_buf, sizeof tx_buf );
77
+ uart_write_bytes (UART_NUM_1, (const char *)buffer, len);
76
78
}
77
79
vTaskDelete ( NULL );
78
80
}
@@ -97,24 +99,29 @@ void main_task(void *args)
97
99
/* Lets process all incoming frames */
98
100
proto.setReceiveCallback ( onReceive );
99
101
/* Redirect all protocol communication to Serial0 UART */
100
- #if defined(TINY_MULTITHREAD)
101
- proto.begin ([](void *p, const void *b, int s)->int { return uart_write_bytes (UART_NUM_1, (const char *)b, s); },
102
- [](void *p, void *b, int s)->int { return uart_read_bytes (UART_NUM_1, (uint8_t *)b, s, 10 ); });
103
- #else
104
- proto.begin ([](void *p, const void *b, int s)->int { return uart_tx_chars (UART_NUM_1, (const char *)b, s); },
105
- [](void *p, void *b, int s)->int { return uart_read_bytes (UART_NUM_1, (uint8_t *)b, s, 0 ); });
106
- #endif
102
+ proto.begin ();
107
103
108
104
#if defined(TINY_MULTITHREAD)
109
105
xTaskCreate ( tx_task, " tx_task" , 2096 , NULL , 1 , NULL );
110
106
#endif
111
107
for (;;)
112
108
{
113
109
#if defined(TINY_MULTITHREAD)
114
- proto.run_rx (100 );
110
+ uint8_t rx_buf[4 ];
111
+ int rx_len = uart_read_bytes (UART_NUM_1, (uint8_t *)rx_buf, sizeof rx_buf, 10 );
112
+ proto.run_rx ( rx_buf, rx_len );
115
113
#else
116
- proto.run_rx ();
117
- proto.run_tx ();
114
+ uint8_t rx_buf[4 ];
115
+ int rx_len = uart_read_bytes (UART_NUM_1, (uint8_t *)rx_buf, sizeof rx_buf, 0 );
116
+ proto.run_rx ( rx_buf, rx_len );
117
+
118
+ uint8_t tx_buf[4 ];
119
+ int tx_len = proto.run_tx ( tx_buf, sizeof tx_buf );
120
+ int sent = 0 ;
121
+ while ( sent < tx_len )
122
+ {
123
+ sent += uart_tx_chars (UART_NUM_1, (const char *)tx_buf + sent, tx_len - sent);
124
+ }
118
125
#endif
119
126
}
120
127
vTaskDelete ( NULL );
0 commit comments