|
Instrument Neutral Distributed Interface INDI 2.2.5
|
Base class for serial communications. More...
#include <ttybase.h>
Public Types | |
| enum | TTY_RESPONSE { TTY_OK = 0 , TTY_READ_ERROR = -1 , TTY_WRITE_ERROR = -2 , TTY_SELECT_ERROR = -3 , TTY_TIME_OUT = -4 , TTY_PORT_FAILURE = -5 , TTY_PARAM_ERROR = -6 , TTY_ERRNO = -7 , TTY_OVERFLOW = -8 } |
Public Member Functions | |
| TTYBase (const char *driverName) | |
| virtual | ~TTYBase () |
| TTY_RESPONSE | read (uint8_t *buffer, uint32_t nbytes, uint8_t timeout, uint32_t *nbytes_read) |
| read buffer from terminal | |
| TTY_RESPONSE | readSection (uint8_t *buffer, uint32_t nsize, uint8_t stop_byte, uint8_t timeout, uint32_t *nbytes_read) |
| read buffer from terminal with a delimiter | |
| TTY_RESPONSE | write (const uint8_t *buffer, uint32_t nbytes, uint32_t *nbytes_written) |
| Writes a buffer to fd. | |
| TTY_RESPONSE | writeString (const char *string, uint32_t *nbytes_written) |
| Writes a null terminated string to fd. | |
| TTY_RESPONSE | connect (const char *device, uint32_t bit_rate, uint8_t word_size, uint8_t parity, uint8_t stop_bits) |
| Establishes a tty connection to a terminal device. | |
| TTY_RESPONSE | disconnect () |
| Closes a tty connection and flushes the bus. | |
| void | setDebug (INDI::Logger::VerbosityLevel channel) |
| setDebug Enable or Disable debug logging | |
| const std::string | error (TTY_RESPONSE code) const |
| Retrieve the tty error message. | |
| int | getPortFD () const |
Base class for serial communications.
This class is the C++ implementation of indicom serial functionality. Due to the idiosyncrasies of different serial implementation (including TCP/UDP), the base class methods can be overridden to provide specific implementations for a particular serial behavior.
It provides methods to connect to and disconnect from serial devices, including TCP/UDP connections.
| TTYBase::TTYBase | ( | const char * | driverName | ) |
Definition at line 73 of file ttybase.cpp.
|
virtual |
Definition at line 78 of file ttybase.cpp.
| TTYBase::TTY_RESPONSE TTYBase::connect | ( | const char * | device, |
| uint32_t | bit_rate, | ||
| uint8_t | word_size, | ||
| uint8_t | parity, | ||
| uint8_t | stop_bits | ||
| ) |
Establishes a tty connection to a terminal device.
| device | the device node. e.g. /dev/ttyS0 |
| bit_rate | bit rate |
| word_size | number of data bits, 7 or 8, USE 8 DATA BITS with modbus |
| parity | 0=no parity, 1=parity EVEN, 2=parity ODD |
| stop_bits | number of stop bits : 1 or 2 |
Definition at line 534 of file ttybase.cpp.
| TTYBase::TTY_RESPONSE TTYBase::disconnect | ( | ) |
Closes a tty connection and flushes the bus.
Definition at line 722 of file ttybase.cpp.
| const std::string TTYBase::error | ( | TTY_RESPONSE | code | ) | const |
Retrieve the tty error message.
| err_code | the error code return by any TTY function. |
Definition at line 740 of file ttybase.cpp.
| TTYBase::TTY_RESPONSE TTYBase::read | ( | uint8_t * | buffer, |
| uint32_t | nbytes, | ||
| uint8_t | timeout, | ||
| uint32_t * | nbytes_read | ||
| ) |
read buffer from terminal
| fd | file descriptor |
| buf | pointer to store data. Must be initialized and big enough to hold data. |
| nbytes | number of bytes to read. |
| timeout | number of seconds to wait for terminal before a timeout error is issued. |
| nbytes_read | the number of bytes read. |
Definition at line 158 of file ttybase.cpp.
| TTYBase::TTY_RESPONSE TTYBase::readSection | ( | uint8_t * | buffer, |
| uint32_t | nsize, | ||
| uint8_t | stop_byte, | ||
| uint8_t | timeout, | ||
| uint32_t * | nbytes_read | ||
| ) |
read buffer from terminal with a delimiter
| fd | file descriptor |
| buf | pointer to store data. Must be initialized and big enough to hold data. |
| stop_char | if the function encounters stop_char then it stops reading and returns the buffer. |
| nsize | size of buf. If stop character is not encountered before nsize, the function aborts. |
| timeout | number of seconds to wait for terminal before a timeout error is issued. |
| nbytes_read | the number of bytes read. |
Definition at line 219 of file ttybase.cpp.
| void TTYBase::setDebug | ( | INDI::Logger::VerbosityLevel | channel | ) |
setDebug Enable or Disable debug logging
| enabled | If true, TTY traffic will be logged. |
| channel | Channel from INDI logger to log to. |
| TTYBase::TTY_RESPONSE TTYBase::write | ( | const uint8_t * | buffer, |
| uint32_t | nbytes, | ||
| uint32_t * | nbytes_written | ||
| ) |
Writes a buffer to fd.
| fd | file descriptor |
| buffer | a null-terminated buffer to write to fd. |
| nbytes | number of bytes to write from buffer |
| nbytes_written | the number of bytes written |
Definition at line 121 of file ttybase.cpp.
| TTYBase::TTY_RESPONSE TTYBase::writeString | ( | const char * | string, |
| uint32_t * | nbytes_written | ||
| ) |
Writes a null terminated string to fd.
| fd | file descriptor |
| buffer | the buffer to write to fd. |
| nbytes_written | the number of bytes written |
Definition at line 152 of file ttybase.cpp.