[Nut-upsdev] megatec over USB - new driver patch

Peter Selinger selinger at mathstat.dal.ca
Tue Dec 5 16:54:25 CET 2006


Hi Andrey,

thanks for your reverse-engineering efforts! Could you please post the
HID descriptor from this device? What is the OEM mechanism that you
discovered? It would be nice if you could document the serial-over-USB
protocol used.

We have in the past seen several different USB devices that were not
proper HID devices, and at least one of them (the Krauler) seemed to
speak a USB-to-serial version of the megatec protocol. They all had
(almost) identical HID descriptors. So far none of them are supported
by NUT, but there is a good chance that your driver can support them,
if the OEM hack is indeed the same. The devices are:

* Krauler UP-M500VA (see Alexander I. Gordeev's thread on nut-upsdev,
  November 2006)
* Ablerex 625L (see Lau Kim Ping's thread on nut-upsuser, October 2006)
* Atlantis-Land S1501 (made by Ablerex) (see ngpost1's threads on
  nut-upsuser and nut-upsdev, December 2005)
* Belkin F6H500ukUNV (made by MEC?) (see the thread by meherenow,
  spamwhole, and Robert Kent on nut-upsdev, September 2006)

I suspect that all of these devices use the same hardware and
protocol. If your OEM mechanism is the same as the Krauler's, then we
should distribute your driver to the owners of the above devices and
see if they get it to work. It would be great if this family of
devices could be supported. 

-- Peter

P.S. accommodating your driver in Makefile.am is not a big problem.
Several drivers already have specialized LDADD variables, including
all of the USB drivers (which don't link against serial.o).

Andrey Lelikov wrote:
> 
> 
> Hello, all.
> 
>      Some time ago I bought myself a UPS which was advertised as USB-HID.
> It was a surprise to learn that while it definitely is recognized as USB
> device, the HID descriptor has no UPS pages at all. The only software it
> came with was a windows program written in visual basic. Trying to
> research this topic I found a reference to energizer USB ups driver and
> learned about variety of UPSes that speak megatec protocol and have
> proprietary usb-to-serial connectors. The energizer driver did not work
> for me - my converter was different.
> 
>      The usb-serial chip used in my UPS (SVEN Pro+ usb series) is a
> complete OEM hack. Apparently the only reason it is a HID device is so
> usermode application can access it without driver in windows. Its HID
> tables are flawed, it is impossible to learn a valid report size from
> it. After some reverse-engineering of windows driver I learned that all
> these constants were hardcoded in driver directly.
> 
>      In order to write a driver for it I had two options -- either add
> support to energizer driver or add another communication layer to
> megatec protocol. I did not like energizer driver approach - the
> energizer driver is a hack by itself, does not support all of megatec
> protocol (and especially assumes that UPS is 110V rated rather then use
> F command), and uses hiddev. In my case there was no way to use a hiddev
> (tables ar flawed) and anyways libusb seemed to be much more robust
> alternative. I choose to change megatec driver. Since usb drivers go to
> separate package I creates a new driver megatec_usb . The changes in
> megatec.c were minimal - only replace all serial send/getline with calls
> to a communication layer and change two lines in init/cleanup. Now
> megatec.c links with megatec_ser.c that impements serial communication
> layer to produce old megatec driver, and
> megatec.c+megatec_usb.c+libusb.c produce megatec_usb driver.
> 
> (this is a good point to actually look at the attached patch)
> 
>      The architecture of megatec_usb itself is modular. For each device
> it knows about there are two routines (send/recv) that do actual
> transfer. This way in order to support yet another usb-serial controller
> one only needs to add corresponding functions and an entry into device
> table. For now the driver supports only single chip by agiler that
> happen to be in my UPS. It might be that this driver will support
> energizer UPSes too, but naturally I have no chance to test that. Anyway
> changing it to support all hardware that is supported by energizer
> driver should be trivial - this way energizer driver (the only remaining
> "old" hid driver) may be replaced by megatec_usb.
> 
>      While changes to megatec.c are marginal and megatec_ser.c is a
> straightforward one, i did not test it at all. megatec_usb works fine on
> my system (amd64 debian etch) for several days. So someone with an
> serial megatec UPS have to look at it, or at least code review it. Also
> it probably will make sense to make a call for users of such UPSes and
> try to see if that hardware will work with this driver.
> 
>      I just dont want the results of my work to disappear into void. Is
> it something that can go into main tree? Please let me know what you
> think. I can also do all the grunt work (write man page, add to a list
> of supported devices, change debian USB hotplug script, etc) if this
> driver will be included. Thanks.



More information about the Nut-upsdev mailing list