Modules | |
TTY files | |
Classes | |
struct | MagAOX::tty::telnetConn |
A Telnet connection manager, wrapping libtelnet . More... | |
struct | MagAOX::tty::usbDevice |
A USB device as a TTY device. More... | |
Functions | |
std::string | MagAOX::tty::ttyErrorString (int ec) |
Get a text explanation of a TTY_E_ error code. More... | |
int | MagAOX::tty::ttyOpenRaw (int &fileDescrip, std::string &deviceName, speed_t speed) |
Open a file as a raw-mode tty device. More... | |
bool | MagAOX::tty::isEndOfTrans (const std::string &strRead, const std::string &eot) |
Check if the end of the buffer contains the end-of-transmission string. More... | |
int | MagAOX::tty::ttyWrite (const std::string &buffWrite, int fd, int timeoutWrite) |
Write to the tty console indicated by a file descriptor. More... | |
int | MagAOX::tty::ttyReadRaw (std::vector< unsigned char > &vecRead, int &readBytes, int fd, int timeoutRead) |
Read from a tty console indicated by a file-descriptor, up to a given number of bytes. More... | |
int | MagAOX::tty::ttyRead (std::string &strRead, int bytes, int fd, int timeoutRead) |
Read from a tty console indicated by a file-descriptor, until a given number of bytes are read. More... | |
int | MagAOX::tty::ttyRead (std::string &strRead, const std::string &eot, int fd, int timeoutRead) |
Read from a tty console indicated by a file-descriptor, until an end of transmission string is read. More... | |
int | MagAOX::tty::ttyWriteRead (std::string &strRead, const std::string &strWrite, const std::string &eot, bool swallowEcho, int fd, int timeoutWrite, int timeoutRead) |
Write to a tty on an open file descriptor, then get the result. More... | |
int | MagAOX::tty::ttyUSBDevName (std::string &devName, const std::string &vendor, const std::string &product, const std::string &serial) |
Get the ttyUSB device name for a specific device. More... | |
int | MagAOX::tty::ttyUSBDevNames (std::vector< std::string > &devNames, const std::string &vendor, const std::string &product) |
Get the ttyUSB device name for a set of devices specified by their vendor and product ids. More... | |
Variables | |
static const telnet_telopt_t | MagAOX::tty::telopts [] |
libtelnet option table. More... | |
Using screen
to talk to TTY devices.
The screen
program needs to be installed. You will need root privileges (sudo works).
$ screen /dev/ttyUSBX 115200
where you replace the dev node with the correct path, and the baud rate with the correct value. See the particular devices specs for the correct baud rate to use. Also See https:// for a list of baud rates.
Note that screen does not echo, so if the device doesn't echo you won't see the characters you type.
bool MagAOX::tty::isEndOfTrans | ( | const std::string & | strRead, |
const std::string & | eot | ||
) |
Check if the end of the buffer contains the end-of-transmission string.
[in] | strRead | The read buffer to check |
[in] | eot | The end-of-transmission string |
Definition at line 116 of file ttyIOUtils.cpp.
Referenced by MagAOX::tty::telnetConn::read(), MagAOX::tty::ttyRead(), and MagAOX::tty::telnetConn::writeRead().
std::string MagAOX::tty::ttyErrorString | ( | int | ec | ) |
Get a text explanation of a TTY_E_ error code.
[in] | ec | the error code |
Definition at line 15 of file ttyErrors.cpp.
Referenced by MagAOX::app::filterWheelCtrl::appLogic(), MagAOX::app::flipperCtrl::appLogic(), MagAOX::app::koolanceCtrl::appLogic(), MagAOX::app::pi335Ctrl::appLogic(), MagAOX::app::picoMotorCtrl::appLogic(), MagAOX::app::smc100ccCtrl::appLogic(), MagAOX::app::tcsInterface::appLogic(), MagAOX::app::trippLitePDU::appLogic(), MagAOX::app::zaberLowLevel::appLogic(), MagAOX::app::picoMotorCtrl::channelThreadExec(), MagAOX::app::rhusbMon::connect(), MagAOX::app::trippLitePDU::devStatus(), MagAOX::app::pi335Ctrl::finishInit(), MagAOX::app::pi335Ctrl::getCom(), MagAOX::app::smc100ccCtrl::getCtrlState(), MagAOX::app::smc100ccCtrl::getLastError(), MagAOX::app::smc100ccCtrl::getPosition(), MagAOX::app::filterWheelCtrl::home(), MagAOX::app::pi335Ctrl::home_1(), MagAOX::app::pi335Ctrl::home_2(), MagAOX::app::pi335Ctrl::home_3(), MagAOX::app::pi335Ctrl::initDM(), MagAOX::app::filterWheelCtrl::loadConfig(), MagAOX::app::smc100ccCtrl::loadConfig(), MagAOX::app::zaberLowLevel::loadConfig(), MagAOX::app::flipperCtrl::loadConfigImpl(), MagAOX::app::koolanceCtrl::loadConfigImpl(), MagAOX::app::pi335Ctrl::loadConfigImpl(), MagAOX::app::pi335Ctrl::move_1(), MagAOX::app::pi335Ctrl::move_2(), MagAOX::app::pi335Ctrl::move_3(), MagAOX::app::smc100ccCtrl::moveTo(), MagAOX::app::filterWheelCtrl::moveToRaw(), MagAOX::app::filterWheelCtrl::moveToRawRelative(), MagAOX::app::filterWheelCtrl::onPowerOnConnect(), MagAOX::app::rhusbMon::readProbe(), MagAOX::app::pi335Ctrl::releaseDM(), MagAOX::app::smc100ccCtrl::startHoming(), MagAOX::app::filterWheelCtrl::stop(), MagAOX::app::smc100ccCtrl::stop(), MagAOX::app::pi335Ctrl::testConnection(), MagAOX::app::smc100ccCtrl::testConnection(), MagAOX::app::siglentSDG::writeCommand(), and MagAOX::app::siglentSDG::writeRead().
int MagAOX::tty::ttyOpenRaw | ( | int & | fileDescrip, |
std::string & | deviceName, | ||
speed_t | speed | ||
) |
Open a file as a raw-mode tty device.
[out] | fileDescrip | the file descriptor. Set to 0 on an error. |
[in] | deviceName | the device path name, e.g. /dev/ttyUSB0 |
[in] | speed | indicates the baud rate (see http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html) |
Definition at line 72 of file ttyIOUtils.cpp.
Referenced by MagAOX::tty::usbDevice::connect().
int MagAOX::tty::ttyRead | ( | std::string & | strRead, |
const std::string & | eot, | ||
int | fd, | ||
int | timeoutRead | ||
) |
Read from a tty console indicated by a file-descriptor, until an end of transmission string is read.
[out] | strRead | The string in which to store the output. |
[in] | eot | A sequence of characters which indicates the end of transmission. |
[in] | fd | The file descriptor of the open tty. |
[in] | timeoutRead | The timeout in milliseconds. |
Definition at line 271 of file ttyIOUtils.cpp.
int MagAOX::tty::ttyRead | ( | std::string & | strRead, |
int | bytes, | ||
int | fd, | ||
int | timeoutRead | ||
) |
Read from a tty console indicated by a file-descriptor, until a given number of bytes are read.
[out] | strRead | The string in which to store the output. |
[in] | bytes | the number of bytes to read |
[in] | fd | The file descriptor of the open tty. |
[in] | timeoutRead | The timeout in milliseconds. |
Definition at line 206 of file ttyIOUtils.cpp.
Referenced by MagAOX::app::filterWheelCtrl::appLogic(), MagAOX::app::flipperCtrl::getPos(), MagAOX::app::koolanceCtrl::getStatus(), and MagAOX::tty::ttyWriteRead().
int MagAOX::tty::ttyReadRaw | ( | std::vector< unsigned char > & | vecRead, |
int & | readBytes, | ||
int | fd, | ||
int | timeoutRead | ||
) |
Read from a tty console indicated by a file-descriptor, up to a given number of bytes.
Polls before attempting to read, but does not wait for all bytes to be ready.
[out] | vecRead | The buffer in which to store the output. |
[out] | readBytes | The number of bytes read. |
[in] | fd | The file descriptor of the open tty. |
[in] | timeoutRead | The timeout in milliseconds. |
Definition at line 172 of file ttyIOUtils.cpp.
Referenced by MagAOX::app::koolanceCtrl::initialConnect().
int MagAOX::tty::ttyUSBDevName | ( | std::string & | devName, |
const std::string & | vendor, | ||
const std::string & | product, | ||
const std::string & | serial | ||
) |
Get the ttyUSB device name for a specific device.
[out] | devName | the /dev/ttyUSBX device name. |
[in] | vendor | the 4-digit vendor identifier. |
[in] | product | the 4-digit product identifier. |
[in] | serial | the serial number. Can be "". |
Definition at line 30 of file ttyUSB.cpp.
Referenced by MagAOX::tty::usbDevice::getDeviceName().
int MagAOX::tty::ttyUSBDevNames | ( | std::vector< std::string > & | devNames, |
const std::string & | vendor, | ||
const std::string & | product | ||
) |
Get the ttyUSB device name for a set of devices specified by their vendor and product ids.
[out] | devNames | the /dev/ttyUSBX device names for all matching devices. |
[in] | vendor | the 4-digit vendor identifier. |
[in] | product | the 4-digit product identifier. |
Definition at line 137 of file ttyUSB.cpp.
Referenced by MagAOX::app::usbtempMon::checkConnections().
int MagAOX::tty::ttyWrite | ( | const std::string & | buffWrite, |
int | fd, | ||
int | timeoutWrite | ||
) |
Write to the tty console indicated by a file descriptor.
[in] | buffWrite | The characters to write to the tty. |
[in] | fd | The file descriptor of the open tty. |
[in] | timeoutWrite | The timeout in milliseconds. |
Definition at line 132 of file ttyIOUtils.cpp.
Referenced by MagAOX::app::smc100ccCtrl::appLogic(), MagAOX::app::pi335Ctrl::finishInit(), MagAOX::app::flipperCtrl::getPos(), MagAOX::app::filterWheelCtrl::home(), MagAOX::app::pi335Ctrl::home_1(), MagAOX::app::pi335Ctrl::home_2(), MagAOX::app::pi335Ctrl::home_3(), MagAOX::app::pi335Ctrl::initDM(), MagAOX::app::pi335Ctrl::move_1(), MagAOX::app::pi335Ctrl::move_2(), MagAOX::app::pi335Ctrl::move_3(), MagAOX::app::smc100ccCtrl::moveTo(), MagAOX::app::flipperCtrl::moveTo(), MagAOX::app::filterWheelCtrl::moveToRaw(), MagAOX::app::filterWheelCtrl::moveToRawRelative(), MagAOX::app::filterWheelCtrl::onPowerOnConnect(), MagAOX::app::pi335Ctrl::releaseDM(), MagAOX::app::smc100ccCtrl::startHoming(), MagAOX::app::filterWheelCtrl::stop(), MagAOX::app::smc100ccCtrl::stop(), and MagAOX::tty::ttyWriteRead().
int MagAOX::tty::ttyWriteRead | ( | std::string & | strRead, |
const std::string & | strWrite, | ||
const std::string & | eot, | ||
bool | swallowEcho, | ||
int | fd, | ||
int | timeoutWrite, | ||
int | timeoutRead | ||
) |
Write to a tty on an open file descriptor, then get the result.
The read is conducted until an end-of-transmission string is received. Echo characters are swallowed if desired.
[out] | strRead | The string in which to store the output. |
[in] | strWrite | The characters to write to the tty. |
[in] | eot | A sequence of characters which indicates the end of transmission. |
[in] | swallowEcho | If true, strWrite.size() characters are read after the write |
[in] | fd | The file descriptor of the open tty. |
[in] | timeoutWrite | The write timeout in milliseconds. |
[in] | timeoutRead | The read timeout in milliseconds. |
Definition at line 332 of file ttyIOUtils.cpp.
Referenced by MagAOX::app::pi335Ctrl::finishInit(), MagAOX::app::pi335Ctrl::getCom(), MagAOX::app::smc100ccCtrl::getCtrlState(), MagAOX::app::smc100ccCtrl::getLastError(), MagAOX::app::filterWheelCtrl::getMoving(), MagAOX::app::filterWheelCtrl::getPos(), MagAOX::app::smc100ccCtrl::getPosition(), MagAOX::app::filterWheelCtrl::getSwitch(), MagAOX::app::pi335Ctrl::initDM(), MagAOX::app::rhusbMon::readProbe(), MagAOX::app::pi335Ctrl::testConnection(), and MagAOX::app::smc100ccCtrl::testConnection().
|
static |
libtelnet option table.
Definition at line 49 of file telnetConn.hpp.
Referenced by MagAOX::tty::telnetConn::connect().