diff options
author | Gergő J. Miklós | 2020-11-06 22:05:49 +0100 |
---|---|---|
committer | Gergő J. Miklós | 2020-11-06 22:05:49 +0100 |
commit | 47bda328c70858c3b61cddf8e1398ce7ab0ff700 (patch) | |
tree | abcbf237dc1681dad42847a752d0c4ea93fa7b21 | |
parent | 09666096e8cfef88042cdcebffc606da8f1b3614 (diff) | |
download | i2sensors-47bda328c70858c3b61cddf8e1398ce7ab0ff700.tar.gz i2sensors-47bda328c70858c3b61cddf8e1398ce7ab0ff700.zip |
errors to stderr
-rw-r--r-- | src/hih61xx.c | 2 | ||||
-rw-r--r-- | src/lm75.c | 2 | ||||
-rw-r--r-- | src/main.c | 22 |
3 files changed, 13 insertions, 13 deletions
diff --git a/src/hih61xx.c b/src/hih61xx.c index cf00c04..92de893 100644 --- a/src/hih61xx.c +++ b/src/hih61xx.c @@ -152,7 +152,7 @@ void hih61xx_read_one(const uchar *opts) break; }else{ if( !isdigit(*(opts+i)) ){ //# Check the register string - printf("The Register address must be an integer!\n"); + fprintf(stderr, "The Register address must be an integer!\n"); print_help(); hih61xx_print_all(); exit (EXIT_FAILURE); @@ -142,7 +142,7 @@ void lm75_read_one(const uchar *opts){ // Prints the selected r } else { if( !isdigit(*(opts+i)) ){ //# Check the register string - printf("The Register address must be an integer!\n"); + fprintf(stderr, "The Register address must be an integer!\n"); print_help(); lm75_print_all(); exit (EXIT_FAILURE); @@ -21,8 +21,8 @@ #include "lm75.h" #include "hih61xx.h" #include "hmc5883.h" - -#define VERSION 1.31 + +#define VERSION 1.032 #ifndef _BUILD_TIME_ #define _BUILD_TIME_ __DATE__" "__TIME__ #endif @@ -78,7 +78,7 @@ void print_help(void) { " 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] (gcc %s) \n\n",VERSION,_BUILD_TIME_,__VERSION__); + printf ("Version: v%1.3f, build: [%s] (gcc %s) \n\n",VERSION,_BUILD_TIME_,__VERSION__); } @@ -91,11 +91,11 @@ __uint8_t *xchg_data (__uint8_t *buf, __uint16_t wrlen, __uint16_t waitlen, _ if( funcs & I2C_FUNC_I2C ){ #endif if(write(devicef, buf, 1) != 1){ //# write one byte to device - fprintf (stdout, "I2C write error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__); + fprintf (stderr, "I2C write error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__); } usleep(waitlen*1000); //# Wait 10ms for reading if(read(devicef, buf, rdlen) != rdlen) { //# read the result - fprintf (stdout, "I2C read error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__); + fprintf (stderr, "I2C read error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__); close(devicef); exit(EXIT_FAILURE); } @@ -103,11 +103,11 @@ __uint8_t *xchg_data (__uint8_t *buf, __uint16_t wrlen, __uint16_t waitlen, _ #ifdef WITH_I2C_SMBUS } else if ( funcs && I2C_FUNC_SMBUS_WORD_DATA ){ if(i2c_smbus_write_byte(devicef, buf[0] ) < 0){ //# write one byte to device - fprintf (stdout, "I2C write error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__); + fprintf (stderr, "I2C write error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__); } usleep(waitlen*1000); //# Wait 10ms for reading if((data = i2c_smbus_read_word_data(devicef, buf[0])) < 0) { //# read the result - fprintf (stdout, "I2C read error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__); + fprintf (stderr, "I2C read error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__); close(devicef); exit(EXIT_FAILURE); } else { @@ -157,12 +157,12 @@ int main( int argc, char *argv[] ){ snprintf(filename, 256, "/dev/i2c-%s", argv[2]); devicef = open(filename, O_RDWR); //# Open the i2c bus if (devicef < 0){ - printf("\n\tCan't open \"%s\" BUS. (Have you any permission?)\n\n", filename); + fprintf(stderr, "\n\tCan't open \"%s\" BUS. (Have you any permission?)\n\n", filename); exit(EXIT_FAILURE); } if (ioctl(devicef, I2C_FUNCS, &funcs) < 0) { //Get i2c device features - fprintf (stdout, "\n\tAdapter function error [ERR: %d, MSG: %s] at %s, line %d. \n", errno, strerror(errno), __FILE__, __LINE__); + fprintf (stderr, "\n\tAdapter function error [ERR: %d, MSG: %s] at %s, line %d. \n", errno, strerror(errno), __FILE__, __LINE__); close(devicef); exit(EXIT_FAILURE); } @@ -175,12 +175,12 @@ int main( int argc, char *argv[] ){ if (ioctl(devicef, I2C_SLAVE_FORCE, addr) < 0){ //# Seeking/Opening the device on the Bus //printf("\n\tCan't open i2c DEVICE, errno: %d\n\n",errno); - fprintf (stdout, "\n\tCan't open i2c DEVICE! [ERR: %d, MSG: %s] at %s, line %d. \n", errno, strerror(errno), __FILE__, __LINE__); + fprintf (stderr, "\n\tCan't open i2c DEVICE! [ERR: %d, MSG: %s] at %s, line %d. \n", errno, strerror(errno), __FILE__, __LINE__); close(devicef); exit(EXIT_FAILURE); } } else { - printf("\n\tThe DEVICE address must be a hexadecimal number\n\n"); + fprintf(stderr, "\n\tThe DEVICE address must be a hexadecimal number\n\n"); close(devicef); exit(EXIT_FAILURE); } |