Logo Search packages:      
Sourcecode: scanbuttond version File versions  Download package

int scanbtnd_get_button ( scanner_t *  scanner  ) 

Queries the scanner's button status.

Parameters:
scanner the scanner device
Returns:
the number of the currently pressed button, 0 if no button is currently pressed, or <0 if there was an error.
Return values:
-EINVAL if the scanner device has not been opened before

Definition at line 257 of file epson.c.

{
      unsigned char bytes[255];
      int rcv_len;
      int num_bytes;

      bytes[0] = ESC;
      bytes[1] = '!';
      bytes[2] = '\0';

      if (!scanner->is_open)
            return -EINVAL;

      num_bytes = epson_write(scanner, (void*)bytes, 2);
      if (num_bytes != 2) {
            epson_flush(scanner); 
            return 0;
      }
      num_bytes = epson_read(scanner, (void*)bytes, 4);
      if (num_bytes != 4) {
            epson_flush(scanner);
            return 0;
      }
      rcv_len = bytes[3] << 8 | bytes[2];
      num_bytes = epson_read(scanner, (void*)bytes, rcv_len);
      if (num_bytes != rcv_len) {
            epson_flush(scanner);
            return 0;
      }
      return bytes[0];
}


Generated by  Doxygen 1.6.0   Back to index