#include #include #include #include #include #include #include #include #include #include "lm75.h" #include "hih61xx.h" #include "hmc5883.h" #define VERSION 1.22 // extern void lm75_print_help(void); // extern void lm75_read_all(const char *opts); // extern void lm75_read_one(const char *opts); // extern void hih61xx_print_help(void); // extern void hih61xx_read_all(const char *opts); // extern void hih61xx_read_one(const char *opts); int file; char temp[256]; void (*print_all)(void) = NULL; void (*read_all)(const char *opts) = NULL; void (*read_one)(const char *opts) = NULL; void (*conf_set)(const char *opts) = NULL; void print_help(void) { printf ("\n" " i2sensors ()\n" "\n" "Aviable options: \n" " print_all -- list all available measurement parameters of the device\n" " read_all -- read all measured parameters from device\n" " read_one -- read the selected parameters from device\n" " conf_set -- set the configuration register\n" "\n" "Usage:\n" " i2sensors read_all
\n" " i2sensors read_one
\n" " i2sensors conf_set
\n" "\n" "Examples:\n" " i2sensors read_all 1 lm75 0x4f \n" " i2sensors read_one 1 lm75 0x4f 00,-1.35\n" "\n" ); printf ("Version: v%1.2f, build: %s %s\n\n",VERSION,__DATE__,__TIME__); } 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)){ 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)) { print_all = hih61xx_print_all; read_all = hih61xx_read_all; read_one = hih61xx_read_one; conf_set = hih61xx_conf_set; } else if(!strcmp("hmc5883", dev_type)) { print_all = hmc5883_print_all; read_all = hmc5883_read_all; read_one = hmc5883_read_one; conf_set = hmc5883_conf_set; } } int main(int argc, char *argv[]) { // >> i2sensor () // >> i2sensor read_all 0 lm75 4f 1,-1.0;2,+0.2;3,+10;4,-2 // read_all, list_all, // ...read_all..., // read_one..., // ...read_reg_hex... , // ...read_reg_dec... , // ...set_param... , // ...set_reg... , if(4 < argc && argc < 10) //Minimal 5 argument passed { char filename[32]; int i; preinit(argv[3]); for(i=0;i 5) { read_one(argv[5]); } else { print_help(); } close(file); } else { print_help(); } return 0; }