<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX Processors中的主题 Re: How to handle the interrupt_uart interrupt on imx6 ?</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905463#M136621</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank for your detailed reply.&lt;/P&gt;&lt;P&gt;I could hook-up SIGIO handler and see handler getting called when there is data on respective UART. but I have few issues:&lt;/P&gt;&lt;P&gt;1. SIGIO handler gets called only when bunch of bytes are available (not on each byte)&lt;/P&gt;&lt;P&gt;2. SIGIO getting called without missing as long as I had only UART_B, when I added UART_C also, i see inconsistency and data loss in handler.&lt;/P&gt;&lt;P&gt;3. I use Colibri iMX7d (emmc) evl board, I can use only 2 UART (B and C), not sure how and what to modify in device tree and rebuild bitbake to get all UART /dev/ttymx3 to 7&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pasting my code:&lt;/P&gt;&lt;P&gt;#define BAUDRATE B115200&lt;/P&gt;&lt;P&gt;#define COMM_PORT_B "/dev/ttymxc1"&lt;/P&gt;&lt;P&gt;#define COMM_PORT_C "/dev/ttymxc1"&lt;/P&gt;&lt;P&gt;#define COMM_PORT_D "/dev/ttymxc1"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define NO_OF_UART 2&lt;BR /&gt;static int fd[NO_OF_UART] = {0}; &lt;BR /&gt;static int max_fds = 0;&lt;BR /&gt;static fd_set read_fd;&lt;BR /&gt;static char comm_port[NO_OF_UART][16] = {&lt;BR /&gt; {COMM_PORT_B},&lt;BR /&gt; {COMM_PORT_C},&lt;BR /&gt;// {COMM_PORT_D},&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;static uint8_t uart_buf[UART_DATA_LEN];&lt;BR /&gt;volatile uint8_t uart_flag;&lt;/P&gt;&lt;P&gt;static void UART_INT (int sig)&lt;BR /&gt;{&lt;BR /&gt; char rx_buf[UART_DATA_LEN] = {'\0'};&lt;BR /&gt; int res = 0;&lt;BR /&gt; int i = 0;&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; NO_OF_UART; i++) &lt;BR /&gt; { &lt;BR /&gt; if(FD_ISSET(fd[i], &amp;amp;read_fd)) {&lt;BR /&gt; res = read(fd[i], &amp;amp;rx_buf, UART_DATA_LEN);&lt;BR /&gt; if(res &amp;gt; 0) {&lt;BR /&gt; //data received, copy into buffer with flag and clear the buffer&lt;BR /&gt; uart_flag |= (1&amp;lt;&amp;lt;i); //set respective flag&lt;BR /&gt; memcpy(uart_buf, rx_buf, res);&lt;BR /&gt; memset(rx_buf, '\0', UART_DATA_LEN);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;int init_uart(int *fd, const char *port)&lt;BR /&gt;{&lt;BR /&gt; int rc = 0;&lt;BR /&gt; char cmd[CMD_STR_LEN] = {'\0'};&lt;BR /&gt; struct termios newtio;&lt;BR /&gt; struct sigaction saio;&lt;/P&gt;&lt;P&gt;sprintf(cmd, "stty -F %s 115200 -echo", port); &lt;BR /&gt; system(cmd);&lt;/P&gt;&lt;P&gt;memset(cmd, '\0', CMD_STR_LEN);&lt;BR /&gt; sprintf(cmd, "cat &amp;lt; %s &amp;amp;", port);&lt;BR /&gt; system(cmd);&lt;BR /&gt; &lt;BR /&gt; *fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);&lt;BR /&gt; if(*fd &amp;lt; 0) {&lt;BR /&gt; perror(port); &lt;BR /&gt; exit(-1);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;saio.sa_handler = UART_INT;&lt;BR /&gt; sigemptyset(&amp;amp;saio.sa_mask);&lt;BR /&gt; saio.sa_flags = SA_SIGINFO;&lt;BR /&gt; sigaction(SIGIO, &amp;amp;saio,NULL);&lt;BR /&gt; &lt;BR /&gt; fcntl (*fd, F_SETOWN, getgid());&lt;BR /&gt; fcntl(*fd, F_SETFL, FASYNC);&lt;BR /&gt; &lt;BR /&gt; newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD ;&lt;BR /&gt; newtio.c_iflag = IGNPAR | IXOFF;&lt;BR /&gt; newtio.c_oflag = 0;&lt;BR /&gt; newtio.c_lflag = 0;&lt;BR /&gt; newtio.c_cc[VMIN] = 0;&lt;BR /&gt; newtio.c_cc[VTIME] = 0;&lt;BR /&gt; tcflush(*fd, TCIFLUSH);&lt;BR /&gt; tcsetattr(*fd, TCSANOW, &amp;amp;newtio);&lt;/P&gt;&lt;P&gt;return rc;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;static uint8_t cal_crc(uint8_t *byte, size_t len)&lt;BR /&gt;{&lt;BR /&gt; uint8_t crc = 0xFF;&lt;BR /&gt; size_t i, j;&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; len; i++) &lt;BR /&gt; {&lt;BR /&gt; crc ^= byte[i];&lt;BR /&gt; for(j = 0; j &amp;lt; 8; j++)&lt;BR /&gt; {&lt;BR /&gt; if((crc &amp;amp; 0x80) != 0) {&lt;BR /&gt; crc = (uint8_t) ((crc &amp;lt;&amp;lt; 1) ^ 0x31);&lt;BR /&gt; } else {&lt;BR /&gt; crc &amp;lt;&amp;lt;= 1;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; return crc;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int send_data(int fd, uint8_t *buf)&lt;BR /&gt;{&lt;BR /&gt; int rc = 0;&lt;BR /&gt; int size = buf[NO_OF_BYTES] + 2;&lt;BR /&gt; buf[size] = cal_crc(buf,buf[NO_OF_BYTES] + 1); &lt;BR /&gt; rc = write(fd, (char *)buf, size); &lt;BR /&gt; &lt;BR /&gt; return rc;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Keep reentrant as this function runs in serveral instances &lt;BR /&gt;static int uart_trigger(void *index)&lt;BR /&gt;{&lt;BR /&gt; int rc = 0;&lt;BR /&gt; do&lt;BR /&gt; {&lt;BR /&gt; FD_SET(fd[*(int *)index], &amp;amp;read_fd);&lt;BR /&gt; pselect(max_fds + 1, &amp;amp;read_fd, NULL, NULL, NULL, NULL);&lt;/P&gt;&lt;P&gt;}while(1);&lt;/P&gt;&lt;P&gt;return rc;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int largest_num(int arr[], int n)&lt;BR /&gt;{&lt;BR /&gt; int i;&lt;BR /&gt; int max = arr[0];&lt;BR /&gt; &lt;BR /&gt; for(i = 1; i &amp;lt; n; i++)&lt;BR /&gt; {&lt;BR /&gt; if(arr[i] &amp;gt; max) {&lt;BR /&gt; max = arr[i];&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; return max;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int uart_main(void *td)&lt;BR /&gt;{ &lt;BR /&gt; int rc = 0;&lt;BR /&gt; int mydata = *(int *)td;&lt;BR /&gt; int i = 0;&lt;BR /&gt; pthread_t thread_id[NO_OF_UART];&lt;BR /&gt; int tr = 0;&lt;BR /&gt; int arg[NO_OF_UART] = {0};&lt;BR /&gt; &lt;BR /&gt; printf("%s() called thread ID: %d\n", __FUNCTION__, mydata);&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; NO_OF_UART; i++) {&lt;BR /&gt; init_uart(&amp;amp;fd[i], comm_port[i]);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;//calculate max fds&lt;BR /&gt; max_fds = largest_num(fd, NO_OF_UART);&lt;/P&gt;&lt;P&gt;FD_ZERO(&amp;amp;read_fd);&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; NO_OF_UART; i++) {&lt;BR /&gt; arg[i] = i;&lt;BR /&gt; rc |= pthread_create(&amp;amp;(thread_id[i]), NULL, (void *) uart_trigger, (void *)&amp;amp;arg[i]);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; do {&lt;BR /&gt; switch(uart_flag)&lt;BR /&gt; {&lt;BR /&gt; case UART_B_DATA:&lt;BR /&gt; printf("UART_B: %s\n", uart_buf);&lt;BR /&gt; memset(uart_buf, '\0', UART_DATA_LEN);&lt;BR /&gt; uart_flag &amp;amp;= ~UART_B_DATA;&lt;/P&gt;&lt;P&gt;break;&lt;BR /&gt; case UART_C_DATA:&lt;BR /&gt; printf("UART_C: %s\n", uart_buf);&lt;BR /&gt; memset(uart_buf, '\0', UART_DATA_LEN);&lt;BR /&gt; uart_flag &amp;amp;= ~UART_C_DATA;&lt;/P&gt;&lt;P&gt;break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}while(1);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; for(i = 0; i &amp;lt; NO_OF_UART; i++) {&lt;BR /&gt; rc |=pthread_join(thread_id[i], (void **)&amp;amp;tr);&lt;BR /&gt; printf("Thread: %d %s\n", i, tr==0?"SUCCESS":"FAILED");&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; return rc; &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest me on this....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Aug 2019 17:31:12 GMT</pubDate>
    <dc:creator>neeraj_verma</dc:creator>
    <dc:date>2019-08-02T17:31:12Z</dc:date>
    <item>
      <title>How to handle the interrupt_uart interrupt on imx6 ?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905459#M136617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using UART 3 on imx6 and I want to know when my first byte is being sent.&lt;/P&gt;&lt;P&gt;At the moment, I'm polling the TXDC flag to know it but I want to do it with an interrupt.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The TCEN bit in UCR4, allows the interrupt to be asserted (interrupt_uart) but I don't know how to catch it !&lt;BR /&gt;I've configure many register to generate this interrupt but I don't know how to catch it ...&lt;/P&gt;&lt;P&gt;I you have any answers or tips to help me, it would be nice !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you already ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Florian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2019 08:00:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905459#M136617</guid>
      <dc:creator>f_gaudon</dc:creator>
      <dc:date>2019-05-23T08:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle the interrupt_uart interrupt on imx6 ?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905460#M136618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Florian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;description of interrupt configuration and some uart tests can be found in&lt;/P&gt;&lt;P&gt;sect.2.1.2 Interrupts (Operation), sect.4.11 Universal Asynchronous Receiver/Transmitter (UART)&lt;/P&gt;&lt;P&gt;attached Linux Manual, uart test :&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://source.codeaurora.org/external/imx/imx-test/tree/test/mxc_uart_test?h=nxp/imx_4.9.11_1.0.0_ga" title="https://source.codeaurora.org/external/imx/imx-test/tree/test/mxc_uart_test?h=nxp/imx_4.9.11_1.0.0_ga"&gt;mxc_uart_test\test - imx-test - i.MX Driver Test Application Software&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;igor&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 May 2019 00:48:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905460#M136618</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2019-05-28T00:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle the interrupt_uart interrupt on imx6 ?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905461#M136619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I tried looking the links but didn't find.&lt;/P&gt;&lt;P&gt;Can you please point me the UART code (Interrupt for send/receive each byte) for imx7?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jul 2019 00:48:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905461#M136619</guid>
      <dc:creator>neeraj_verma</dc:creator>
      <dc:date>2019-07-27T00:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle the interrupt_uart interrupt on imx6 ?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905462#M136620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/86181i257B3CBBB77329C3/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.jpg" alt="pastedImage_1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.nxp.com/webapp/Download?colCode=imx-yocto-L4.14.98_2.0.0_ga" target="_blank"&gt;Linux L4.14.98_2.0.0 Documentation&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jul 2019 00:48:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905462#M136620</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2019-07-30T00:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle the interrupt_uart interrupt on imx6 ?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905463#M136621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank for your detailed reply.&lt;/P&gt;&lt;P&gt;I could hook-up SIGIO handler and see handler getting called when there is data on respective UART. but I have few issues:&lt;/P&gt;&lt;P&gt;1. SIGIO handler gets called only when bunch of bytes are available (not on each byte)&lt;/P&gt;&lt;P&gt;2. SIGIO getting called without missing as long as I had only UART_B, when I added UART_C also, i see inconsistency and data loss in handler.&lt;/P&gt;&lt;P&gt;3. I use Colibri iMX7d (emmc) evl board, I can use only 2 UART (B and C), not sure how and what to modify in device tree and rebuild bitbake to get all UART /dev/ttymx3 to 7&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pasting my code:&lt;/P&gt;&lt;P&gt;#define BAUDRATE B115200&lt;/P&gt;&lt;P&gt;#define COMM_PORT_B "/dev/ttymxc1"&lt;/P&gt;&lt;P&gt;#define COMM_PORT_C "/dev/ttymxc1"&lt;/P&gt;&lt;P&gt;#define COMM_PORT_D "/dev/ttymxc1"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define NO_OF_UART 2&lt;BR /&gt;static int fd[NO_OF_UART] = {0}; &lt;BR /&gt;static int max_fds = 0;&lt;BR /&gt;static fd_set read_fd;&lt;BR /&gt;static char comm_port[NO_OF_UART][16] = {&lt;BR /&gt; {COMM_PORT_B},&lt;BR /&gt; {COMM_PORT_C},&lt;BR /&gt;// {COMM_PORT_D},&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;static uint8_t uart_buf[UART_DATA_LEN];&lt;BR /&gt;volatile uint8_t uart_flag;&lt;/P&gt;&lt;P&gt;static void UART_INT (int sig)&lt;BR /&gt;{&lt;BR /&gt; char rx_buf[UART_DATA_LEN] = {'\0'};&lt;BR /&gt; int res = 0;&lt;BR /&gt; int i = 0;&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; NO_OF_UART; i++) &lt;BR /&gt; { &lt;BR /&gt; if(FD_ISSET(fd[i], &amp;amp;read_fd)) {&lt;BR /&gt; res = read(fd[i], &amp;amp;rx_buf, UART_DATA_LEN);&lt;BR /&gt; if(res &amp;gt; 0) {&lt;BR /&gt; //data received, copy into buffer with flag and clear the buffer&lt;BR /&gt; uart_flag |= (1&amp;lt;&amp;lt;i); //set respective flag&lt;BR /&gt; memcpy(uart_buf, rx_buf, res);&lt;BR /&gt; memset(rx_buf, '\0', UART_DATA_LEN);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;int init_uart(int *fd, const char *port)&lt;BR /&gt;{&lt;BR /&gt; int rc = 0;&lt;BR /&gt; char cmd[CMD_STR_LEN] = {'\0'};&lt;BR /&gt; struct termios newtio;&lt;BR /&gt; struct sigaction saio;&lt;/P&gt;&lt;P&gt;sprintf(cmd, "stty -F %s 115200 -echo", port); &lt;BR /&gt; system(cmd);&lt;/P&gt;&lt;P&gt;memset(cmd, '\0', CMD_STR_LEN);&lt;BR /&gt; sprintf(cmd, "cat &amp;lt; %s &amp;amp;", port);&lt;BR /&gt; system(cmd);&lt;BR /&gt; &lt;BR /&gt; *fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);&lt;BR /&gt; if(*fd &amp;lt; 0) {&lt;BR /&gt; perror(port); &lt;BR /&gt; exit(-1);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;saio.sa_handler = UART_INT;&lt;BR /&gt; sigemptyset(&amp;amp;saio.sa_mask);&lt;BR /&gt; saio.sa_flags = SA_SIGINFO;&lt;BR /&gt; sigaction(SIGIO, &amp;amp;saio,NULL);&lt;BR /&gt; &lt;BR /&gt; fcntl (*fd, F_SETOWN, getgid());&lt;BR /&gt; fcntl(*fd, F_SETFL, FASYNC);&lt;BR /&gt; &lt;BR /&gt; newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD ;&lt;BR /&gt; newtio.c_iflag = IGNPAR | IXOFF;&lt;BR /&gt; newtio.c_oflag = 0;&lt;BR /&gt; newtio.c_lflag = 0;&lt;BR /&gt; newtio.c_cc[VMIN] = 0;&lt;BR /&gt; newtio.c_cc[VTIME] = 0;&lt;BR /&gt; tcflush(*fd, TCIFLUSH);&lt;BR /&gt; tcsetattr(*fd, TCSANOW, &amp;amp;newtio);&lt;/P&gt;&lt;P&gt;return rc;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;static uint8_t cal_crc(uint8_t *byte, size_t len)&lt;BR /&gt;{&lt;BR /&gt; uint8_t crc = 0xFF;&lt;BR /&gt; size_t i, j;&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; len; i++) &lt;BR /&gt; {&lt;BR /&gt; crc ^= byte[i];&lt;BR /&gt; for(j = 0; j &amp;lt; 8; j++)&lt;BR /&gt; {&lt;BR /&gt; if((crc &amp;amp; 0x80) != 0) {&lt;BR /&gt; crc = (uint8_t) ((crc &amp;lt;&amp;lt; 1) ^ 0x31);&lt;BR /&gt; } else {&lt;BR /&gt; crc &amp;lt;&amp;lt;= 1;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; return crc;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int send_data(int fd, uint8_t *buf)&lt;BR /&gt;{&lt;BR /&gt; int rc = 0;&lt;BR /&gt; int size = buf[NO_OF_BYTES] + 2;&lt;BR /&gt; buf[size] = cal_crc(buf,buf[NO_OF_BYTES] + 1); &lt;BR /&gt; rc = write(fd, (char *)buf, size); &lt;BR /&gt; &lt;BR /&gt; return rc;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Keep reentrant as this function runs in serveral instances &lt;BR /&gt;static int uart_trigger(void *index)&lt;BR /&gt;{&lt;BR /&gt; int rc = 0;&lt;BR /&gt; do&lt;BR /&gt; {&lt;BR /&gt; FD_SET(fd[*(int *)index], &amp;amp;read_fd);&lt;BR /&gt; pselect(max_fds + 1, &amp;amp;read_fd, NULL, NULL, NULL, NULL);&lt;/P&gt;&lt;P&gt;}while(1);&lt;/P&gt;&lt;P&gt;return rc;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int largest_num(int arr[], int n)&lt;BR /&gt;{&lt;BR /&gt; int i;&lt;BR /&gt; int max = arr[0];&lt;BR /&gt; &lt;BR /&gt; for(i = 1; i &amp;lt; n; i++)&lt;BR /&gt; {&lt;BR /&gt; if(arr[i] &amp;gt; max) {&lt;BR /&gt; max = arr[i];&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; return max;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int uart_main(void *td)&lt;BR /&gt;{ &lt;BR /&gt; int rc = 0;&lt;BR /&gt; int mydata = *(int *)td;&lt;BR /&gt; int i = 0;&lt;BR /&gt; pthread_t thread_id[NO_OF_UART];&lt;BR /&gt; int tr = 0;&lt;BR /&gt; int arg[NO_OF_UART] = {0};&lt;BR /&gt; &lt;BR /&gt; printf("%s() called thread ID: %d\n", __FUNCTION__, mydata);&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; NO_OF_UART; i++) {&lt;BR /&gt; init_uart(&amp;amp;fd[i], comm_port[i]);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;//calculate max fds&lt;BR /&gt; max_fds = largest_num(fd, NO_OF_UART);&lt;/P&gt;&lt;P&gt;FD_ZERO(&amp;amp;read_fd);&lt;/P&gt;&lt;P&gt;for(i = 0; i &amp;lt; NO_OF_UART; i++) {&lt;BR /&gt; arg[i] = i;&lt;BR /&gt; rc |= pthread_create(&amp;amp;(thread_id[i]), NULL, (void *) uart_trigger, (void *)&amp;amp;arg[i]);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; do {&lt;BR /&gt; switch(uart_flag)&lt;BR /&gt; {&lt;BR /&gt; case UART_B_DATA:&lt;BR /&gt; printf("UART_B: %s\n", uart_buf);&lt;BR /&gt; memset(uart_buf, '\0', UART_DATA_LEN);&lt;BR /&gt; uart_flag &amp;amp;= ~UART_B_DATA;&lt;/P&gt;&lt;P&gt;break;&lt;BR /&gt; case UART_C_DATA:&lt;BR /&gt; printf("UART_C: %s\n", uart_buf);&lt;BR /&gt; memset(uart_buf, '\0', UART_DATA_LEN);&lt;BR /&gt; uart_flag &amp;amp;= ~UART_C_DATA;&lt;/P&gt;&lt;P&gt;break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}while(1);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; for(i = 0; i &amp;lt; NO_OF_UART; i++) {&lt;BR /&gt; rc |=pthread_join(thread_id[i], (void **)&amp;amp;tr);&lt;BR /&gt; printf("Thread: %d %s\n", i, tr==0?"SUCCESS":"FAILED");&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; return rc; &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest me on this....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2019 17:31:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-handle-the-interrupt-uart-interrupt-on-imx6/m-p/905463#M136621</guid>
      <dc:creator>neeraj_verma</dc:creator>
      <dc:date>2019-08-02T17:31:12Z</dc:date>
    </item>
  </channel>
</rss>

