TwiceAsNice
2019-02-18
|
Functions | |
int | tty_read (int fd, char *buf, int nbytes, int timeout, int *nbytes_read) |
read buffer from terminal More... | |
int | tty_read_section (int fd, char *buf, char stop_char, int timeout, int *nbytes_read) |
read buffer from terminal with a delimiter More... | |
int | tty_nread_section (int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read) |
read buffer from terminal with a delimiter More... | |
int | tty_write (int fd, const char *buffer, int nbytes, int *nbytes_written) |
Writes a buffer to fd. More... | |
int | tty_write_string (int fd, const char *buffer, int *nbytes_written) |
Writes a null terminated string to fd. More... | |
int | tty_connect (const char *device, int bit_rate, int word_size, int parity, int stop_bits, int *fd) |
Establishes a tty connection to a terminal device. More... | |
int | tty_disconnect (int fd) |
Closes a tty connection and flushes the bus. More... | |
void | tty_error_msg (int err_code, char *err_msg, int err_msg_len) |
Retrieve the tty error message. More... | |
void | tty_set_debug (int debug) |
tty_set_debug Enable or disable debug which prints verbose information. More... | |
void | tty_set_gemini_udp_format (int enabled) |
void | tty_clr_trailing_read_lf (int enabled) |
int | tty_timeout (int fd, int timeout) |
void tty_clr_trailing_read_lf | ( | int | enabled | ) |
int tty_connect | ( | const char * | device, |
int | bit_rate, | ||
int | word_size, | ||
int | parity, | ||
int | stop_bits, | ||
int * | fd | ||
) |
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 |
fd | fd is set to the file descriptor value on success. |
int tty_disconnect | ( | int | fd | ) |
Closes a tty connection and flushes the bus.
fd | the file descriptor to close. |
void tty_error_msg | ( | int | err_code, |
char * | err_msg, | ||
int | err_msg_len | ||
) |
Retrieve the tty error message.
err_code | the error code return by any TTY function. |
err_msg | an initialized buffer to hold the error message. |
err_msg_len | length in bytes of err_msg |
int tty_nread_section | ( | int | fd, |
char * | buf, | ||
int | nsize, | ||
char | stop_char, | ||
int | timeout, | ||
int * | nbytes_read | ||
) |
read buffer from terminal with a delimiter
fd | file descriptor |
buf | pointer to store data. Must be initilized 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. |
int tty_read | ( | int | fd, |
char * | buf, | ||
int | nbytes, | ||
int | timeout, | ||
int * | nbytes_read | ||
) |
read buffer from terminal
fd | file descriptor |
buf | pointer to store data. Must be initilized 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. |
int tty_read_section | ( | int | fd, |
char * | buf, | ||
char | stop_char, | ||
int | timeout, | ||
int * | nbytes_read | ||
) |
read buffer from terminal with a delimiter
fd | file descriptor |
buf | pointer to store data. Must be initilized and big enough to hold data. |
stop_char | if the function encounters stop_char then it stops reading and returns the buffer. |
timeout | number of seconds to wait for terminal before a timeout error is issued. |
nbytes_read | the number of bytes read. |
void tty_set_debug | ( | int | debug | ) |
tty_set_debug Enable or disable debug which prints verbose information.
debug | 1 to enable, 0 to disable |
void tty_set_gemini_udp_format | ( | int | enabled | ) |
int tty_timeout | ( | int | fd, |
int | timeout | ||
) |
int tty_write | ( | int | fd, |
const char * | buffer, | ||
int | nbytes, | ||
int * | 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 |
int tty_write_string | ( | int | fd, |
const char * | buffer, | ||
int * | 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 |