From 0951357e44912a0afe92519d8cf871ac644a5892 Mon Sep 17 00:00:00 2001 From: Hayden Roche <hroche@blues.com> Date: Thu, 1 Feb 2024 12:42:09 -0800 Subject: [PATCH] Update to latest note-c master. (#127) * remove note-c before re-add * Squashed 'src/note-c/' content from commit 96e5ca2 git-subtree-dir: src/note-c git-subtree-split: 96e5ca2c2ec7724d6133ac67225d51482ee1f328 * Update to latest note-c master. --- src/note-c/n_i2c.c | 18 ------------------ src/note-c/n_serial.c | 16 +--------------- src/note-c/note.h | 1 - 3 files changed, 1 insertion(+), 34 deletions(-) diff --git a/src/note-c/n_i2c.c b/src/note-c/n_i2c.c index a5c552f..deb2269 100644 --- a/src/note-c/n_i2c.c +++ b/src/note-c/n_i2c.c @@ -58,18 +58,14 @@ NOTE_C_STATIC const char * i2cNoteQueryLength(uint32_t * available, // Send a dummy I2C transaction to prime the Notecard const char *err = _I2CReceive(_I2CAddress(), &dummy_buffer, 0, available); if (err) { -#ifdef ERRDBG NOTE_C_LOG_ERROR(err); -#endif return err; } // If we've timed out, return an error if (timeoutMs && _GetMs() - startMs >= timeoutMs) { const char *err = ERRSTR("timeout: no response from Notecard {io}", c_iotimeout); -#ifdef ERRDBG NOTE_C_LOG_ERROR(err); -#endif return err; } } @@ -119,9 +115,7 @@ const char *i2cNoteTransaction(const char *request, size_t reqLen, char **respon uint32_t available = 0; err = i2cNoteQueryLength(&available, timeoutMs); if (err) { -#ifdef ERRDBG NOTE_C_LOG_ERROR(ERRSTR("failed to query Notecard", c_err)); -#endif _UnlockI2C(); return err; } @@ -131,9 +125,7 @@ const char *i2cNoteTransaction(const char *request, size_t reqLen, char **respon jsonbuf = (uint8_t *)_Malloc(jsonbufAllocLen + 1); if (jsonbuf == NULL) { const char *err = ERRSTR("transaction: jsonbuf malloc failed", c_mem); -#ifdef ERRDBG NOTE_C_LOG_ERROR(err); -#endif _UnlockI2C(); return err; } @@ -150,9 +142,7 @@ const char *i2cNoteTransaction(const char *request, size_t reqLen, char **respon if (jsonbuf) { _Free(jsonbuf); } -#ifdef ERRDBG NOTE_C_LOG_ERROR(ERRSTR("error occured during receive", c_iobad)); -#endif _UnlockI2C(); return err; } @@ -169,9 +159,7 @@ const char *i2cNoteTransaction(const char *request, size_t reqLen, char **respon uint8_t *jsonbufNew = (uint8_t *)_Malloc(jsonbufAllocLen + 1); if (jsonbufNew == NULL) { const char *err = ERRSTR("transaction: jsonbuf grow malloc failed", c_mem); -#ifdef ERRDBG NOTE_C_LOG_ERROR(err); -#endif if (jsonbuf) { _Free(jsonbuf); } @@ -368,9 +356,7 @@ const char *i2cChunkedReceive(uint8_t *buffer, uint32_t *size, bool delay, uint3 const char *err = _I2CReceive(_I2CAddress(), (buffer + received), requested, available); if (err) { *size = received; -#ifdef ERRDBG NOTE_C_LOG_ERROR(err); -#endif return err; } @@ -414,11 +400,9 @@ const char *i2cChunkedReceive(uint8_t *buffer, uint32_t *size, bool delay, uint3 // Exit on timeout if (timeoutMs && (_GetMs() - startMs >= timeoutMs)) { *size = received; -#ifdef ERRDBG if (received) { NOTE_C_LOG_ERROR(ERRSTR("received only partial reply before timeout", c_iobad)); } -#endif return ERRSTR("timeout: transaction incomplete {io}", c_iotimeout); } @@ -461,9 +445,7 @@ const char *i2cChunkedTransmit(uint8_t *buffer, uint32_t size, bool delay) estr = _I2CTransmit(_I2CAddress(), chunk, chunkLen); if (estr != NULL) { _I2CReset(_I2CAddress()); -#ifdef ERRDBG NOTE_C_LOG_ERROR(estr); -#endif return estr; } chunk += chunkLen; diff --git a/src/note-c/n_serial.c b/src/note-c/n_serial.c index d2339c2..ede4189 100644 --- a/src/note-c/n_serial.c +++ b/src/note-c/n_serial.c @@ -60,9 +60,7 @@ const char *serialNoteTransaction(const char *request, size_t reqLen, char **res // max timeout and ultimately in our error handling. for (const uint32_t startMs = _GetMs(); !_SerialAvailable(); ) { if (timeoutMs && (_GetMs() - startMs) >= timeoutMs) { -#ifdef ERRDBG - NOTE_C_LOG_ERROR(ERRSTR("reply to request didn't arrive from module in time", c_iotimeout)); -#endif + NOTE_C_LOG_DEBUG(ERRSTR("reply to request didn't arrive from module in time", c_iotimeout)); return ERRSTR("transaction timeout {io}", c_iotimeout); } if (!cardTurboIO) { @@ -78,9 +76,7 @@ const char *serialNoteTransaction(const char *request, size_t reqLen, char **res uint8_t *jsonbuf = (uint8_t *)_Malloc(jsonbufAllocLen + 1); if (jsonbuf == NULL) { const char *err = ERRSTR("transaction: jsonbuf malloc failed", c_mem); -#ifdef ERRDBG NOTE_C_LOG_ERROR(err); -#endif return err; } @@ -93,9 +89,7 @@ const char *serialNoteTransaction(const char *request, size_t reqLen, char **res const char *err = serialChunkedReceive((uint8_t *)(jsonbuf + jsonbufLen), &jsonbufAvailLen, true, (CARD_INTRA_TRANSACTION_TIMEOUT_SEC * 1000), &available); if (err) { _Free(jsonbuf); -#ifdef ERRDBG NOTE_C_LOG_ERROR(ERRSTR("error occured during receive", c_iobad)); -#endif return err; } jsonbufLen += jsonbufAvailLen; @@ -111,9 +105,7 @@ const char *serialNoteTransaction(const char *request, size_t reqLen, char **res uint8_t *jsonbufNew = (uint8_t *)_Malloc(jsonbufAllocLen + 1); if (jsonbufNew == NULL) { const char *err = ERRSTR("transaction: jsonbuf grow malloc failed", c_mem); -#ifdef ERRDBG NOTE_C_LOG_ERROR(err); -#endif _Free(jsonbuf); return err; } @@ -190,11 +182,7 @@ bool serialNoteReset(void) break; } -#ifdef ERRDBG NOTE_C_LOG_ERROR(somethingFound ? ERRSTR("unrecognized data from notecard", c_iobad) : ERRSTR("notecard not responding", c_iobad)); -#else - NOTE_C_LOG_ERROR(ERRSTR("notecard not responding", c_iobad)); -#endif _DelayMs(CARD_RESET_DRAIN_MS); if (!_SerialReset()) { @@ -234,11 +222,9 @@ const char *serialChunkedReceive(uint8_t *buffer, uint32_t *size, bool delay, ui while (!_SerialAvailable()) { if (timeoutMs && (_GetMs() - startMs >= timeoutMs)) { *size = received; -#ifdef ERRDBG if (received) { NOTE_C_LOG_ERROR(ERRSTR("received only partial reply before timeout", c_iobad)); } -#endif return ERRSTR("timeout: transaction incomplete {io}",c_iotimeout); } // Yield while awaiting the first byte (lazy). After the first byte, diff --git a/src/note-c/note.h b/src/note-c/note.h index 1ad5941..bb2466f 100644 --- a/src/note-c/note.h +++ b/src/note-c/note.h @@ -52,7 +52,6 @@ #define ERRSTR(x,y) (y) #else #define ERRSTR(x,y) (x) -#define ERRDBG #endif #ifdef NOTE_C_TEST_SINGLE_PRECISION