aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils/comgt/patches/004-check_tty.patch
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2015-02-22 08:29:26 +0000
committerJohn Crispin <john@openwrt.org>2015-02-22 08:29:26 +0000
commit291e04ee8f47b86cbe3b63f2434c1c5e80bab678 (patch)
treeaccf003da3df1948791b440c5bd726c34282204d /package/network/utils/comgt/patches/004-check_tty.patch
parent6aab00fa44db337b35112b95d81bcdfd827d088d (diff)
downloadupstream-291e04ee8f47b86cbe3b63f2434c1c5e80bab678.tar.gz
upstream-291e04ee8f47b86cbe3b63f2434c1c5e80bab678.tar.bz2
upstream-291e04ee8f47b86cbe3b63f2434c1c5e80bab678.zip
comgt: Use TCGETS and TCSETS ioctls for struct termios
When passing struct termios to ioctl TCGETS and TCSETS should be used instead of TCGETA and TCSETA, which are meant for the older struct termio. Should fix https://dev.openwrt.org/ticket/19012 Signed-off-by: Matti Laakso <malaakso@elisanet.fi> SVN-Revision: 44506
Diffstat (limited to 'package/network/utils/comgt/patches/004-check_tty.patch')
-rw-r--r--package/network/utils/comgt/patches/004-check_tty.patch24
1 files changed, 12 insertions, 12 deletions
diff --git a/package/network/utils/comgt/patches/004-check_tty.patch b/package/network/utils/comgt/patches/004-check_tty.patch
index b81b0514c8..fb1d9af4bb 100644
--- a/package/network/utils/comgt/patches/004-check_tty.patch
+++ b/package/network/utils/comgt/patches/004-check_tty.patch
@@ -12,8 +12,8 @@
void setcom(void) {
stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits );
-- if (ioctl(comfd, TCSETA, &stbuf) < 0) {
-+ if (tty && ioctl(comfd, TCSETA, &stbuf) < 0) {
+- if (ioctl(comfd, TCSETS, &stbuf) < 0) {
++ if (tty && ioctl(comfd, TCSETS, &stbuf) < 0) {
serror("Can't ioctl set device",1);
}
}
@@ -21,8 +21,8 @@
if(strcmp(token,"hardcom")==0) {
if(comfd== -1) serror("Com device not open",1);
vmsg("Closing device");
-- if (ioctl(comfd, TCSETA, &svbuf) < 0) {
-+ if (tty && ioctl(comfd, TCSETA, &svbuf) < 0) {
+- if (ioctl(comfd, TCSETS, &svbuf) < 0) {
++ if (tty && ioctl(comfd, TCSETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl set device %s.\n",device);
serror(msg,1);
}
@@ -30,19 +30,19 @@
ext(1);
}
}
-- if (ioctl (comfd, TCGETA, &svbuf) < 0) {
+- if (ioctl (comfd, TCGETS, &svbuf) < 0) {
+ if (isatty (comfd))
+ tty=1;
+ else
+ tty=0;
-+ if (tty && ioctl (comfd, TCGETA, &svbuf) < 0) {
++ if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't control %s, please try again.\n",device);
serror(msg,1);
}
setenv("COMGTDEVICE",device,1);
-- ioctl(comfd, TCGETA, &stbuf);
+- ioctl(comfd, TCGETS, &stbuf);
+ if (tty)
-+ ioctl(comfd, TCGETA, &stbuf);
++ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
if (high_speed == 0) strcpy(cspeed,"115200");
else strcpy(cspeed,"57600");
@@ -51,18 +51,18 @@
}
else comfd=0;
-
-- if (ioctl (comfd, TCGETA, &svbuf) < 0) {
+- if (ioctl (comfd, TCGETS, &svbuf) < 0) {
+ if (isatty (comfd))
+ tty=1;
+ else
+ tty=0;
-+ if (tty && ioctl (comfd, TCGETA, &svbuf) < 0) {
++ if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl get device %s.\n",device);
serror(msg,1);
}
-- ioctl(comfd, TCGETA, &stbuf);
+- ioctl(comfd, TCGETS, &stbuf);
+ if (tty)
-+ ioctl(comfd, TCGETA, &stbuf);
++ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
switch(speed) {
case B0: strcpy(cspeed,"0");break;