Skip to content

Commit 0951357

Browse files
authored
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.
1 parent 8253f4d commit 0951357

File tree

3 files changed

+1
-34
lines changed

3 files changed

+1
-34
lines changed

src/note-c/n_i2c.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,14 @@ NOTE_C_STATIC const char * i2cNoteQueryLength(uint32_t * available,
5858
// Send a dummy I2C transaction to prime the Notecard
5959
const char *err = _I2CReceive(_I2CAddress(), &dummy_buffer, 0, available);
6060
if (err) {
61-
#ifdef ERRDBG
6261
NOTE_C_LOG_ERROR(err);
63-
#endif
6462
return err;
6563
}
6664

6765
// If we've timed out, return an error
6866
if (timeoutMs && _GetMs() - startMs >= timeoutMs) {
6967
const char *err = ERRSTR("timeout: no response from Notecard {io}", c_iotimeout);
70-
#ifdef ERRDBG
7168
NOTE_C_LOG_ERROR(err);
72-
#endif
7369
return err;
7470
}
7571
}
@@ -119,9 +115,7 @@ const char *i2cNoteTransaction(const char *request, size_t reqLen, char **respon
119115
uint32_t available = 0;
120116
err = i2cNoteQueryLength(&available, timeoutMs);
121117
if (err) {
122-
#ifdef ERRDBG
123118
NOTE_C_LOG_ERROR(ERRSTR("failed to query Notecard", c_err));
124-
#endif
125119
_UnlockI2C();
126120
return err;
127121
}
@@ -131,9 +125,7 @@ const char *i2cNoteTransaction(const char *request, size_t reqLen, char **respon
131125
jsonbuf = (uint8_t *)_Malloc(jsonbufAllocLen + 1);
132126
if (jsonbuf == NULL) {
133127
const char *err = ERRSTR("transaction: jsonbuf malloc failed", c_mem);
134-
#ifdef ERRDBG
135128
NOTE_C_LOG_ERROR(err);
136-
#endif
137129
_UnlockI2C();
138130
return err;
139131
}
@@ -150,9 +142,7 @@ const char *i2cNoteTransaction(const char *request, size_t reqLen, char **respon
150142
if (jsonbuf) {
151143
_Free(jsonbuf);
152144
}
153-
#ifdef ERRDBG
154145
NOTE_C_LOG_ERROR(ERRSTR("error occured during receive", c_iobad));
155-
#endif
156146
_UnlockI2C();
157147
return err;
158148
}
@@ -169,9 +159,7 @@ const char *i2cNoteTransaction(const char *request, size_t reqLen, char **respon
169159
uint8_t *jsonbufNew = (uint8_t *)_Malloc(jsonbufAllocLen + 1);
170160
if (jsonbufNew == NULL) {
171161
const char *err = ERRSTR("transaction: jsonbuf grow malloc failed", c_mem);
172-
#ifdef ERRDBG
173162
NOTE_C_LOG_ERROR(err);
174-
#endif
175163
if (jsonbuf) {
176164
_Free(jsonbuf);
177165
}
@@ -368,9 +356,7 @@ const char *i2cChunkedReceive(uint8_t *buffer, uint32_t *size, bool delay, uint3
368356
const char *err = _I2CReceive(_I2CAddress(), (buffer + received), requested, available);
369357
if (err) {
370358
*size = received;
371-
#ifdef ERRDBG
372359
NOTE_C_LOG_ERROR(err);
373-
#endif
374360
return err;
375361
}
376362

@@ -414,11 +400,9 @@ const char *i2cChunkedReceive(uint8_t *buffer, uint32_t *size, bool delay, uint3
414400
// Exit on timeout
415401
if (timeoutMs && (_GetMs() - startMs >= timeoutMs)) {
416402
*size = received;
417-
#ifdef ERRDBG
418403
if (received) {
419404
NOTE_C_LOG_ERROR(ERRSTR("received only partial reply before timeout", c_iobad));
420405
}
421-
#endif
422406
return ERRSTR("timeout: transaction incomplete {io}", c_iotimeout);
423407
}
424408

@@ -461,9 +445,7 @@ const char *i2cChunkedTransmit(uint8_t *buffer, uint32_t size, bool delay)
461445
estr = _I2CTransmit(_I2CAddress(), chunk, chunkLen);
462446
if (estr != NULL) {
463447
_I2CReset(_I2CAddress());
464-
#ifdef ERRDBG
465448
NOTE_C_LOG_ERROR(estr);
466-
#endif
467449
return estr;
468450
}
469451
chunk += chunkLen;

src/note-c/n_serial.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ const char *serialNoteTransaction(const char *request, size_t reqLen, char **res
6060
// max timeout and ultimately in our error handling.
6161
for (const uint32_t startMs = _GetMs(); !_SerialAvailable(); ) {
6262
if (timeoutMs && (_GetMs() - startMs) >= timeoutMs) {
63-
#ifdef ERRDBG
64-
NOTE_C_LOG_ERROR(ERRSTR("reply to request didn't arrive from module in time", c_iotimeout));
65-
#endif
63+
NOTE_C_LOG_DEBUG(ERRSTR("reply to request didn't arrive from module in time", c_iotimeout));
6664
return ERRSTR("transaction timeout {io}", c_iotimeout);
6765
}
6866
if (!cardTurboIO) {
@@ -78,9 +76,7 @@ const char *serialNoteTransaction(const char *request, size_t reqLen, char **res
7876
uint8_t *jsonbuf = (uint8_t *)_Malloc(jsonbufAllocLen + 1);
7977
if (jsonbuf == NULL) {
8078
const char *err = ERRSTR("transaction: jsonbuf malloc failed", c_mem);
81-
#ifdef ERRDBG
8279
NOTE_C_LOG_ERROR(err);
83-
#endif
8480
return err;
8581
}
8682

@@ -93,9 +89,7 @@ const char *serialNoteTransaction(const char *request, size_t reqLen, char **res
9389
const char *err = serialChunkedReceive((uint8_t *)(jsonbuf + jsonbufLen), &jsonbufAvailLen, true, (CARD_INTRA_TRANSACTION_TIMEOUT_SEC * 1000), &available);
9490
if (err) {
9591
_Free(jsonbuf);
96-
#ifdef ERRDBG
9792
NOTE_C_LOG_ERROR(ERRSTR("error occured during receive", c_iobad));
98-
#endif
9993
return err;
10094
}
10195
jsonbufLen += jsonbufAvailLen;
@@ -111,9 +105,7 @@ const char *serialNoteTransaction(const char *request, size_t reqLen, char **res
111105
uint8_t *jsonbufNew = (uint8_t *)_Malloc(jsonbufAllocLen + 1);
112106
if (jsonbufNew == NULL) {
113107
const char *err = ERRSTR("transaction: jsonbuf grow malloc failed", c_mem);
114-
#ifdef ERRDBG
115108
NOTE_C_LOG_ERROR(err);
116-
#endif
117109
_Free(jsonbuf);
118110
return err;
119111
}
@@ -190,11 +182,7 @@ bool serialNoteReset(void)
190182
break;
191183
}
192184

193-
#ifdef ERRDBG
194185
NOTE_C_LOG_ERROR(somethingFound ? ERRSTR("unrecognized data from notecard", c_iobad) : ERRSTR("notecard not responding", c_iobad));
195-
#else
196-
NOTE_C_LOG_ERROR(ERRSTR("notecard not responding", c_iobad));
197-
#endif
198186

199187
_DelayMs(CARD_RESET_DRAIN_MS);
200188
if (!_SerialReset()) {
@@ -234,11 +222,9 @@ const char *serialChunkedReceive(uint8_t *buffer, uint32_t *size, bool delay, ui
234222
while (!_SerialAvailable()) {
235223
if (timeoutMs && (_GetMs() - startMs >= timeoutMs)) {
236224
*size = received;
237-
#ifdef ERRDBG
238225
if (received) {
239226
NOTE_C_LOG_ERROR(ERRSTR("received only partial reply before timeout", c_iobad));
240227
}
241-
#endif
242228
return ERRSTR("timeout: transaction incomplete {io}",c_iotimeout);
243229
}
244230
// Yield while awaiting the first byte (lazy). After the first byte,

src/note-c/note.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#define ERRSTR(x,y) (y)
5353
#else
5454
#define ERRSTR(x,y) (x)
55-
#define ERRDBG
5655
#endif
5756

5857
#ifdef NOTE_C_TEST_SINGLE_PRECISION

0 commit comments

Comments
 (0)