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

libhid.c File Reference


Detailed Description

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

Author:
Copyright (C) 2003 - 2005 Arnaud Quette <arnaud.quette@free.fr> && <arnaud.quette@mgeups.com> Philippe Marzouk <philm@users.sourceforge.net> (dump_hex()) 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 "libusb.h"
#include <errno.h>

Go to the source code of this file.

Classes

struct  regex_matcher_data_s
struct  report_s

Defines

#define MAX_STRING   64
#define min(x, y)   ((x)>(y) ? (y) : (x))
#define NB_HID_UNITS   10
#define NIBBLE(_i)   (((_i) < 10) ? '0' + (_i) : 'A' + (_i) - 10)
#define REPORT_SIZE   8
#define TRACE   upsdebugx

Typedefs

typedef struct regex_matcher_data_s regex_matcher_data_t
typedef struct report_s report_t

Functions

static int compile_regex (regex_t **compiled, char *regex, int cflags)
static void dump_hex (const char *msg, const unsigned char *buf, int len)
static float expo (int a, int b)
void free_exact_matcher (HIDDeviceMatcher_t *matcher)
void free_regex_matcher (HIDDeviceMatcher_t *matcher)
int get_current_data_attribute ()
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 (usb_dev_handle *udev)
void HIDDumpTree (usb_dev_handle *udev, usage_tables_t *utab)
int HIDGetEvents (usb_dev_handle *udev, HIDDevice *dev, HIDItem **eventsList, usage_tables_t *utab)
HIDItemHIDGetItem (const char *ItemPath)
char * HIDGetItemString (usb_dev_handle *udev, char *path, unsigned char *rawbuf, usage_tables_t *utab)
int HIDGetItemValue (usb_dev_handle *udev, char *path, float *Value, usage_tables_t *utab)
HIDDeviceHIDOpenDevice (usb_dev_handle **udevp, HIDDevice *hd, HIDDeviceMatcher_t *matcher, int mode)
bool HIDSetItemValue (usb_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_t * new_exact_matcher (HIDDevice *d)
int new_regex_matcher (HIDDeviceMatcher_t **matcher, char *regex_array[6], int cflags)
static int path_to_string (char *HIDpath, HIDPath *path, usage_tables_t *utab)
static long physical_to_logical (HIDData *Data, float physical)
static int strcmp_null (char *s1, char *s2)
static int string_to_path (char *HIDpath, HIDPath *path, usage_tables_t *utab)
void upsdebugx (int level, const char *fmt,...)

Variables

static report_t cur_report_struct = {0, 0, 0, {0}}
static HIDData hData
usage_lkp_t hid_usage_lkp []
static const long HIDUnits [NB_HID_UNITS][2]
static HIDParser hParser


Generated by  Doxygen 1.6.0   Back to index