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

libshut.c File Reference


Detailed Description

HID Library - Serial SHUT communication sub driver.

Author:
Copyright (C) 2006 - 2007 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/types.h>
#include <string.h>
#include "nut_stdint.h"
#include "serial.h"
#include "libshut.h"
#include "common.h"

Go to the source code of this file.

Classes

struct  device_descriptor_s
union  hid_data_t
union  hid_desc_data_t
struct  my_hid_descriptor
struct  shut_ctrltransfer_s
union  shut_data_t
struct  shut_packet_s

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.81"
#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_s device_descriptor_t
typedef struct shut_ctrltransfer_s shut_ctrltransfer_t
typedef struct shut_packet_s shut_packet_t

Functions

static void align_request (struct shut_ctrltransfer_s *ctrl)
void libshut_close (int upsfd)
int libshut_get_interrupt (int upsfd, unsigned char *buf, int bufsize, int timeout)
int libshut_get_report (int upsfd, int ReportId, unsigned char *raw_buf, int ReportSize)
int libshut_get_string (int upsfd, int StringIdx, char *buf, size_t buflen)
int libshut_open (int *upsfd, SHUTDevice_t *curDevice, char *device_path, int(*callback)(int upsfd, SHUTDevice_t *hd, unsigned char *rdbuf, int rdlen))
int libshut_set_report (int upsfd, int ReportId, unsigned char *raw_buf, int ReportSize)
void setline (int upsfd, int set)
u_char shut_checksum (const u_char *buf, int bufsize)
int shut_control_msg (int upsfd, int requesttype, int request, int value, int index, unsigned char *bytes, int size, int timeout)
int shut_get_descriptor (int upsfd, unsigned char type, unsigned char index, void *buf, int size)
int shut_get_string_simple (int upsfd, int index, char *buf, size_t buflen)
int shut_interrupt_read (int upsfd, int ep, unsigned char *bytes, int size, int timeout)
int shut_packet_recv (int upsfd, u_char *Buf, int datalen)
int shut_set_report (int upsfd, int id, unsigned char *pkt, int reportlen)
char * shut_strerror ()
int shut_synchronise (int upsfd)
int shut_wait_ack (int upsfd)

Variables

upsdrv_info_t comm_upsdrv_info
shut_communication_subdriver_t shut_subdriver


Generated by  Doxygen 1.6.0   Back to index