Logo Search packages:      
Sourcecode: nut version File versions

libhid.c File Reference

Detailed Description

HID Library - User API (Generic HID Access using MGE HIDParser).

Copyright (C) 2003 - 2005 Arnaud Quette <arnaud.quette@free.fr> && <arnaud.quette@mgeups.com> John Stamp <kinsayder@hotmail.com> 2005 Peter Selinger <selinger@users.sourceforge.net>
This program is sponsored by MGE UPS SYSTEMS - opensource.mgeups.com

The logic of this file is ripped from mge-shut driver (also from Arnaud Quette), which is a "HID over serial link" UPS driver for Network UPS Tools <http://www.networkupstools.org/>

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 libhid.c.

#include <stdio.h>
#include <string.h>
#include "hidparser.h"
#include "hidtypes.h"
#include "libhid.h"
#include "common.h"
#include "libusb.h"
#include <errno.h>

Go to the source code of this file.


struct  regex_matcher_data_s
struct  reportbuf_s


#define MAX_STRING   64
#define min(x, y)   ((x)>(y) ? (y) : (x))
#define NB_HID_UNITS   10
#define REPORT_SIZE   8


typedef struct regex_matcher_data_s regex_matcher_data_t
typedef struct reportbuf_s reportbuf_t


static int compile_regex (regex_t **compiled, char *regex, int cflags)
static float expo (int a, int b)
int file_report_buffer (reportbuf_t *rbuf, u_char *report, int len)
void free_exact_matcher (HIDDeviceMatcher_t *matcher)
void free_regex_matcher (HIDDeviceMatcher_t *matcher)
void free_report_buffer (reportbuf_t *rbuf)
int get_item_buffered (reportbuf_t *rbuf, HIDData *pData, int age, HIDDesc *pDesc, hid_dev_handle *udev, long *Value)
static long get_unit_expo (long UnitType)
static const char * hid_lookup_path (unsigned int usage, usage_tables_t *utab)
static int hid_lookup_usage (char *name, usage_tables_t *utab)
void HIDCloseDevice (hid_dev_handle *udev)
void HIDDumpTree (hid_dev_handle *udev, usage_tables_t *utab)
void HIDFreeEvents (HIDEvent *events)
int HIDGetEvents (hid_dev_handle *udev, HIDDevice *dev, HIDEvent **eventsListp, usage_tables_t *utab)
static int HIDGetItemLogical (hid_dev_handle *udev, char *path, usage_tables_t *utab, long *Value, HIDData **ppData)
char * HIDGetItemString (hid_dev_handle *udev, char *path, unsigned char *rawbuf, usage_tables_t *utab)
int HIDGetItemValue (hid_dev_handle *udev, char *path, float *Value, usage_tables_t *utab)
HIDDeviceHIDOpenDevice (hid_dev_handle **udevp, HIDDevice *hd, HIDDeviceMatcher_t *matcher, int mode)
bool HIDSetItemValue (hid_dev_handle *udev, char *path, float value, usage_tables_t *utab)
static float logical_to_physical (HIDData *Data, long logical)
static int match_function_exact (HIDDevice *d, void *privdata)
static int match_function_regex (HIDDevice *d, void *privdata)
static int match_regex (regex_t *preg, char *str)
static int match_regex_hex (regex_t *preg, int n)
HIDDeviceMatcher_tnew_exact_matcher (HIDDevice *d)
int new_regex_matcher (HIDDeviceMatcher_t **matcher, char *regex_array[6], int cflags)
reportbuf_t * new_report_buffer (void)
static int path_to_string (char *HIDpath, HIDPath *path, usage_tables_t *utab)
static long physical_to_logical (HIDData *Data, float physical)
int refresh_report_buffer (reportbuf_t *rbuf, int id, int age, HIDDesc *pDesc, hid_dev_handle *udev)
int set_item_buffered (reportbuf_t *rbuf, HIDData *pData, HIDDesc *pDesc, hid_dev_handle *udev, long Value)
int set_report_from_buffer (reportbuf_t *rbuf, int id, hid_dev_handle *udev)
static int strcmp_null (char *s1, char *s2)
static int string_to_path (char *HIDpath, HIDPath *path, usage_tables_t *utab)


communication_subdriver_t * comm_driver = &usb_subdriver
usage_lkp_t hid_usage_lkp []
static const long HIDUnits [NB_HID_UNITS][2]
static HIDDesc * pDesc = NULL
static reportbuf_t * rbuf = NULL

Generated by  Doxygen 1.6.0   Back to index