API
MagAOX::tty Namespace Reference

Classes

struct  netSerial
 Manage a connectio to a serial device over a network. More...
 
struct  telnetConn
 A Telnet connection manager, wrapping libtelnet. More...
 
struct  usbDevice
 A USB device as a TTY device. More...
 

Functions

std::string ttyErrorString (int ec)
 Get a text explanation of a TTY_E_ error code. More...
 
int telnetCRLF (std::string &telnetStr, const std::string &inputStr)
 Replace lone \r and \n with \r\n for telnet-ness. More...
 
int ttyOpenRaw (int &fileDescrip, std::string &deviceName, speed_t speed)
 Open a file as a raw-mode tty device. More...
 
bool isEndOfTrans (const std::string &strRead, const std::string &eot)
 Check if the end of the buffer contains the end-of-transmission string. More...
 
int ttyWrite (const std::string &buffWrite, int fd, int timeoutWrite)
 Write to the tty console indicated by a file descriptor. More...
 
int 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 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 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 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 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 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 telopts []
 libtelnet option table. More...
 

Function Documentation

◆ telnetCRLF()

int MagAOX::tty::telnetCRLF ( std::string &  telnetStr,
const std::string &  inputStr 
)

Replace lone \r and \n with \r\n for telnet-ness.

Do it all at once instead of during char-by-char transmission cuz some devices (I'm looking at you SDG) get impatient and stop paying attention.

Returns
0 on success
-1 on error (nothing yet)
Parameters
[out]telnetStrthe string with \r an \n converted to \r\n
[in]inputStrthe string to be converted

Definition at line 26 of file ttyIOUtils.cpp.

Referenced by ttyIOUtils_test::SCENARIO(), and MagAOX::tty::telnetConn::write().