src/plugins/serial/serial_terminal.c
static int
serial_read_line(struct ipmi_intf * intf, char *str, int len)
{
	int rv, i;

	*str = 0;
	i = 0;
	while (i < len) {
		if (serial_wait_for_data(intf)) {
			return -1;
		}
		rv = read(intf->fd, str + i, 1);
		if (rv < 0) {
			return -1;
		} else if (!rv) {
			lperror(LOG_ERR, "Serial read failed: %s", strerror(errno));
			return -1;
		}
		if (str[i] == '\n' || str[i] == '\r') {
			if (verbose > 4) {
				char c = str[i];
				str[i] = '\0';
				fprintf(stderr, "Received data: %s\n", str);
				str[i] = c;
			}
			return i + 1;
		} else {
			i++;
		}
	}

	lprintf(LOG_ERR, "Serial data is too long");
	return -1;
}
/*
 *	Read a line from serial port
 *	Returns > 0 if there is a line, < 0 on error or timeout
 */
Read a line from serial port
Returns > 0 if there is a line, < 0 on error or timeout
Read a line from serial port Returns > 0 if there is a line < 0 on error or timeout
static int
serial_read_line(struct ipmi_intf * intf, char *str, int len)
{
	int rv, i;
	*str = 0;
	i = 0;
	while (i < len) {
		if (serial_wait_for_data(intf)) {
			return -1;
		}
		rv = read(intf->fd, str + i, 1);
		if (rv < 0) {
			return -1;
		} else if (!rv) {
			lperror(LOG_ERR, "Serial read failed: %s", strerror(errno));
			return -1;
		}
		if (str[i] == '\n' || str[i] == '\r') {
			if (verbose > 4) {
				char c = str[i];
				str[i] = '\0';
				fprintf(stderr, "Received data: %s\n", str);
				str[i] = c;
			}
			return i + 1;
		} else {
			i++;
		}
	}
	lprintf(LOG_ERR, "Serial data is too long");
	return -1;
}
static int serial_read_line ( struct ipmi_intf * intf , char * str , int len ) { int rv , i ; * str = 0 ; i = 0 ; while ( i < len ) { if ( serial_wait_for_data ( intf ) ) { return -1 ; } rv = read ( intf -> fd , str + i , 1 ) ; if ( rv < 0 ) { return -1 ; } else if ( ! rv ) { lperror ( LOG_ERR , " " , strerror ( errno ) ) ; return -1 ; } if ( str [ i ] == ' \n ' || str [ i ] == ' \r ' ) { if ( verbose > 4 ) { char c = str [ i ] ; str [ i ] = ' \0 ' ; fprintf ( stderr , " \n " , str ) ; str [ i ] = c ; } return i + 1 ; } else { i ++ ; } } lprintf ( LOG_ERR , " " ) ; return -1 ; }
Read a line from serial port
      Returns > 0 if there is a line, < 0 on error or timeout
Read a line from serial port Returns > 0 if there is a line < 0 on error or timeout