title: "Not a typewriter" AVRDude error on Android
body: <p>I have received a file descriptor for a <a href="http://en.wikipedia.org/wiki/Universal_Serial_Bus" rel="nofollow">USB</a> device from an Android app (using <a href="http://developer.android.com/reference/android/hardware/usb/UsbDeviceConnection.html#getFileDescriptor%28%29" rel="nofollow"> getFileDescriptor()</a>), sent it via JNI in native code and received it in a child process (AVRDude) via a Unix socket and tried to use for uploading.</p>
  
  <p>So I'm getting a "<strong>Not a typewriter</strong>" error. Does it mean that file descriptor was passed incorrectly (it is a positive int and it is not equal to -1 after receiving)? Or can there be another error? Can it be a permissions issue (though permissions to UsbDevice is granted and passing via a socket seems to hold permissions, the device is not rooted)?</p>
  
  <p>The code used (<code>ser_posix.c</code> in AVRDude 5_11_0 sources):</p>
  
  <pre><code>fprintf(stdout, "Try to set baud = %i for fd = %i", baud, usbfd);
  if (!isatty(usbfd)) { // Error here!
      fprintf(stderr, "!isatty\n");
      return -ENOTTY;
  }
  </code></pre>
  
  <p>Right after receiving from the socket file descriptor is checked to be valid (and I believe it is):</p>
  
  <pre><code>if (!(fcntl(usbfd, F_GETFL) != -1 || errno != EBADF)) {
      fprintf(stderr, "Invalid file descriptor %d, - %s", usbfd, strerror(errno));
      exit(1);
  }
  </code></pre>
  
  <p>Originally the file descriptor in ser_posix is received like that (and I believe it's working):</p>
  
  <pre><code>fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
  </code></pre>
  
  <p>In my implementation I use the file descriptor from the Android app instead. Is it what's expected?</p>