mirror of
https://github.com/UzixLS/picocom.git
synced 2025-07-19 07:21:18 +03:00
Type consistency tweaks
Better type consistency when returning enums flowcntrl_e and parity_e. See also PR #92.
This commit is contained in:
10
picocom.c
10
picocom.c
@ -66,6 +66,7 @@ const char *parity_str[] = {
|
||||
[P_ODD] = "odd",
|
||||
[P_MARK] = "mark",
|
||||
[P_SPACE] = "space",
|
||||
[P_ERROR] = "invalid parity mode",
|
||||
};
|
||||
|
||||
/* flow control modes names */
|
||||
@ -74,6 +75,7 @@ const char *flow_str[] = {
|
||||
[FC_RTSCTS] = "RTS/CTS",
|
||||
[FC_XONXOFF] = "xon/xoff",
|
||||
[FC_OTHER] = "other",
|
||||
[FC_ERROR] = "invalid flow control mode",
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
@ -850,7 +852,7 @@ baud_down (int baud)
|
||||
return nb;
|
||||
}
|
||||
|
||||
int
|
||||
enum flowcntrl_e
|
||||
flow_next (int flow)
|
||||
{
|
||||
switch(flow) {
|
||||
@ -871,7 +873,7 @@ flow_next (int flow)
|
||||
return flow;
|
||||
}
|
||||
|
||||
int
|
||||
enum parity_e
|
||||
parity_next (int parity)
|
||||
{
|
||||
switch(parity) {
|
||||
@ -1212,7 +1214,9 @@ int tty_q_push(const char *s, int len) {
|
||||
int
|
||||
do_command (unsigned char c)
|
||||
{
|
||||
int newbaud, newflow, newparity, newbits, newstopbits;
|
||||
int newbaud, newbits, newstopbits;
|
||||
enum flowcntrl_e newflow;
|
||||
enum parity_e newparity;
|
||||
const char *xfr_cmd;
|
||||
char *fname;
|
||||
unsigned char hexbuf[HEXBUF_SZ];
|
||||
|
4
term.c
4
term.c
@ -942,7 +942,7 @@ term_get_parity (int fd)
|
||||
|
||||
i = term_find(fd);
|
||||
if ( i < 0 ) {
|
||||
parity = -1;
|
||||
parity = P_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1155,7 +1155,7 @@ term_get_flowcntrl (int fd)
|
||||
|
||||
i = term_find(fd);
|
||||
if ( i < 0 ) {
|
||||
flow = -1;
|
||||
flow = FC_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
14
term.h
14
term.h
@ -161,6 +161,7 @@ enum term_errno_e {
|
||||
* P_ODD - odd parity
|
||||
* P_MARK - mark parity (parity bit always 1)
|
||||
* P_SPACE - space parity (parity bit always 0)
|
||||
* P_ERROR - marker to indicate error for functions returning parity_e
|
||||
*/
|
||||
enum parity_e {
|
||||
P_NONE = 0,
|
||||
@ -168,7 +169,7 @@ enum parity_e {
|
||||
P_ODD,
|
||||
P_MARK,
|
||||
P_SPACE,
|
||||
P_ERROR = -1
|
||||
P_ERROR
|
||||
};
|
||||
|
||||
/*
|
||||
@ -180,13 +181,14 @@ enum parity_e {
|
||||
* FC_RTSCTS - RTS/CTS handshaking, also known as hardware
|
||||
* flow-control.
|
||||
* FC_XONXOFF - xon/xoff flow control.
|
||||
* FC_ERROR - marker to indicate error for functions returning flowcntrl_e
|
||||
*/
|
||||
enum flowcntrl_e {
|
||||
FC_NONE = 0,
|
||||
FC_RTSCTS,
|
||||
FC_XONXOFF,
|
||||
FC_OTHER,
|
||||
FC_ERROR = -1
|
||||
FC_ERROR
|
||||
};
|
||||
|
||||
/*
|
||||
@ -551,8 +553,8 @@ int term_get_baudrate (int fd, int *ispeed);
|
||||
* Reads and decodes the current parity settings in the
|
||||
* "currtermios" structure of the managed filedes "fd".
|
||||
*
|
||||
* Returns one of the "enum parity_e" members, or -1 if "fd" does not
|
||||
* correspond to a managed filedes.
|
||||
* Returns one of the "enum parity_e" members. Returns P_ERROR if "fd"
|
||||
* does not correspond to a managed filedes.
|
||||
*/
|
||||
enum parity_e term_get_parity (int fd);
|
||||
|
||||
@ -581,8 +583,8 @@ int term_get_stopbits (int fd);
|
||||
* Reads and decodes the current flow-control settings in the
|
||||
* "currtermios" structure of the managed filedes "fd".
|
||||
*
|
||||
* Returns one of the "enum flowcntrl_e" members, or -1 if "fd" does
|
||||
* not correspond to a managed filedes.
|
||||
* Returns one of the "enum flowcntrl_e" members. Returns FC_ERROR if
|
||||
* "fd" does not correspond to a managed filedes.
|
||||
*/
|
||||
enum flowcntrl_e term_get_flowcntrl (int fd);
|
||||
|
||||
|
Reference in New Issue
Block a user