aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 6012a03..4623919 100644
--- a/src/main.c
+++ b/src/main.c
@@ -63,16 +63,31 @@ void bus_err(int ern){
printf("I2C communication(rd) error. errno: %d\n",errno);
}
-void preinit(const char *dev_type){
- if(!strcmp("lm75", dev_type)){
+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);
+ }
+ usleep(waitlen*1000); //# Wait 10ms for reading
+
+ if(read(devicef, buf, rdlen) != rdlen) { //# read the result
+ bus_err(errno);
+ }
+ return buf;
+}
+
+
+void preinit(const uchar *dev_type){
+
+ if(!strcmp("lm75", (char *)dev_type)){
print_all = lm75_print_all;
read_all = lm75_read_all;
read_one = lm75_read_one;
conf_set = lm75_conf_set;
}
- else if(!strcmp("hih61xx", dev_type)) {
+ else if(!strcmp("hih61xx", (char *)dev_type)) {
print_all = hih61xx_print_all;
read_all = hih61xx_read_all;
read_one = hih61xx_read_one;
@@ -108,7 +123,7 @@ int main(int argc, char *argv[])
char filename[32];
int i;
- preinit(argv[3]);
+ preinit((uchar *)argv[3]);
for( i = 0; i < strlen(argv[2]); i++){ //# Test on bus address, for error detection.
if(!isdigit(argv[2][i])){