Brkint Is Not Working

Brkint Is Not Working

BRKINT is not working

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);
  }

I have registered with the signal as: 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);
}

But still I am not getting signal when break is detected or when ctrlc is pressed.

7
Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.