Skip to content

Commit

Permalink
retry i2c_write when failing with -EIO
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit committed Dec 19, 2021
1 parent fc09005 commit 86c7c39
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/src/main/cpp/libnxphalpatch/ipc/ipc_request_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ void handleDeviceWriteRequest(uint32_t requestId, const void *payload, uint32_t
auto size = size_t(requestBody->length);
if (sNciDeviceFd > 0) {
ssize_t result = write(fd, data, size);
if (result < 0 && errno == EIO) {
// NFCC may be in standby mode, wait 5ms and retry once
usleep(5000);
result = write(fd, data, size);
}
if (result == -1) {
result = -errno;
}
Expand Down

0 comments on commit 86c7c39

Please sign in to comment.