0

I have an USB CDC-Device connected to my RaspberryPi with Raspbian. The Firmware for this USB device was developed in my company and offers several communication modes. The "normal" mode is an ascii shell, which you can use with the normal tty, attached by the kernel to the device.

To activate the mode I need, a binary communication mode, I had to set the DTR and the RTS flag to zero. Unfortunately when I do this (set both flags to zero), the syscall 'read' stops to receive data (does not return).

When I test it with H-Term on an Windows PC it works as expected, I can even see with my logic-analyser that the device is sending data, but Linux does not give them to me.

I have already tried to set the file descriptor to O_NONBLOCK, but it doesn't work. If I set only one of the flags to zero, read still receives something.

int fd = open("/dev/ttyACM0", O_RDWR | O_NOCTTY);
int flags = TIOCM_DTR | TIOCM_RTS;
ioctl(fd, TIOCMBIC, &flags); // I also tried to set the flags separately

uint8_t req = {'t', 'e', 's', 't'};
write(fd, req, 4);

uint8_t resp[100];
ssize_t resp_len = read(fd, resp, 100); // does not return

I would expect that read returns and I get some data back.

I also write an small python script to test the connection, same result.

cone1018
  • 13
  • 4
  • I suggest to start with capturing and testing the return values of ioctl and write. You need to know if these calls are without error. – Pat Jul 27 '19 at 17:28
  • I did this, no errors. I also checked the flags manually with TIOCMGET. – cone1018 Jul 27 '19 at 17:42

0 Answers0