BRKINT不起作用

时间:2018-04-24 06:33:55

标签: c linux serial-port break termios

BRKINT无效

struct termios     term;
  uint8_t stop_bits = 0;
  memset(&term, 0, sizeof(struct termios));
  fd = open(device_name, O_RDWR);
  if(fd == -1)
  {
    LOGI("Could not open serial device file, errno : %d ", errno, 0, 0);
  }
  /* Change the mode to TTY. */
  LOGI("Successfully opened UART device file. FD is %d", uart_serial_fd);
  if (tcflush(fd, TCIOFLUSH) < 0)
  {
    LOGI("issue while tcflush ");
    close(fd);
  }
  if (tcgetattr(fd, &term) < 0) {
      LOGI("issue while tcgetattr ");
      close(fd);
  }
  cfmakeraw(&term);
  /* Set RTS/CTS HW Flow Control*/
  term.c_cflag |= (CRTSCTS | stop_bits);
  term.c_iflag |= BRKINT;
  if (tcsetattr(fd, TCSANOW, &term) < 0) {
     LOGI("issue while tcsetattr ");
     close(fd);
  }

我已将信号注册为: signal(SIGINT,sig_int_handler);

void sig_int_handler(int sig)
{
  LOGI("\n received break - sig int \n");
  LOG_MSG_INFO1("\n received break - sig int \n",0,0,0);
}

但是当检测到中断或按下 ctrl c 时,我仍然没有收到信号。

0 个答案:

没有答案