Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions userial/ds9097/linuxlnk.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,28 @@ SMALLINT owTouchReset(int portnum)
cfsetispeed(&term[portnum], B115200);
cfsetospeed(&term[portnum], B115200);

/* set to 6 data bits */
term[portnum].c_cflag |= CS6;
/* set to 6 data bits with fallback to 8 if rejected */
term[portnum].c_cflag &= ~CSIZE;
term[portnum].c_cflag |= CS6;

if (tcsetattr(fd[portnum], TCSANOW, &term[portnum] ) < 0 )
{
OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
perror("Reset: Error with tcsetattr 2");
close(fd[portnum]);
return FALSE;
/* CS6 failed, try CS8 fallback for modern kernels/drivers */
if (errno == EINVAL) {
term[portnum].c_cflag &= ~CSIZE;
term[portnum].c_cflag |= CS8;
if (tcsetattr(fd[portnum], TCSANOW, &term[portnum] ) < 0 ) {
OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
perror("Reset: Error with tcsetattr 2 (CS6/CS8 fallback failed)");
close(fd[portnum]);
return FALSE;
}
} else {
OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
perror("Reset: Error with tcsetattr 2");
close(fd[portnum]);
return FALSE;
}
}

return stat;
Expand Down
22 changes: 18 additions & 4 deletions userial/ds9097/linuxses.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <errno.h>
#include <ownet.h>
#include <sys/file.h>

Expand Down Expand Up @@ -94,6 +95,7 @@ SMALLINT owAcquire(int portnum, char *port_zstr)
term[portnum].c_cc[VTIME] = 0;

/* 6 data bits, Receiver enabled, Hangup, Dont change "owner" */
/* Try CS6 first with fallback to CS8 for modern kernels */
term[portnum].c_cflag |= CS6 | CREAD | HUPCL | CLOCAL;

/* Set input and output speed to 115.2k */
Expand All @@ -103,10 +105,22 @@ SMALLINT owAcquire(int portnum, char *port_zstr)
/* set the attributes */
if(tcsetattr(fd[portnum], TCSANOW, &term[portnum]) < 0 )
{
OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
perror("owAcquire: failed to set attributes");
close(fd[portnum]);
return FALSE;
/* CS6 failed, try CS8 fallback for modern kernels/drivers */
if (errno == EINVAL) {
term[portnum].c_cflag &= ~CSIZE;
term[portnum].c_cflag |= CS8 | CREAD | HUPCL | CLOCAL;
if (tcsetattr(fd[portnum], TCSANOW, &term[portnum]) < 0 ) {
OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
perror("owAcquire: failed to set attributes (CS6/CS8 fallback failed)");
close(fd[portnum]);
return FALSE;
}
} else {
OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
perror("owAcquire: failed to set attributes");
close(fd[portnum]);
return FALSE;
}
}

/* Flush the input and output buffers */
Expand Down