Init the new driver
This commit is contained in:
parent
06fcdbc9b1
commit
d459ec6ce9
|
@ -195,7 +195,7 @@ LIBUSB_IMPL = libusb1.c
|
|||
endif
|
||||
USBHID_UPS_SUBDRIVERS = apc-hid.c arduino-hid.c belkin-hid.c cps-hid.c explore-hid.c \
|
||||
liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c \
|
||||
openups-hid.c powervar-hid.c delta_ups-hid.c ever-hid.c legrand-hid.c salicru-hid.c
|
||||
openups-hid.c powervar-hid.c delta_ups-hid.c ever-hid.c legrand-hid.c salicru-hid.c rpi-hid.c
|
||||
usbhid_ups_SOURCES = usbhid-ups.c libhid.c $(LIBUSB_IMPL) hidparser.c \
|
||||
usb-common.c $(USBHID_UPS_SUBDRIVERS)
|
||||
usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm
|
||||
|
@ -338,7 +338,7 @@ dist_noinst_HEADERS = apc-mib.h apc-iem-mib.h apc-hid.h arduino-hid.h baytech-mi
|
|||
xppc-mib.h huawei-mib.h eaton-ats16-nmc-mib.h eaton-ats16-nm2-mib.h apc-ats-mib.h raritan-px2-mib.h eaton-ats30-mib.h \
|
||||
apc-pdu-mib.h ever-hid.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h eaton-pdu-marlin-helpers.h \
|
||||
eaton-pdu-pulizzi-mib.h eaton-pdu-revelation-mib.h emerson-avocent-pdu-mib.h legrand-hid.h \
|
||||
hpe-pdu-mib.h powervar-hid.h delta_ups-hid.h generic_modbus.h salicru-hid.h adelsystem_cbi.h
|
||||
hpe-pdu-mib.h powervar-hid.h delta_ups-hid.h generic_modbus.h salicru-hid.h adelsystem_cbi.h rpi-hid.h
|
||||
|
||||
# Define a dummy library so that Automake builds rules for the
|
||||
# corresponding object files. This library is not actually built,
|
||||
|
|
123
drivers/rpi-hid.c
Normal file
123
drivers/rpi-hid.c
Normal file
|
@ -0,0 +1,123 @@
|
|||
/* rpi-hid.c - subdriver to monitor RPi USB/HID devices with NUT
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2003 - 2012 Arnaud Quette <ArnaudQuette@Eaton.com>
|
||||
* 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net>
|
||||
* 2008 - 2009 Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
* 2013 Charles Lepple <clepple+nut@gmail.com>
|
||||
*
|
||||
* TODO: Add year and name for new subdriver author (contributor)
|
||||
* Mention in docs/acknowledgements.txt if this is a vendor contribution
|
||||
*
|
||||
* Note: this subdriver was initially generated as a "stub" by the
|
||||
* gen-usbhid-subdriver script. It must be customized.
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "usbhid-ups.h"
|
||||
#include "rpi-hid.h"
|
||||
#include "main.h" /* for getval() */
|
||||
#include "usb-common.h"
|
||||
|
||||
#define RPI_HID_VERSION "RPi HID 0.1"
|
||||
/* FIXME: experimental flag to be put in upsdrv_info */
|
||||
|
||||
/* RPi */
|
||||
#define RPI_VENDORID 0x051D
|
||||
|
||||
/* USB IDs device table */
|
||||
static usb_device_id_t rpi_usb_device_table[] = {
|
||||
/* RPi */
|
||||
{ USB_DEVICE(RPI_VENDORID, 0x0004), NULL },
|
||||
|
||||
/* Terminating entry */
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
/* Vendor-specific usage table */
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
/* RPI usage table */
|
||||
static usage_lkp_t rpi_usage_lkp[] = {
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static usage_tables_t rpi_utab[] = {
|
||||
rpi_usage_lkp,
|
||||
hid_usage_lkp,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
/* HID2NUT lookup table */
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
static hid_info_t rpi_hid2nut[] = {
|
||||
|
||||
|
||||
/* end of structure. */
|
||||
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
static const char *rpi_format_model(HIDDevice_t *hd) {
|
||||
return hd->Product;
|
||||
}
|
||||
|
||||
static const char *rpi_format_mfr(HIDDevice_t *hd) {
|
||||
return hd->Vendor ? hd->Vendor : "RPi";
|
||||
}
|
||||
|
||||
static const char *rpi_format_serial(HIDDevice_t *hd) {
|
||||
return hd->Serial;
|
||||
}
|
||||
|
||||
/* this function allows the subdriver to "claim" a device: return 1 if
|
||||
* the device is supported by this subdriver, else 0. */
|
||||
static int rpi_claim(HIDDevice_t *hd)
|
||||
{
|
||||
int status = is_usb_device_supported(rpi_usb_device_table, hd);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case POSSIBLY_SUPPORTED:
|
||||
/* by default, reject, unless the productid option is given */
|
||||
if (getval("productid")) {
|
||||
return 1;
|
||||
}
|
||||
possibly_supported("RPi", hd);
|
||||
return 0;
|
||||
|
||||
case SUPPORTED:
|
||||
return 1;
|
||||
|
||||
case NOT_SUPPORTED:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
subdriver_t rpi_subdriver = {
|
||||
RPI_HID_VERSION,
|
||||
rpi_claim,
|
||||
rpi_utab,
|
||||
rpi_hid2nut,
|
||||
rpi_format_model,
|
||||
rpi_format_mfr,
|
||||
rpi_format_serial,
|
||||
fix_report_desc, /* may optionally be customized, see cps-hid.c for example */
|
||||
};
|
30
drivers/rpi-hid.h
Normal file
30
drivers/rpi-hid.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* rpi-hid.h - subdriver to monitor RPi USB/HID devices with NUT
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2003 - 2009 Arnaud Quette <ArnaudQuette@Eaton.com>
|
||||
* 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net>
|
||||
* 2008 - 2009 Arjen de Korte <adkorte-guest@alioth.debian.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef RPI_HID_H
|
||||
#define RPI_HID_H
|
||||
|
||||
#include "usbhid-ups.h"
|
||||
|
||||
extern subdriver_t rpi_subdriver;
|
||||
|
||||
#endif /* RPI_HID_H */
|
|
@ -54,6 +54,7 @@
|
|||
#include "openups-hid.h"
|
||||
#include "powercom-hid.h"
|
||||
#include "powervar-hid.h"
|
||||
#include "rpi-hid.h"
|
||||
#include "salicru-hid.h"
|
||||
#include "tripplite-hid.h"
|
||||
#endif
|
||||
|
@ -77,6 +78,7 @@ static subdriver_t *subdriver_list[] = {
|
|||
&openups_subdriver,
|
||||
&powercom_subdriver,
|
||||
&powervar_subdriver,
|
||||
&rpi_subdriver,
|
||||
&salicru_subdriver,
|
||||
&tripplite_subdriver,
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user