+ int i;
+ double kw;
+ double voltage;
+
+ if (device == NULL)
+ {
+ device = DEFAULT_DEVICE;
+ }
+
+ for (i = 0; i < 10; i++)
+ {
+ device[strlen(device)-1] = i + '0';
+
+ if ((fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK)) <= 0)
+ {
+ DEBUG ("No device at fd %d", fd);
+ close (fd);
+ continue;
+ }
+ struct termios options;
+ /* Get the current options for the port... */
+ tcgetattr(fd, &options);
+ options.c_cflag = B19200 | CS8 | CSTOPB | CREAD | CLOCAL;
+ options.c_iflag = IGNBRK | IGNPAR;
+ options.c_oflag = 0;
+ options.c_lflag = 0;
+ options.c_cc[VTIME] = 20;
+ options.c_cc[VMIN] = 250;
+
+ /* Set the new options for the port... */
+ tcflush(fd, TCIFLUSH);
+ tcsetattr(fd, TCSANOW, &options);
+
+ if (ted_read_value (&kw,&voltage) != 0)