title: Enable ACK/NAK handshaking for UART serial port communication
body: <p>A barcode reader that has a UART male interface is connected through a serial port on my Ubuntu 10.10 desktop. From the proprietary readme doc, I came to know that I would have to enable the ACK/NAK handshaking in order to get an ACK or a NAK from the device for the commands that I send. I am not sure how to enable those using C serial port programming in Linux environment.</p>
  
  <p>Can someone throw some light on this?</p>
  
  <p><B>UPDATE:</B></p>
  
  <p>Did the following to enable software handshaking - <BR>
  <code>
  system ("stty ixon -ixoff -F /dev/tty");<BR>
  bzero (shcmd, 64);<BR>
  sprintf (shcmd, "stty ixon -ixoff -F %s", UART_DEVICE);<BR>
  system (shcmd);<BR>
  </code></p>
  
  <p>Set the speed - <BR>
  <code>
  system("stty speed 9600");<BR>
  bzero (shcmd, 64);<BR>
  sprintf (shcmd, "stty speed 9600 -F %s", UART_DEVICE);<BR>
  system (shcmd);<BR>
  </code></p>
  
  <p>Wrote a command - <BR>
  <code>
  unsigned char req_rev[6] = {0x05,0xA3,0x04,0x00,0xFF,0x55};<BR>
  n = write(fd, req_rev, 6);<BR>
  </code></p>
  
  <p>Read from the device - <BR>
  <code>
  int n = read(fd, result, 254);<BR>
  </code></p>
  
  <p>But I got "EGAIN" every time while reading. Any idea why I get that?</p>