[Nut-upsdev] Powercom driver patch
Андрей Новиков
andrey.v.novikoff at gmail.com
Fri Jul 2 17:35:53 UTC 2010
Hello everybody!
I'm trying to use nut-2.4.1 with brand new UPS Powercom Imperial
IMD-825AP USB. I've faced a problem that the driver powercom despite
specifying type=IMP automatically re-detects the UPS as "KIN" and then
interprets raw data incorrectly. The same problem was reported by
other Powercom users on the official support forum (
http://forum.pcm.ru ).
I suppose the problem concerns models with serial-over-usb connection
implemented via cypress_m8 chip (ID 0d9f:0002), e.g. IMD-865AP USB,
BNT-1000AP USB, etc. (these are on sale everywhere in Russia). The
thing is that such UPS sends raw_data[UPSVERSION]==0xFF like
"Imperial" series and simultaneously raw_data[MODELNAME]==0x4B like
"KING" series (the explanation is proposed here -
http://forum.pcm.ru/viewtopic.php?p=3401&sid=462a66a8272fea06e38be9c58e8c28f3#p3401
and here - http://forum.pcm.ru/viewtopic.php?p=7328&sid=d8839fb218d6c69bf1eae754b4dd2a58#p7328
in Russian ).
So here it is a simple patch fixing wrong detection of Imperial
serial-over-usb protocol as King one. It is not based on any official
specs, but rather empirical one. On the other hand, the code being
modified is rather ambiguous itself with several type redefinitions.
Anyway patched NUT-2.4.1 works flawlessly with my Powercom IMD-825AP
(and will definitely work with BNT-1000AP, BNT-1500AP as reported by
other users who applied similar patches independently).
Hope the proposed patch can be committed to the trunk.
Best regards,
Andrey
====================================================
--- drivers/powercom.c 2009-02-17 12:20:48.000000000 +0300
+++ drivers/powercom.c 2010-07-01 23:41:26.000000000 +0400
@@ -45,6 +45,10 @@
* - fix string comparison (thanks Michael Tokarev for bugreport &
Charles Lepple for patch)
* - added BNT-other, for BNT 100-120V models (I havn't specs for it)
*
+ * rev 0.12: Andrey V. Novikov <AndrewNovikov at yandex.ru>
+ * - fix wrong detection of Imperial serial-over-usb protocol as King
one (e.g. IMD-865AP USB, BNT-1000AP USB)
+ * - changed IMP constants to pretty values, they are not used anyway
+ *
* Tested on: BNT-1200AP
*
* Known bugs:
@@ -133,10 +137,10 @@
{ "no_flow_control", no_flow_control },
{ { 5U, 0xFFU }, { 7U, 0U }, { 8U, 0U } },
{ { 1U, 30U }, 'y' },
- { 0.00020997, 0.00020928 },
- { 6.1343, -0.3808, 4.3110, 0.1811 },
- { 5.0000, 0.3268, -825.00, 4.5639, -835.82 },
- { 1.9216, -0.0977, 0.9545, 0.0000 },
+ { 1.0, 1.0 },
+ { 1.0000, 0.0000, 1.0000, 0.0000 },
+ { 1.0000, 0.0000, 0.0000, 1.0000, 0.0000 },
+ { 2.0000, 0.0000, 2.0000, 0.0000 },
},
{
"KIN",
@@ -857,14 +861,14 @@
if (raw_data[UPSVERSION]==0xFF){
types[type].name="IMP";
model=IMPmodels[raw_data[MODELNUMBER]/16];
- }
+ } else
if (raw_data[MODELNAME]==0x42){
if (!strcmp(types[type].name, "BNT-other"))
types[type].name="BNT-other";
else
types[type].name="BNT";
model=BNTmodels[raw_data[MODELNUMBER]/16];
- }
+ } else
if (raw_data[MODELNAME]==0x4B){
types[type].name="KIN";
model=KINmodels[raw_data[MODELNUMBER]/16];
============================================================
More information about the Nut-upsdev
mailing list