Skip to content

Commit 8be0c3b

Browse files
uart cosmetic fixes
* fx * tttttttttttttttt * dis
1 parent f2c87bf commit 8be0c3b

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

src/driver/drv_main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,22 +566,23 @@ static driver_t g_drivers[] = {
566566
//drvdetail:"title":"TODO",
567567
//drvdetail:"descr":"A bridge relay driver, added for [TONGOU TO-Q-SY1-JWT Din Rail Switch](https://www.elektroda.com/rtvforum/topic3934580.html). See linked topic for info.",
568568
//drvdetail:"requires":""}
569-
{ "Bridge", Bridge_driver_Init, NULL, NULL, Bridge_driver_QuickFrame, Bridge_driver_DeInit, Bridge_driver_OnChannelChanged, NULL, false }
569+
{ "Bridge", Bridge_driver_Init, NULL, NULL, Bridge_driver_QuickFrame, Bridge_driver_DeInit, Bridge_driver_OnChannelChanged, NULL, false },
570570
#endif
571571
#if ENABLE_DRIVER_UART_TCP
572572
//drvdetail:{"name":"UartTCP",
573573
//drvdetail:"title":"TODO",
574574
//drvdetail:"descr":"UART to TCP bridge, mainly for WiFi Zigbee coordinators.",
575575
//drvdetail:"requires":""}
576-
{ "UartTCP", UART_TCP_Init, NULL, NULL, NULL, UART_TCP_Deinit, NULL, NULL, false }
576+
{ "UartTCP", UART_TCP_Init, NULL, NULL, NULL, UART_TCP_Deinit, NULL, NULL, false },
577577
#endif
578578
#if PLATFORM_TXW81X
579579
//drvdetail:{"name":"TXWCAM",
580580
//drvdetail:"title":"TODO",
581581
//drvdetail:"descr":"TXW81X Camera.",
582582
//drvdetail:"requires":""}
583-
{ "TXWCAM", TXW_Cam_Init, TXW_Cam_RunEverySecond, NULL, NULL, NULL, NULL, NULL, false }
583+
{ "TXWCAM", TXW_Cam_Init, TXW_Cam_RunEverySecond, NULL, NULL, NULL, NULL, NULL, false },
584584
#endif
585+
//{ "", NULL, NULL, NULL, NULL, NULL, NULL, NULL, false },
585586
};
586587

587588

src/driver/drv_uart.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -272,30 +272,28 @@ void UART_LogBufState(int auartindex) {
272272
);
273273
}
274274
void UART_DebugTool_Run(int auartindex) {
275-
byte b;
276-
char tmp[128];
277-
char *p = tmp;
278-
int i;
275+
byte b;
276+
char tmp[128];
277+
char *p = tmp;
279278
int bytes = 0;
280279

281-
for (i = 0; i < sizeof(tmp) - 4; i++) {
282-
if (UART_GetDataSizeEx(auartindex)==0) {
283-
break;
284-
}
285-
b = UART_GetByteEx(auartindex,0);
286-
if (i) {
287-
*p = ' ';
288-
p++;
289-
}
280+
while (UART_GetDataSizeEx(auartindex) > 0) {
281+
b = UART_GetByteEx(auartindex, 0);
282+
283+
int needed = (bytes ? 3 : 2); // 2 for first byte, 3 (space + 2 hex) after
284+
if ((p - tmp) + needed >= sizeof(tmp) - 1) break;
285+
286+
if (bytes) *p++ = ' ';
287+
sprintf(p, "%02X", b);
288+
p += 2;
289+
UART_ConsumeBytesEx(auartindex, 1);
290290
bytes++;
291-
sprintf(p, "%02X", b);
292-
p += 2;
293-
UART_ConsumeBytesEx(auartindex,1);
294-
}
295-
*p = 0;
291+
}
292+
293+
*p = 0;
296294
if (bytes) {
297-
addLogAdv(LOG_INFO, LOG_FEATURE_CMD, "UART %i received %i bytes: %s\n",
298-
auartindex, bytes, tmp);
295+
addLogAdv(LOG_INFO, LOG_FEATURE_CMD,
296+
"UART %i received %i bytes: %s\n", auartindex, bytes, tmp);
299297
}
300298
}
301299

@@ -307,6 +305,7 @@ void UART_RunEverySecond() {
307305
}
308306
}
309307
// uartInit 115200
308+
// uartSendASCII Hello123
310309
commandResult_t CMD_UART_Init(const void *context, const char *cmd, const char *args, int cmdFlags) {
311310
int baud;
312311

src/obk_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@
234234
//#define ENABLE_LFS_SPI 1
235235
//#define ENABLE_DRIVER_TESTSPIFLASH 1
236236

237+
//#define ENABLE_DRIVER_UART_TCP 1
238+
237239
// #define ENABLE_DRIVER_PIR 1
238240
//#define ENABLE_DRIVER_BKPARTITIONS 1
239241
#define ENABLE_HA_DISCOVERY 1

0 commit comments

Comments
 (0)