On Dec 8, 2014, at 6:07 PM, Martin Pieuchot <[email protected]> wrote:
> On 08/12/14(Mon) 09:35, David Higgs wrote: >> On Mon, Dec 8, 2014 at 9:29 AM, Martin Pieuchot <[email protected]> >> wrote: >> [...] >>> Now I'd like to finish the transition that started with the import of >>> upd(4) and move away from the actual 1 reportID = 1 driver model. >>> Because in the end they are all sharing the same USB device actually >>> represented by an uhidev(4) instance. So I'll ride the refactoring >>> needed by your buggy firmware to also change that. Since all the >>> uhidev_*_report() will be modified, we can also pass a pointer to >>> the uhidev(4) device instead of one of its children. Is it clearer? >> >> Sounds great to me. > > As promised, here's a second and last diff that changes the various > uhidev_*_report() functions to provide the transfered length to the > caller if requested. > > The *get* variant now also handles the first byte required for non-0 > reportID. > > And last but not least, it includes the hack from apcupsd to deal with > buggy firmwares like yours. > > Could you try it and let me know how it goes? Seems to work just fine on my -current VM after adding the diff below (I didn’t try without). See my previous email in this thread for other comments re: your diff. hw.sensors.upd0.indicator0=Off (Charging), OK hw.sensors.upd0.indicator1=Off (Discharging), OK hw.sensors.upd0.indicator2=On (ACPresent), OK hw.sensors.upd0.indicator3=Off (ShutdownImminent), OK hw.sensors.upd0.indicator4=On (BatteryPresent), OK hw.sensors.upd0.percent0=100.00% (RemainingCapacity), OK hw.sensors.upd0.percent1=100.00% (FullChargeCapacity), OK --david Index: upd.c =================================================================== RCS file: /cvs/src/sys/dev/usb/upd.c,v retrieving revision 1.10 diff -u -p -r1.10 upd.c --- upd.c 12 Jul 2014 18:48:52 -0000 1.10 +++ upd.c 9 Dec 2014 15:39:20 -0000 @@ -358,8 +360,7 @@ upd_update_sensors(struct upd_softc *sc, break; } - /* XXX first byte which is the report id */ - hdata = hid_get_data(buf + 1, len, &sensor->hitem.loc); + hdata = hid_get_data(buf, len, &sensor->hitem.loc); sensor->ksensor.value = hdata * adjust; sensor->ksensor.status = SENSOR_S_OK;
