le_tty.h File Reference

Go to the source code of this file.

Enumerations

enum  tty_FlowControl_t { LE_TTY_FLOW_CONTROL_NONE = 0, LE_TTY_FLOW_CONTROL_XON_XOFF = 1, LE_TTY_FLOW_CONTROL_HARDWARE = 2 }
 
enum  tty_Speed_t {
  LE_TTY_SPEED_0 = 0, LE_TTY_SPEED_50, LE_TTY_SPEED_75, LE_TTY_SPEED_110,
  LE_TTY_SPEED_134, LE_TTY_SPEED_150, LE_TTY_SPEED_200, LE_TTY_SPEED_300,
  LE_TTY_SPEED_600, LE_TTY_SPEED_1200, LE_TTY_SPEED_1800, LE_TTY_SPEED_2400,
  LE_TTY_SPEED_4800, LE_TTY_SPEED_9600, LE_TTY_SPEED_19200, LE_TTY_SPEED_38400,
  LE_TTY_SPEED_57600, LE_TTY_SPEED_115200, LE_TTY_SPEED_230400, LE_TTY_SPEED_460800,
  LE_TTY_SPEED_500000, LE_TTY_SPEED_576000, LE_TTY_SPEED_921600, LE_TTY_SPEED_1000000,
  LE_TTY_SPEED_1152000, LE_TTY_SPEED_1500000, LE_TTY_SPEED_2000000, LE_TTY_SPEED_2500000,
  LE_TTY_SPEED_3000000, LE_TTY_SPEED_3500000, LE_TTY_SPEED_4000000
}
 

Functions

int le_tty_Open (const char *ttyDev, int flags)
 
void le_tty_Close (int fd)
 
le_result_t le_tty_SetBaudRate (int fd, tty_Speed_t ttyRate)
 
le_result_t le_tty_GetBaudRate (int fd, tty_Speed_t *ttyInRatePtr, tty_Speed_t *ttyOutRatePtr)
 
le_result_t le_tty_SetFraming (int fd, char parity, int wordSize, int stopBits)
 
le_result_t le_tty_SetFlowControl (int fd, tty_FlowControl_t ttyFlowControl)
 
le_result_t le_tty_SetCanonical (int fd)
 
le_result_t le_tty_SetRaw (int fd, int numChars, int timeout)
 

Detailed Description

Legato tty API include file

Function Documentation

◆ le_tty_Close()

void le_tty_Close ( int  fd)

Close and unlock a serial port file descriptor.

Parameters
[in]fdFile descriptor

◆ le_tty_GetBaudRate()

le_result_t le_tty_GetBaudRate ( int  fd,
tty_Speed_t *  ttyInRatePtr,
tty_Speed_t *  ttyOutRatePtr 
)

Get baud rate of serial port.

Returns
  • LE_OK if successful = - LE_NOT_FOUND if speed is not supported by legato
  • LE_FAULT for any other error
Parameters
[in]fdFile Descriptor
[out]ttyInRatePtrinput baud rate
[out]ttyOutRatePtroutput baud rate

◆ le_tty_Open()

int le_tty_Open ( const char *  ttyDev,
int  flags 
)

Open a serial port device and locks it for exclusive use.

Returns
  • Serial port file descriptor number on success.
  • -1 on failure.
Parameters
[in]ttyDevPath name
[in]flagsflags used in open(2)

◆ le_tty_SetBaudRate()

le_result_t le_tty_SetBaudRate ( int  fd,
tty_Speed_t  ttyRate 
)

Set baud rate of serial port.

Returns
  • LE_OK if successful
  • LE_UNSUPPORTED if value cannot be set
  • LE_NOT_FOUND if value is not supported
  • LE_FAULT for any other error
Parameters
[in]fdFile Descriptor
[in]ttyRateBaud rate

◆ le_tty_SetCanonical()

le_result_t le_tty_SetCanonical ( int  fd)

Set serial port into terminal mode. Converts EOL characters to unix format, enables local echo, line mode, etc.

Returns
  • LE_OK if successful
  • LE_UNSUPPORTED if canonical mode cannot be set
  • LE_FAULT for any other error
Parameters
[in]fdFile Descriptor

◆ le_tty_SetFlowControl()

le_result_t le_tty_SetFlowControl ( int  fd,
tty_FlowControl_t  ttyFlowControl 
)

Set flow control option on serial port. Flow control options are: LE_TTY_FLOW_CONTROL_NONE - flow control disabled LE_TTY_FLOW_CONTROL_XON_XOFF - software flow control (XON/XOFF) LE_TTY_FLOW_CONTROL_HARDWARE - hardware flow control (RTS/CTS)

Returns
  • LE_OK if successful
  • LE_UNSUPPORTED if value cannot be set
  • LE_NOT_FOUND if value is not supported
  • LE_FAULT for any other error
Parameters
[in]fdFile decriptor
[in]ttyFlowControlFlow control option

◆ le_tty_SetFraming()

le_result_t le_tty_SetFraming ( int  fd,
char  parity,
int  wordSize,
int  stopBits 
)

Set framing on serial port. Use human-readable characters/numbers such as 'N', 8, 1 to indicate parity, word size and stop bit settings.

Returns
  • LE_OK if successful
  • LE_UNSUPPORTED if value cannot be set
  • LE_NOT_FOUND if value is not supported
  • LE_FAULT for any other error
Parameters
[in]fdFile Descriptor
[in]parityParity ('N','O','E')
[in]wordSizeData bits (5,6,7,8)
[in]stopBitsStop bits (1,2)

◆ le_tty_SetRaw()

le_result_t le_tty_SetRaw ( int  fd,
int  numChars,
int  timeout 
)

Set serial port into raw (non-canonical) mode. Disables conversion of EOL characters, disables local echo, sets character mode, read timeouts, etc.

Returns
  • LE_OK if successful
  • LE_UNSUPPORTED if raw mode cannot be set
  • LE_FAULT for any other error
Parameters
[in]fdFile Descriptor
[in]numCharsNumber of bytes returned by read(2) when a read is performed.
[in]timeoutwhen a read(2) is performed return after that timeout. The timeout value is given with 1 decimal places.