Ejemplo n.º 1
0
Archivo: init.c Proyecto: Fyleo/rtems
/*
 *  Test converting baud number to termios baud constant
 */
static void test_termios_number_to_baud(void)
{
  int i;
  tcflag_t termios_baud;

  puts(
    "\n"
    "Test termios_number_to_baud..."
  );
  puts( "termios_number_to_baud(-2) - NOT OK" );
  termios_baud = rtems_termios_number_to_baud( INVALID_BAUD );
  rtems_test_assert( termios_baud == 0 );

  for (i=0 ; baud_table[i].constant != INVALID_CONSTANT ; i++ ) {
    printf(
      "termios_number_to_baud(B%" PRIdrtems_termios_baud_t ") - OK\n",
      baud_table[i].baud
    );
    termios_baud = rtems_termios_number_to_baud( baud_table[i].baud );
    if ( termios_baud != baud_table[i].constant ) {
      printf(
        "ERROR - returned %d should be %d\n",
        termios_baud,
        baud_table[i].constant
      );
      rtems_test_exit(0);
    }
  }
}
Ejemplo n.º 2
0
/*
 *  Test converting baud number to termios baud constant
 */
void test_termios_number_to_baud(void)
{
  int i;
  int termios_baud;

  puts(
    "\n"
    "Test termios_number_to_baud..."
  );
  puts( "termios_number_to_baud(-2) - NOT OK" );
  i = rtems_termios_number_to_baud( -2 );
  rtems_test_assert( i == -1 );

  puts( "termios_number_to_baud(572) - NOT OK" );
  i = rtems_termios_number_to_baud( -2 );
  rtems_test_assert( i == -1 );

  for (i=0 ; baud_table[i].constant != -1 ; i++ ) {
    printf( "termios_number_to_baud(B%" PRIdrtems_termios_baud_t ") - OK\n", baud_table[i].baud );
    termios_baud = rtems_termios_number_to_baud( baud_table[i].baud );
    if ( termios_baud != baud_table[i].constant ) {
      printf(
        "ERROR - returned %d should be %d\n",
        termios_baud,
        baud_table[i].constant
      );
      rtems_test_exit(0);
    }
  }
}
Ejemplo n.º 3
0
int  rtems_termios_set_initial_baud(
  struct rtems_termios_tty *ttyp,
  int32_t                   baud
)
{
  int cflags_baud;

  cflags_baud = rtems_termios_number_to_baud(baud);
  if ( cflags_baud == -1 )
    return -1;

  ttyp->termios.c_cflag = (ttyp->termios.c_cflag & ~CBAUD) | cflags_baud;

  return 0;
}
Ejemplo n.º 4
0
int rtems_termios_set_initial_baud(
  struct rtems_termios_tty *tty,
  rtems_termios_baud_t baud
)
{
  int rv = 0;
  speed_t spd = rtems_termios_number_to_baud(baud);

  if ( spd != 0 ) {
    tty->termios.c_ispeed = spd;
    tty->termios.c_ospeed = spd;
  } else {
    rv = -1;
  }

  return rv;
}