Opening USB for Reading/Writing

Good Afternoon,

I am a beginner at linux C programming.
I am trying to connect to a power meter device so that I may read values.
If I plug/unplug my USB device, I find that my power meter is identified in the /dev folder as usbdev6.6 and as "usb-187b-DENT_USB-if00" in folder /dev/serial/by-id. I trying to use "open" to just start the process of connecting to this device. With the code below, I keep seeing a return value of -1 from the "open statement. If anyone has any insight as to what the problem is, I would appreciate it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int theError;


//char *portname = "/dev/serial/by-id/usb-187b-DENT_USB-if00";
char *portname = "/dev/usbdev6.6";

int USB = open( portname, O_RDWR | O_NONBLOCK | O_NDELAY );

struct termios tty;
memset (&tty, 0, sizeof tty);

/* Error Handling */
if ( tcgetattr ( USB, &tty ) != 0 )
{
    theError = 1;
}
theError = 0;
Topic archived. No new replies allowed.