Hello.
I need to simulate a few serial links (doing a simulation of an application for a robot) and found socat which, at least with minicom, is working flawlessly.
I would really like to make pts static: ie same numbers between reboots, and automatic (not me opening terminals and leaving them with empty socat windows).
Is there a way for this?
Or maybe there is a (super easy!) way of replicating what socat does inside my own program so that I don't have to start multiple executables?
I also have problems with the ports themselves, don't know if these problems stem from the fact they are virtual.
Here is the bulk of the serial code (bluntly copied from link)
fd = open(PortIn, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1 )
{
dbg_print(MAIN_PROC_NAME,"Failed to open input port %s\n",PortIn);
dbg_print(MAIN_PROC_NAME,"Error: %s\n",strerror(errno));
}
else
dbg_print(MAIN_PROC_NAME,"Connected to port \"%s\"\n",PortIn);
tcgetattr(fd,&oldtio); /* save current port settings */
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
/* set input mode (non-canonical, no echo,...) */
newtio.c_lflag = 0;
newtio.c_cc[VTIME] = 0; /* inter-character timer unused */
newtio.c_cc[VMIN] = 5; /* blocking read until 5 chars received */
tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW,&newtio);
while (1) {
res = read(fd,input_buffer,255);
if (res > 0)
{
input_buffer[res]=0;
dbg_print(MAIN_PROC_NAME,"String received %s\n",input_buffer);
}
if (res < 0)
dbg_print(MAIN_PROC_NAME,"Error: %s\n",strerror(errno));
All I get is an endless list of
"Resource temporary unavailable"
Thank you for any input.