]> vcs.slashdirt.org Git - sw/tic2json.git/commitdiff

vcs.slashdirt.org Git - sw/tic2json.git/commitdiff

git git / sw / tic2json.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3099940)
tic2json: ticframecb: add "valid" argument.
2021年9月28日 13:51:05 +0000 (15:51 +0200)
2021年9月28日 17:27:04 +0000 (19:27 +0200)
Enables to only process valid frames.
Used in embedded / esptic to only send valid frames on the wire.


diff --git a/embedded/ESP-RTOS/esptic/main/main.c b/embedded/ESP-RTOS/esptic/main/main.c
index 78e88de5c2a6955b5a6d58c81754df97fe998338..56d91ecc8bcbc2e940d4c4b5a750d9da619a3153 100644 (file)
--- a/embedded/ESP-RTOS/esptic/main/main.c
+++ b/embedded/ESP-RTOS/esptic/main/main.c
@@ -88,9 +88,10 @@ cleanup:
}
-static void ticframecb(char * buf, size_t size)
+static void ticframecb(char * buf, size_t size, bool valid)
{
- sendto(Gsockfd, buf, size, 0, &Gai_addr, Gai_addrlen);
+ if (valid)
+ sendto(Gsockfd, buf, size, 0, &Gai_addr, Gai_addrlen);
}
static void tic_task(void *pvParameter)
diff --git a/tic2json.c b/tic2json.c
index d74ccd2f961c641857d65d1ee14d485153451c98..277ad231ee661e3602b1f384cbe9f30920a93d80 100644 (file)
--- a/tic2json.c
+++ b/tic2json.c
@@ -50,12 +50,6 @@
#ifdef PRINT2BUF
static char * ticbuf;
static size_t ticbufsize, ticbufavail;
-
- /**
- * TIC frame callback
- * @param buf the buffer received from tic2json_main(), filled with JSON data
- * @param size the length of JSON data currently in the buffer
- */
static tic2json_framecb_t ticframecb;
#include <stdarg.h>
@@ -95,7 +89,7 @@ static struct {
char fdelim;
int optflags;
unsigned int skipframes, framecount;
- char ferr;
+ bool ferr;
} tp;
/** TIC units representation strings */
@@ -286,7 +280,7 @@ void frame_sep(void)
#ifdef PRINT2BUF
ticprintf("%c\n", tp.framedelims[1]);
if (ticframecb)
- ticframecb(ticbuf, ticbufsize-ticbufavail);
+ ticframecb(ticbuf, ticbufsize-ticbufavail, !tp.ferr);
ticbufavail = ticbufsize; // reset buffer
ticprintf("%c", tp.framedelims[0]);
#else
diff --git a/tic2json.h b/tic2json.h
index 439e99ab70dc026a0b7a3ff5cbb7e9c9a70455a1..afd70f50be914c5bdf78bc0d4c80d2c4804188c9 100644 (file)
--- a/tic2json.h
+++ b/tic2json.h
@@ -24,6 +24,12 @@ enum {
TIC2JSON_OPT_PARSESTGE = 0x20,
};
-typedef void (*tic2json_framecb_t)(char * buf, size_t size);
+/**
+ * TIC frame callback
+ * @param buf the buffer received from tic2json_main(), filled with JSON data
+ * @param size the length of JSON data currently in the buffer
+ * @param valid true if TIC frame is valid, false otherwise
+ */
+typedef void (*tic2json_framecb_t)(char * buf, size_t size, bool valid);
#endif /* tic2json_h */
tic2json TIC parser/converter
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /