aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGergő J. Miklós2020-10-09 02:10:06 +0200
committerGergő J. Miklós2020-10-09 02:10:06 +0200
commita44e57ef396abcc3d350ab95f007392c96d286d9 (patch)
treefc5dc2ceb5c673720426c69437b4062489abf171 /src
parent73d2bc24adab62fefa4c90fced0d121b2ee9fb38 (diff)
downloadi2sensors-a44e57ef396abcc3d350ab95f007392c96d286d9.tar.gz
i2sensors-a44e57ef396abcc3d350ab95f007392c96d286d9.zip
plus error handling
Diffstat (limited to 'src')
-rw-r--r--src/main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 4623919..0c7e800 100644
--- a/src/main.c
+++ b/src/main.c
@@ -67,12 +67,14 @@ void bus_err(int ern){
uchar *xchg_data (uchar *buf, uint16 wrlen, uint16 waitlen, uint16 rdlen){ //# [buf] = 32 byte
if(write(devicef, buf, wrlen) != wrlen){ //# write one byte to device
- bus_err(errno);
+ printf("I2C communication(wr) error. errno: %d\n",errno);
+ perror(errno);
}
usleep(waitlen*1000); //# Wait 10ms for reading
if(read(devicef, buf, rdlen) != rdlen) { //# read the result
- bus_err(errno);
+ printf("I2C communication(rd) error. errno: %d\n",errno);
+ perror(errno);
}
return buf;
}