|
|
#define | USIN_CHAN_CNT 4 |
| | Number of input channels allocated.
|
| |
|
#define | USIN_CHAN_SIZE 256 |
| | Single channel buffer (FIFO) size.
|
| |
|
#define | USIN_MAX_READLINES 16 |
| | Max. number of lines supported in input buffer.
|
| |
|
#define | US_OVERFLOW_CHAR '\x0f' |
| | Character at end of the line when buffer overflow occurs.
|
| |
|
#define | US_LINEEND_CHAR '\n' |
| | End of line character.
|
| |
|
#define | US_CHAN0_CHAR '\x10' |
| | Channel ID for channel 0, other channel IDs sequentially follow.
|
| |
|
#define | US_MAX_CHANS 11 |
| | Theoretical limit of serial console protocol.
|
| |
|
#define | SER_IOCTL_READ ((int)(1<<31)) |
| | ioctl argument value to read data
|
| |
|
#define | SER_IOCTL_INVALID ((int)(1<<31)) |
| | ioctl return value indicating unknown operation
|
| |
|
#define | SERIO_IS_ENABLED 0x01 |
| | ioctl op (RW) - Serial console on/off
|
| |
|
#define | SERIO_IS_ACTIVE 0x02 |
| | ioctl op (R) - Enabled and USB connected -> active
|
| |
|
#define | SERIO_IS_CONNECTED 0x03 |
| | ioctl op (R) - Client connected
|
| |
|
#define | SERIO_LINE_READY 0x08 |
| | ioctl op (R) val=channel, Line is ready in input channel
|
| |
|
#define | SERIO_LINE_LENGTH 0x09 |
| | ioctl op (R) val=channel, Line length if line is ready, 0 otherwise
|
| |
|
#define | SERIO_SEND_PRINTF 0x10 |
| | ioctl op (RW) - Send printf output to serial console
|
| |
|
#define | SERIO_SEND_LCD 0x11 |
| | ioctl op (RW) - Send LCD contents over serial console
|
| |
|
#define | SERIO_SEND_KEYS 0x12 |
| | ioctl op (RW) - Send key scan changes to serial console
|
| |
|
#define | SERIO_SEND_IR 0x13 |
| | ioctl op (RW) - Send IR traffic over serial console
|
| |
|
#define | US_ICHAN_KEY 0 |
| | dedicated input channel
|
| |
|
#define | US_ICHAN_SYS 1 |
| | dedicated input channel
|
| |
|
#define | US_OCHAN_SYS 0 |
| | dedicated output channel
|
| |
|
#define | US_OCHAN_PRINTF 1 |
| | dedicated output channel
|
| |
| int usb_serial_read_line |
( |
uint8_t | chan_nr, |
|
|
uint8_t * | buf, |
|
|
int | buflen, |
|
|
uint8_t * | is_overflow ) |
Serial console read line.
- Parameters
-
| chan_nr | Channel number |
| buf | Buffer for read data (or NULL to discard the line) |
| buflen | Number of bytes available in buf |
| is_overflow | Pointer to overflow flag |
- Returns
- 0 if line isn't ready,
-1 buf cannot accommodate available line (buflen < line length),
otherwise, number of characters copied into buf (or discarded if buf == NULL).
Note that if number of read characters is < buflen, the read string is properly ended with '\0' character in buf.
Last character of line should be either '\n' (US_LINEEND_CHAR) or US_OVERFLOW_CHAR. Indicating whether line was read from serial line correctly (US_LINEEND_CHAR) or whether input buffer overflow occurred during line read (US_OVERFLOW_CHAR). The line is incomplete in later case. *is_overflow is set to 1 if is_overflow pointer is provided and read buffer overflow occurred while reading the line.
Before calling usb_serial_read_line the state of current line can be probed with usb_serial_ioctl calls:
usb_serial_ioctl(SERIO_LINE_READY, chan_nr); // To check whether line is ready
usb_serial_ioctl(SERIO_LINE_LENGTH, chan_nr); // To check line length if line is ready