Logo Search packages:      
Sourcecode: nut version File versions

libshut.c File Reference


Detailed Description

HID Library - Serial SHUT backend for Generic HID Access (using MGE HIDParser).

Author:
Copyright (C) 2006 Arnaud Quette <aquette.dev@gmail.com>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

--------------------------------------------------------------------------

Definition in file libshut.c.

#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <string.h>
#include "serial.h"
#include "libshut.h"
#include "libhid.h"
#include "common.h"

Go to the source code of this file.

Classes

struct  device_descriptor
union  hid_data
union  hid_desc_data
struct  my_hid_descriptor
struct  shut_ctrltransfer
union  shut_data
struct  shut_packet

Defines

#define BYTESWAP(in)   (((in & 0xFF) << 8) + ((in & 0xFF00) >> 8))
#define HID_REPORT_TYPE_FEATURE   0x03
#define HID_REPORT_TYPE_INPUT   0x01
#define HID_REPORT_TYPE_OUTPUT   0x02
#define MAX_REPORT_SIZE   0x1800
#define MAX_TRY   4
#define REQUEST_TYPE_GET_REPORT   0xa1
#define REQUEST_TYPE_HID   0x81
#define REQUEST_TYPE_SET_REPORT   0x21
#define REQUEST_TYPE_USB   0x80
#define SHUT_DRIVER_NAME   "MGE SHUT communication driver"
#define SHUT_DRIVER_VERSION   "0.67"
#define SHUT_NOK   0x15
#define SHUT_OK   0x06
#define SHUT_PKT_LAST   0x80
#define SHUT_SYNC   0x16
#define SHUT_SYNC_LIGHT   0x17
#define SHUT_SYNC_OFF   0x18
#define SHUT_TIMEOUT   3000
#define SHUT_TYPE_NOTIFY   0x05
#define SHUT_TYPE_REQUEST   0x01
#define SHUT_TYPE_RESPONSE   0x04
#define USB_CLASS_AUDIO   1
#define USB_CLASS_COMM   2
#define USB_CLASS_DATA   10
#define USB_CLASS_HID   3
#define USB_CLASS_HUB   9
#define USB_CLASS_MASS_STORAGE   8
#define USB_CLASS_PER_INTERFACE   0
#define USB_CLASS_PRINTER   7
#define USB_CLASS_VENDOR_SPEC   0xff
#define USB_DT_CONFIG   0x02
#define USB_DT_CONFIG_SIZE   9
#define USB_DT_DEVICE   0x01
#define USB_DT_DEVICE_SIZE   18
#define USB_DT_ENDPOINT   0x05
#define USB_DT_ENDPOINT_AUDIO_SIZE   9
#define USB_DT_ENDPOINT_SIZE   7
#define USB_DT_HID   0x21
#define USB_DT_HUB   0x29
#define USB_DT_HUB_NONVAR_SIZE   7
#define USB_DT_INTERFACE   0x04
#define USB_DT_INTERFACE_SIZE   9
#define USB_DT_PHYSICAL   0x23
#define USB_DT_REPORT   0x22
#define USB_DT_STRING   0x03
#define USB_ENDPOINT_IN   0x80
#define USB_ENDPOINT_OUT   0x00
#define USB_RECIP_DEVICE   0x00
#define USB_RECIP_ENDPOINT   0x02
#define USB_RECIP_INTERFACE   0x01
#define USB_RECIP_OTHER   0x03
#define USB_REQ_CLEAR_FEATURE   0x01
#define USB_REQ_GET_CONFIGURATION   0x08
#define USB_REQ_GET_DESCRIPTOR   0x06
#define USB_REQ_GET_INTERFACE   0x0A
#define USB_REQ_GET_STATUS   0x00
#define USB_REQ_SET_ADDRESS   0x05
#define USB_REQ_SET_CONFIGURATION   0x09
#define USB_REQ_SET_DESCRIPTOR   0x07
#define USB_REQ_SET_FEATURE   0x03
#define USB_REQ_SET_INTERFACE   0x0B
#define USB_REQ_SYNCH_FRAME   0x0C
#define USB_TYPE_CLASS   (0x01 << 5)
#define USB_TYPE_RESERVED   (0x03 << 5)
#define USB_TYPE_STANDARD   (0x00 << 5)
#define USB_TYPE_VENDOR   (0x02 << 5)

Typedefs

typedef struct device_descriptor device_descriptor_t
typedef union hid_data hid_data_u
typedef union hid_desc_data hid_desc_data_u
typedef struct shut_ctrltransfer shut_ctrltransfer_t
typedef union shut_data shut_data_u
typedef struct shut_packet shut_packet_t

Functions

static void align_request (struct shut_ctrltransfer *ctrl)
void libshut_close (shut_dev_handle *sdev)
int libshut_get_interrupt (shut_dev_handle *devp, unsigned char *buf, int bufsize, int timeout)
int libshut_get_report (shut_dev_handle *devp, int ReportId, unsigned char *raw_buf, int ReportSize)
int libshut_get_string (shut_dev_handle *devp, int StringIdx, char *buf)
int libshut_open (shut_dev_handle **sdevp, HIDDevice *curDevice, HIDDeviceMatcher_t *matcher, unsigned char *ReportDesc, int mode)
int libshut_set_report (shut_dev_handle *devp, int ReportId, unsigned char *raw_buf, int ReportSize)
void setline (int fd, int set)
u_char shut_checksum (const u_char *buf, int bufsize)
int shut_control_msg (shut_dev_handle *dev, int requesttype, int request, int value, int index, unsigned char *bytes, int size, int timeout)
int shut_get_descriptor (shut_dev_handle *sdev, unsigned char type, unsigned char index, void *buf, int size)
int shut_get_string_simple (shut_dev_handle *dev, int index, unsigned char *buf, size_t buflen)
int shut_interrupt_read (shut_dev_handle *dev, int ep, unsigned char *bytes, int size, int timeout)
int shut_packet_recv (int fd, u_char *Buf, int datalen)
int shut_set_report (shut_dev_handle *sdev, int id, unsigned char *pkt, int reportlen)
char * shut_strerror ()
bool shut_synchronise (int fd)
int shut_wait_ack (int fd)

Variables

communication_subdriver_t shut_subdriver


Generated by  Doxygen 1.6.0   Back to index