Implement override of default RTS/DTR behavior for DVM-V24-V2 boards with hardware boot control. (#77)

* initial work to support DVM-V24 RTS/DTR boot modes

* whoops forgot to remove this debug print

---------

Co-authored-by: W3AXL <29879554+W3AXL@users.noreply.github.com>
pull/79/head
W3AXL 1 year ago committed by GitHub
parent aadfbd4393
commit 1528894099
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -552,12 +552,17 @@ bool Host::createModem()
}
if (portType == PTY_PORT) {
modemPort = new port::UARTPort(uartPort, serialSpeed, false);
modemPort = new port::UARTPort(uartPort, serialSpeed, false, false);
LogInfo(" PTY Port: %s", uartPort.c_str());
LogInfo(" PTY Speed: %u", uartSpeed);
}
else {
modemPort = new port::UARTPort(uartPort, serialSpeed, true);
if (modemMode == MODEM_MODE_DFSI) {
modemPort = new port::UARTPort(uartPort, serialSpeed, false, true);
LogInfo(" RTS/DTR boot flags enabled");
} else {
modemPort = new port::UARTPort(uartPort, serialSpeed, true, false);
}
LogInfo(" UART Port: %s", uartPort.c_str());
LogInfo(" UART Speed: %u", uartSpeed);
}

@ -30,7 +30,7 @@ using namespace modem::port;
/* Initializes a new instance of the PseudoPTYPort class. */
PseudoPTYPort::PseudoPTYPort(const std::string& symlink, SERIAL_SPEED speed, bool assertRTS) : UARTPort(speed, assertRTS),
PseudoPTYPort::PseudoPTYPort(const std::string& symlink, SERIAL_SPEED speed, bool assertRTS) : UARTPort(speed, assertRTS, false),
m_symlink(symlink)
{
/* stub */

@ -37,11 +37,12 @@ using namespace modem::port;
/* Initializes a new instance of the UARTPort class. */
UARTPort::UARTPort(const std::string& device, SERIAL_SPEED speed, bool assertRTS) :
UARTPort::UARTPort(const std::string& device, SERIAL_SPEED speed, bool assertRTS, bool rtsBoot) :
m_isOpen(false),
m_device(device),
m_speed(speed),
m_assertRTS(assertRTS),
m_rtsBoot(rtsBoot),
#if defined(_WIN32)
m_fd(INVALID_HANDLE_VALUE)
#else
@ -334,10 +335,11 @@ int UARTPort::setNonblock(bool nonblock)
/* Initializes a new instance of the UARTPort class. */
UARTPort::UARTPort(SERIAL_SPEED speed, bool assertRTS) :
UARTPort::UARTPort(SERIAL_SPEED speed, bool assertRTS, bool rtsBoot) :
m_isOpen(false),
m_speed(speed),
m_assertRTS(assertRTS),
m_rtsBoot(rtsBoot),
#if defined(_WIN32)
m_fd(INVALID_HANDLE_VALUE)
#else
@ -500,6 +502,40 @@ bool UARTPort::setTermios()
}
}
// Special setting of RTS/DTR for DVM-V24 boards with onboard DTR/RTS boot connections
if (m_rtsBoot) {
::LogInfoEx(LOG_MODEM, "RTS/DTR boot flag enabled, forcing board reset");
uint32_t y;
if (::ioctl(m_fd, TIOCMGET, &y) < 0) {
::LogError(LOG_HOST, "Cannot get the control attributes for %s", m_device.c_str());
::close(m_fd);
return false;
}
// Force RTS bit off
y &= ~TIOCM_RTS;
if (::ioctl(m_fd, TIOCMSET, &y) < 0) {
::LogError(LOG_HOST, "Cannot set the control attributes for %s", m_device.c_str());
::close(m_fd);
return false;
}
// Toggle DTR to force second reset
y &= ~TIOCM_DTR;
if (::ioctl(m_fd, TIOCMSET, &y) < 0) {
::LogError(LOG_HOST, "Cannot set the control attributes for %s", m_device.c_str());
::close(m_fd);
return false;
}
y |= TIOCM_DTR;
if (::ioctl(m_fd, TIOCMSET, &y) < 0) {
::LogError(LOG_HOST, "Cannot set the control attributes for %s", m_device.c_str());
::close(m_fd);
return false;
}
}
#if defined(__APPLE__)
setNonblock(false);
#endif

@ -76,7 +76,7 @@ namespace modem
* @param speed Serial port speed.
* @param assertRTS
*/
UARTPort(const std::string& device, SERIAL_SPEED speed, bool assertRTS = false);
UARTPort(const std::string& device, SERIAL_SPEED speed, bool assertRTS = false, bool rtsBoot = false);
/**
* @brief Finalizes a instance of the UARTPort class.
*/
@ -122,13 +122,14 @@ namespace modem
* @param speed Serial port speed.
* @param assertRTS
*/
UARTPort(SERIAL_SPEED speed, bool assertRTS = false);
UARTPort(SERIAL_SPEED speed, bool assertRTS = false, bool rtsBoot = false);
bool m_isOpen;
std::string m_device;
SERIAL_SPEED m_speed;
bool m_assertRTS;
bool m_rtsBoot;
#if defined(_WIN32)
HANDLE m_fd;
#else

Loading…
Cancel
Save

Powered by TurnKey Linux.