Allow for non-TTY links to the modem.
This commit is contained in:
parent
0dd446eb29
commit
9350fa8483
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2002-2004,2007-2011,2013,2014-2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2002-2004,2007-2011,2013,2014-2017,2019 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 1999-2001 by Thomas Sailor HB9JNX
|
* Copyright (C) 1999-2001 by Thomas Sailor HB9JNX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -251,12 +251,7 @@ bool CSerialController::open()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::isatty(m_fd) == 0) {
|
if (::isatty(m_fd) == 1) {
|
||||||
LogError("%s is not a TTY device", m_device.c_str());
|
|
||||||
::close(m_fd);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
termios termios;
|
termios termios;
|
||||||
if (::tcgetattr(m_fd, &termios) < 0) {
|
if (::tcgetattr(m_fd, &termios) < 0) {
|
||||||
LogError("Cannot get the attributes for %s", m_device.c_str());
|
LogError("Cannot get the attributes for %s", m_device.c_str());
|
||||||
|
@ -355,6 +350,7 @@ bool CSerialController::open()
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
setNonblock(false);
|
setNonblock(false);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +380,6 @@ int CSerialController::read(unsigned char* buffer, unsigned int length)
|
||||||
unsigned int offset = 0U;
|
unsigned int offset = 0U;
|
||||||
|
|
||||||
while (offset < length) {
|
while (offset < length) {
|
||||||
|
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(m_fd, &fds);
|
FD_SET(m_fd, &fds);
|
||||||
|
@ -432,7 +427,7 @@ bool CSerialController::canWrite(){
|
||||||
timeo.tv_sec = 0;
|
timeo.tv_sec = 0;
|
||||||
timeo.tv_usec = 0;
|
timeo.tv_usec = 0;
|
||||||
|
|
||||||
int rc = select(m_fd + 1, NULL, &wset, NULL, &timeo);
|
int rc = ::select(m_fd + 1, NULL, &wset, NULL, &timeo);
|
||||||
if (rc > 0 && FD_ISSET(m_fd, &wset))
|
if (rc > 0 && FD_ISSET(m_fd, &wset))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -478,3 +473,4 @@ void CSerialController::close()
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue