2

I have an AVR which I have set up to act as a USB serial device when plugged into the computer. I want to send commands to it via serial.

However, I can't manage to get the commands to send and receive a reply. I send 16bits of data at a time and expect to receive a 16bit reply but instead, my program hangs on waiting for a reply. I suspect its to do with output buffering on the serial and USB driver.

I tried looking up ways to control the serial port but it's difficult to work out which options I need since many options are only applicable to real serial ports (not USB serial).

At the moment, I'm using this code to open the device file

int fd = open(device, O_RDWR | O_NDELAY | O_SYNC | O_NOCTTY);
struct termios tio = {0};
cfmakeraw(&tio);
tio.c_cc[VMIN] = 2;
tcsetattr(fd,TCSANOW,&tio);

Can anyone help me select the right options for what I need? I just need synchronous, direct access with none (or little) output buffering.

dsolimano
  • 8,870
  • 3
  • 48
  • 63
tangrs
  • 9,709
  • 1
  • 38
  • 53

0 Answers0