nevixa
May 23rd, 2012, 04:17 PM
Hi,
I'm interfacing via a usb to serial converter with a serial device in c++. I used to have Ubuntu 10.10 and the code below and it worked. With Ubuntu 12.04 (clean install) it won't connect any more. The device is connected and I can find it in the same directory etc.
int open_port(void) {
int fd; // file description for the serial port
fd = open("/dev/serial/by-id/usb-Name_Of_Device_USB_to_serial_bridge_0-if00", O_RDWR | O_NOCTTY);
cout << "BM: Attempting to open port" << endl;
if (fd == -1) // if open is unsucessful
{
printf("BM: open_port: Unable to open BM \n");
} else {
printf("BM: port is open.\n");
}
return (fd);
}
int configure_port(int fd) // configure the port
{
struct termios port_settings; // structure to store the port settings in
cfsetispeed(&port_settings, B115200); // set baud rates
cfsetospeed(&port_settings, B115200);
port_settings.c_cflag &= ~PARENB; // set no parity, stop bits, data bits
port_settings.c_cflag &= ~CSTOPB;
port_settings.c_cflag &= ~CSIZE;
port_settings.c_cflag |= CS8;
tcsetattr(fd, TCSANOW, &port_settings); // apply the settings to the port
return (fd);
}Anyone any idea why this is not working on Ubuntu 12.04 and it is on Ubuntu 10.10?
Some more info:
$ ls -al /dev/serial/by-id
total 0
drwxr-xr-x 2 root root 60 May 23 16:22 .
drwxr-xr-x 4 root root 80 May 23 16:22 ..
lrwxrwxrwx 1 root root 13 May 23 16:22
usb-Name_Of_Device_USB_to_serial_bridge_0-if00-> ../../ttyACM0
Thank you
I'm interfacing via a usb to serial converter with a serial device in c++. I used to have Ubuntu 10.10 and the code below and it worked. With Ubuntu 12.04 (clean install) it won't connect any more. The device is connected and I can find it in the same directory etc.
int open_port(void) {
int fd; // file description for the serial port
fd = open("/dev/serial/by-id/usb-Name_Of_Device_USB_to_serial_bridge_0-if00", O_RDWR | O_NOCTTY);
cout << "BM: Attempting to open port" << endl;
if (fd == -1) // if open is unsucessful
{
printf("BM: open_port: Unable to open BM \n");
} else {
printf("BM: port is open.\n");
}
return (fd);
}
int configure_port(int fd) // configure the port
{
struct termios port_settings; // structure to store the port settings in
cfsetispeed(&port_settings, B115200); // set baud rates
cfsetospeed(&port_settings, B115200);
port_settings.c_cflag &= ~PARENB; // set no parity, stop bits, data bits
port_settings.c_cflag &= ~CSTOPB;
port_settings.c_cflag &= ~CSIZE;
port_settings.c_cflag |= CS8;
tcsetattr(fd, TCSANOW, &port_settings); // apply the settings to the port
return (fd);
}Anyone any idea why this is not working on Ubuntu 12.04 and it is on Ubuntu 10.10?
Some more info:
$ ls -al /dev/serial/by-id
total 0
drwxr-xr-x 2 root root 60 May 23 16:22 .
drwxr-xr-x 4 root root 80 May 23 16:22 ..
lrwxrwxrwx 1 root root 13 May 23 16:22
usb-Name_Of_Device_USB_to_serial_bridge_0-if00-> ../../ttyACM0
Thank you