Skip to content

Commit

Permalink
fix i2cdump output on last line (#123)
Browse files Browse the repository at this point in the history
closes #122

Signed-off-by: RoboSchmied <github@roboschmie.de>
  • Loading branch information
RoboSchmied committed Mar 24, 2024
1 parent c765f48 commit 96aaa44
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/i2cspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ static void hexdump(read_register_t cb, int fd, unsigned char i2c_addr,
} else {
ascii[i % 16] = '.';
}
if ((i + 1) % 8 == 0 || i + 1 == size) {
if ((i + 1) % 8 == 0 || i == size) {
printf(" ");
if ((i + 1) % 16 == 0) {
printf("| %s \n", ascii);
} else if (i + 1 == size) {
} else if (i == size) {
ascii[(i + 1) % 16] = '\0';
if ((i + 1) % 16 <= 8) {
printf(" ");
Expand Down

0 comments on commit 96aaa44

Please sign in to comment.