aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGergő J. Miklós2020-10-10 22:35:14 +0200
committerGergő J. Miklós2020-10-10 22:35:14 +0200
commitf8ae02cf6bad5c5c207aa2b2e9d5b2a5a1e8d3de (patch)
tree7e658dd35a837025ff82d787e444cde61865240c
parent818665c9c6ed9fc78baf56d83809856882904f35 (diff)
downloadi2sensors-f8ae02cf6bad5c5c207aa2b2e9d5b2a5a1e8d3de.tar.gz
i2sensors-f8ae02cf6bad5c5c207aa2b2e9d5b2a5a1e8d3de.zip
test
-rw-r--r--src/main.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 383884d..2ff69a8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -61,21 +61,29 @@ void print_help(void) {
}
void bus_err(int ern){
- printf("I2C communication(rd) error. errno: %d\n",errno);
+ //printf("I2C communication(rd) error. errno: %d\n",errno);
+ fprintf (stderr, "Internal error %d at %s, line %d. (function: %s/%s)", ern, __FILE__, __LINE__, __func__, __FUNCTION__);
+}
+void bus_errr(int ern){
+ //printf("I2C communication(rd) error. errno: %d\n",errno);
+ fprintf (stderr, "Internal error %d at %s, line %d. (function: %s/%s)", errno, __FILE__, __LINE__, __func__, __FUNCTION__);
}
-
uchar *xchg_data (uchar *buf, uint16 wrlen, uint16 waitlen, uint16 rdlen){ //# [buf] = 32 byte
if(write(devicef, buf, 1) != 1){ //# write one byte to device
perror("I2C communication(wrr) error.");
- printf("errno: %d\n",errno);
+ fprintf (stderr, "I2C error (WR) %d at %s, line %d. (function: %s/%s)", errno, __FILE__, __LINE__, __func__, __FUNCTION__);
+ bus_err(errno);
+ bus_errr(0);
}
usleep(waitlen*1000); //# Wait 10ms for reading
if(read(devicef, buf, rdlen) != rdlen) { //# read the result
perror("I2C communication(rd) error.");
- printf("errno: %d\n",errno);
+ fprintf (stderr, "I2C error (WR) %d at %s, line %d. (function: %s/%s)", errno, __FILE__, __LINE__, __func__, __FUNCTION__);
+ bus_err(errno);
+ bus_errr(0);
}
return buf;
}