serial: uart_native_pty_bottom: length parameter
Add a length parameter to the poll in read function so that data can be read in larger chunks. Signed-off-by: Jordan Yates <jordan@embeint.com>
This commit is contained in:
parent
780379e333
commit
3d344186fc
3 changed files with 8 additions and 9 deletions
|
@ -170,13 +170,11 @@ static int np_uart_stdin_poll_in(const struct device *dev, unsigned char *p_char
|
|||
return -1;
|
||||
}
|
||||
|
||||
rc = np_uart_stdin_poll_in_bottom(in_f, p_char);
|
||||
rc = np_uart_stdin_poll_in_bottom(in_f, p_char, 1);
|
||||
if (rc == -2) {
|
||||
disconnected = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
return rc == 1 ? 0 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,12 +32,13 @@
|
|||
*
|
||||
* @param in_f Input file descriptor
|
||||
* @param p_char Pointer to character.
|
||||
* @param len Maximum number of characters to read.
|
||||
*
|
||||
* @retval 0 If a character arrived and was stored in p_char
|
||||
* @retval >0 Number of characters actually read
|
||||
* @retval -1 If no character was available to read
|
||||
* @retval -2 if the stdin is disconnected
|
||||
*/
|
||||
int np_uart_stdin_poll_in_bottom(int in_f, unsigned char *p_char)
|
||||
int np_uart_stdin_poll_in_bottom(int in_f, unsigned char *p_char, int len)
|
||||
{
|
||||
if (feof(stdin)) {
|
||||
/*
|
||||
|
@ -64,12 +65,12 @@ int np_uart_stdin_poll_in_bottom(int in_f, unsigned char *p_char)
|
|||
ERROR("%s: Error on select ()\n", __func__);
|
||||
}
|
||||
|
||||
n = read(in_f, p_char, 1);
|
||||
n = read(in_f, p_char, len);
|
||||
if ((n == -1) || (n == 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@ extern "C" {
|
|||
|
||||
/* Note: None of these functions are public interfaces. But internal to the native ptty driver */
|
||||
|
||||
int np_uart_stdin_poll_in_bottom(int in_f, unsigned char *p_char);
|
||||
int np_uart_stdin_poll_in_bottom(int in_f, unsigned char *p_char, int len);
|
||||
int np_uart_slave_connected(int fd);
|
||||
int np_uart_open_pty(const char *uart_name, const char *auto_attach_cmd,
|
||||
bool do_auto_attach, bool wait_pts);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue