I'd like a little clarification on what socat does to the serial communication, because for some reason I can only get the communication to my Arduino to work when using socat.
This is the command I use to set up socat:
socat -d -v -x PTY,link=/tmp/serial,wait-slave,raw /dev/ttyACM0,raw
The code I used in C++ is:
int file;
file = open("/tmp/serial", O_RDWR | O_NOCTTY | O_NDELAY);
if (file == -1)
{
perror("open_port: Unable to open \n");
}
else
fcntl(file, F_SETFL, 0);
struct termios options;
//* Get the current options for the port...
tcgetattr(file, &options);
cfsetispeed(&options, B9600);
cfsetospeed(&options, B9600);
options.c_oflag = 0;
//options.c_oflag &= ~(OCRNL | ONLCR | ONLRET | ONOCR | OFILL | OLCUC | OPOST);
options.c_cflag |= (CLOCAL | CREAD);
cfmakeraw(&options);
tcsetattr(file, TCSANOW, &options);
sprintf(sendpack,"$C000C000C000C000\r");
num = write(file,sendpack,18);
tcflush(file, TCIOFLUSH); // clear buffer
So when I run this through socat the arduino reacts as it is supposed to, but if I change the open() line from /tmp/serial to /dev/ttyACM0 the arduino no longer performs at all. Can someone exlplain to me what socat is doing to the data to make things work, and how I can change my C code to do the same thing? I cannot use socat in my final implementation because it causes a delay that would make driving my robot unpredictable.