mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-30 00:14:26 +00:00
Merge pull request #234 from kanoi/master
fpgautils.c - must initialise c_cflag before using it
This commit is contained in:
commit
cc557b3f8d
29
fpgautils.c
29
fpgautils.c
@ -181,28 +181,33 @@ serial_open(const char*devpath, unsigned long baud, signed short timeout, bool p
|
|||||||
if (unlikely(fdDev == -1))
|
if (unlikely(fdDev == -1))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
struct termios pattr;
|
struct termios my_termios;
|
||||||
tcgetattr(fdDev, &pattr);
|
|
||||||
pattr.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
|
tcgetattr(fdDev, &my_termios);
|
||||||
pattr.c_oflag &= ~OPOST;
|
|
||||||
pattr.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
|
|
||||||
pattr.c_cflag &= ~(CSIZE | PARENB);
|
|
||||||
pattr.c_cflag |= CS8;
|
|
||||||
|
|
||||||
switch (baud) {
|
switch (baud) {
|
||||||
case 0: break;
|
case 0: break;
|
||||||
case 115200: pattr.c_cflag = B115200; break;
|
case 115200: my_termios.c_cflag = B115200; break;
|
||||||
default:
|
default:
|
||||||
applog(LOG_WARNING, "Unrecognized baud rate: %lu", baud);
|
applog(LOG_WARNING, "Unrecognized baud rate: %lu", baud);
|
||||||
}
|
}
|
||||||
pattr.c_cflag |= CREAD | CLOCAL;
|
|
||||||
|
my_termios.c_cflag |= CS8;
|
||||||
|
my_termios.c_cflag |= CREAD;
|
||||||
|
my_termios.c_cflag |= CLOCAL;
|
||||||
|
my_termios.c_cflag &= ~(CSIZE | PARENB);
|
||||||
|
|
||||||
|
my_termios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK |
|
||||||
|
ISTRIP | INLCR | IGNCR | ICRNL | IXON);
|
||||||
|
my_termios.c_oflag &= ~OPOST;
|
||||||
|
my_termios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
|
||||||
|
|
||||||
if (timeout >= 0) {
|
if (timeout >= 0) {
|
||||||
pattr.c_cc[VTIME] = (cc_t)timeout;
|
my_termios.c_cc[VTIME] = (cc_t)timeout;
|
||||||
pattr.c_cc[VMIN] = 0;
|
my_termios.c_cc[VMIN] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcsetattr(fdDev, TCSANOW, &pattr);
|
tcsetattr(fdDev, TCSANOW, &my_termios);
|
||||||
if (purge)
|
if (purge)
|
||||||
tcflush(fdDev, TCIOFLUSH);
|
tcflush(fdDev, TCIOFLUSH);
|
||||||
return fdDev;
|
return fdDev;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user