0
void *serial_function(void *threadNo_R)
{
int ImThreadNo = (int) threadNo_R;
fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY);//
 if (fd == -1)
    {
    /* Could not open the port. */
        perror("open_port: Unable to open /dev/ttyUSB0 - ");
    }
  fcntl(fd, F_SETFL,0);
  while(1)
   {
    read(fd,&dataReceived.Serial_input,1);
    printf("\n From serial fn: Serial_input is:%c\n",dataReceived.Serial_input);

    if(V_buf.power_window_data.front_right_up>=1)
    {
       writenornot= write(fd,"Window is raising:",19);
        if (writenornot < 0)
        {
        printf("Write Failed \n");
        }
        else
        printf("Write successfull \n"); 
    }   
}

}

In the above program serial input send via terminal which will be read by driver and further operation is carried out.If I press a key 'a' and i should press enter stroke to pass the key,whereas I'm reading both 'a' and 'enter stroke' .Is there any method such that open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); where it is reading both key which I press and "enter" also .I want enter key should be avoided.

Sri
  • 11
  • 3
  • It's not totally clear what you want to happen, but you should check out [How to properly set up serial communication on Linux](http://stackoverflow.com/q/15890903/1072229) and the various terminal flags you can set with [tcsetattr](https://linux.die.net/man/3/cfmakeraw). – Grisha Levit Feb 13 '17 at 04:12
  • will take a look,Thanks @GrishaLevit – Sri Feb 13 '17 at 04:56
  • Add flag "IGNCR" to ignore CR in line feed. for more information follow the link http://www.delorie.com/gnu/docs/glibc/libc_362.html – BhanuSingh Feb 15 '17 at 11:14
  • *"Is there any method..."* -- Yes, it's called non-canonical (aka raw) mode. Your program is probably operating in canonical mode. You fail to initialize the serial terminal using the *termios* interface, which is required for reliable program execution. – sawdust Feb 16 '17 at 00:24

0 Answers0