- if ((fd = open(argv[1], O_RDWR)) < 0) {
- printf("Failed to open the i2c bus %s\n", argv[1]);
- exit(1);
- }
- if (ioctl(fd, I2C_SLAVE, dev.dev_id) < 0) {
- printf("Failed to acquire bus access and/or talk to slave.\n");
- exit(1);
- }
-
- rslt = bme280_init(&dev);
- if (rslt != BME280_OK)
- {
- printf("Failed to initialize the device.\n");
- exit(1);
- }
- rslt = stream_sensor_data_forced_mode(&dev);
- if (rslt != BME280_OK)
- {
- printf("Failed to stream sensor data.\n");
- exit(1);
- }
- return 0;
+ if ((fd = open(argv[1], O_RDWR)) < 0)
+ {
+ fprintf(stderr, "Failed to open the i2c bus %s\n", argv[1]);
+ exit(1);
+ }
+ if (ioctl(fd, I2C_SLAVE, dev.dev_id) < 0)
+ {
+ fprintf(stderr, "Failed to acquire bus access and/or talk to slave.\n");
+ exit(1);
+ }
+
+ rslt = bme280_init(&dev);
+ if (rslt != BME280_OK)
+ {
+ fprintf(stderr, "Failed to initialize the device.\n");
+ exit(1);
+ }
+ rslt = stream_sensor_data_forced_mode(&dev);
+ if (rslt != BME280_OK)
+ {
+ fprintf(stderr, "Failed to stream sensor data.\n");
+ exit(1);
+ }
+ return 0;