busses: i2c: improve logging
Currently we only inform the user with the error logging mechanism that we received a different number of bytes than expected. Thus in case of an error, we say that we sent/received -1 bytes. However -1 indicates an error and errno is set to indicate the error state. This patch extends the logging to also print the actual error. Additionally the same debugging printing was added to read, which is now silently returned to the caller. Signed-off-by: Olliver Schinagl <o.schinagl@ultimaker.com>
This commit is contained in:
parent
61b42396d9
commit
512be89700
1 changed files with 3 additions and 1 deletions
|
@ -135,6 +135,8 @@ i2c_read(i2c_device id, uint8_t *pbtRx, const size_t szRx)
|
|||
|
||||
if (recCount < 0) {
|
||||
res = NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR,
|
||||
"Error: read only %d bytes (%d expected) (%s).", (int)recCount, (int) szRx, strerror(errno));
|
||||
} else {
|
||||
if (recCount < (ssize_t)szRx) {
|
||||
res = NFC_EINVARG;
|
||||
|
@ -167,7 +169,7 @@ i2c_write(i2c_device id, const uint8_t *pbtTx, const size_t szTx)
|
|||
return NFC_SUCCESS;
|
||||
} else {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR,
|
||||
"Error: wrote only %d bytes (%d expected).", (int)writeCount, (int) szTx);
|
||||
"Error: wrote only %d bytes (%d expected) (%s).", (int)writeCount, (int) szTx, strerror(errno));
|
||||
return NFC_EIO;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue