Exemple #1
0
void pseudo_terminal_device::queue(void)
{
		if (is_transmit_register_empty())
		{
				if (m_input_index == m_input_count)
				{
					m_input_index = 0;
					int tmp = read(m_input_buffer , sizeof(m_input_buffer));
					if (tmp > 0) {
						m_input_count = tmp;
					} else {
						m_input_count = 0;
					}
				}

				if (m_input_count != 0)
				{
						transmit_register_setup(m_input_buffer[ m_input_index++ ]);

						m_timer_poll->adjust(attotime::never);
				}
				else
				{
						int txbaud = convert_baud(m_rs232_txbaud->read());
						m_timer_poll->adjust(attotime::from_hz(txbaud));
				}
		}
}
Exemple #2
0
void null_modem_device::queue()
{
	if (is_transmit_register_empty())
	{
		if (m_input_index == m_input_count)
		{
			m_input_index = 0;
			m_input_count = m_stream->input(m_input_buffer, sizeof(m_input_buffer));
		}

		if (m_input_count != 0)
		{
			transmit_register_setup(m_input_buffer[m_input_index++]);

			m_timer_poll->adjust(attotime::never);
		}
		else
		{
			int txbaud = convert_baud(m_rs232_txbaud->read());
			m_timer_poll->adjust(attotime::from_hz(txbaud));
		}
	}
}
boolean bt_hci_qcomm_pfal_changebaudrate (unsigned long new_baud)
{
  struct termios term;
  boolean        status = TRUE;
  speed_t baud_code;
  speed_t actual_baud_code;
#if defined(BOTHER)
  struct termios2 term2;
#endif /* defined(BOTHER) */
  
  if (tcgetattr(fd, &term) < 0) 
  {
    perror("Can't get port settings");
    status = FALSE;
  }
  else
  {  
    baud_code = convert_baud(new_baud);
#if defined(BOTHER)
    if (ioctl(fd, TCGETS2, &term2) == -1)
    {
      perror("bt_hci_qcomm_pfal_changebaudrate: TCGETS2:");
      return FALSE;
    }
    term2.c_ospeed = term2.c_ispeed = (speed_t) new_baud;
    term2.c_cflag &= ~CBAUD;
    term2.c_cflag |= BOTHER;
    if (ioctl(fd, TCSETS2, &term2) == -1)
    {
      perror("bt_hci_qcomm_pfal_changebaudrate: TCGETS2:");
      return FALSE;
    }
    /* read it back and see what we got */
    if (ioctl(fd, TCGETS2, &term2) == -1)
    {
      perror("bt_hci_qcomm_pfal_changebaudrate: TCGETS2:");
      return FALSE;
    }
    if (verbose)
    {
      fprintf(stderr, "bt_hci_qcomm_pfal_changebaudrate: new rates %d, %d\n", term2.c_ispeed, term2.c_ospeed); 
    }   
#else /* No BOTHER */
    (void) cfsetospeed(&term, baud_code);
    if (tcsetattr(fd, TCSADRAIN, &term) < 0) /* don't change speed until last write done */
    {
      perror("bt_hci_qcomm_pfal_changebaudrate: tcsetattr:");
      status = FALSE;
    }
#endif /* BOTHER */

    /* make sure that we reportedly got the speed we tried to set */
    if (1 < verbose)
    {
      if (tcgetattr(fd, &term) < 0)
      {
        perror("bt_hci_qcomm_pfal_changebaudrate: tcgetattr:");
        status = FALSE;
      }
      if (baud_code != (actual_baud_code = cfgetospeed(&term)))
      {
        fprintf(stderr, "bt_hci_qcomm_pfal_changebaudrate: new baud %lu FAILED, got 0x%x\n", new_baud, actual_baud_code);
      }
      else
      {
        fprintf(stderr, "bt_hci_qcomm_pfal_changebaudrate: new baud %lu SUCCESS, got 0x%x\n", new_baud, actual_baud_code);
      }
    }
  }

  return status;
}