3

I am using a converter from serial port to usb and in Windows it is possible to open Serial port properties and set a checkbox RS-485, only after that I am able to receive data from the device. How to do the same in Linux? Because by default I am getting the same result like in Windows with unchecked RS-485:

Port name - /dev/ttyACM0; Method name - readBytes(); Serial port operation timeout (500 ms).
execute try 2 error: I/O exception - failed to read

My device is:

Bus 001 Device 008: ID 04e2:1411 Exar Corp.

setserial -a /dev/ttyACM0
/dev/ttyACM0, Line 0, UART: unknown, Port: 0x0000, IRQ: 0
        Baud_base: 115200, close_delay: 5, divisor: 0
        closing_wait: 300
        Flags: spd_normal low_latency
2

You will have to write some C code, as described in the kernel doc.

#include <linux/serial.h>
struct serial_rs485 rs485conf = {0};

int fd = open ("/dev/ttyACM0", O_RDWR);
if (fd < 0)...
rs485conf.flags |= SER_RS485_ENABLED;
if (ioctl (fd, TIOCSRS485, &rs485conf) < 0)...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.