[Nut-upsdev] bcmxcp: Patch for adding ups.load and battery.voltage.low

Alf Høgemark alf at i100.no
Wed Jul 3 18:00:16 UTC 2013


On 07/03/2013 04:51 PM, Charles Lepple wrote:
> On Jul 2, 2013, at 5:16 PM, Kjell Claesson wrote:
>
>>> I hope other people can also test this.
>>>
>>> Regards
>>> Alf Hogemark
>> Due to some crashes on the disks and lack of time I don't have the git on the
>> pc now. But maybe some other can commit this.
> I'd like to ask people to specifically try the bcmxcp branch on GitHub - it includes some changes that Prachi made a while ago.
>
> https://github.com/networkupstools/nut/tree/bcmxcp
>
> Kjell: if it's just Git that you need, you can download a snapshot from GitHub. If you need the full autotools as well, let me know, and I'll build a tarball. (I still haven't had time to debug why the Buildbot code doesn't publish the autoconf-generated tarball.)
>
> Alf: your patch didn't apply to this branch, but it was easy enough to add in the two NUT mappings.
>
> Overall diffs:
>
> https://github.com/networkupstools/nut/compare/bcmxcp
>
> Many of these changes simply remove some of the "magic numbers" but it would be good if someone with the BCM/XCP hardware could verify that nothing was broken in the process.
>
Hi

I have now compiled from the bcmxcp and tested very briefly on my 
"POWERWARE UPS 500i", which is connected via USB.
Things seems to work fine, but I have just tested very briefly, doing a 
"test.battery.start".

I can confirm that the "device.Part" works :
device.part: 103004261-5591

I can confirm that the "test.system.start" works.



I had a look at the code for the driver in the branch, and made some 
cosmetic changes :


 From 2960d9c6aa63ea23bdf11418b279bcdb633eef39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alf=20H=C3=B8gemark?= <alf at i100.no>
Date: Wed, 3 Jul 2013 19:53:12 +0200
Subject: [PATCH] Cosmetic code to make changes by Prachi Gandhi more 
coherent
  with test of the bcmxcp driver

---
  data/cmdvartab   |  2 +-
  drivers/bcmxcp.c | 26 +++++++-------------------
  2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/data/cmdvartab b/data/cmdvartab
index 22b877f..8bef408 100644
--- a/data/cmdvartab
+++ b/data/cmdvartab
@@ -164,6 +164,7 @@ CMDDESC test.battery.start "Start a battery test"
  CMDDESC test.battery.start.quick "Start a quick battery test"
  CMDDESC test.battery.start.deep "Start a deep battery test"
  CMDDESC test.battery.stop "Stop the battery test"
+CMDDESC test.system.start "Start a system test"
  CMDDESC calibrate.start "Start run time calibration"
  CMDDESC calibrate.stop "Stop run time calibration"
  CMDDESC bypass.start "Put the UPS in bypass mode"
@@ -180,7 +181,6 @@ CMDDESC outlet.1.load.off "Turn off the load on 
outlet 1 immediately"
  CMDDESC outlet.1.load.on "Turn on the load on outlet 1 immediately"
  CMDDESC outlet.2.load.off "Turn off the load on outlet 2 immediately"
  CMDDESC outlet.2.load.on "Turn on the load on outlet 2 immediately"
-CMDDESC test.system.start "Start a system test"

  # The following two commands should *only* be defined when you need
  # to compose a 'shutdown.return' command by sending both a switch-off
diff --git a/drivers/bcmxcp.c b/drivers/bcmxcp.c
index b49da91..5c61bd4 100644
--- a/drivers/bcmxcp.c
+++ b/drivers/bcmxcp.c
@@ -158,7 +158,7 @@ static void init_ups_alarm_map(const unsigned char 
*map, unsigned char len);
  static void decode_meter_map_entry(const unsigned char *entry, const 
unsigned char format, char* value);
  static int init_outlet(unsigned char len);
  static int instcmd(const char *cmdname, const char *extra);
-static int setvar (const char *varname, const char *val);
+static int setvar(const char *varname, const char *val);

  static const char *nut_find_infoval(info_lkp_t *xcp2info, const double 
value);

@@ -641,7 +641,7 @@ void init_command_map(int size)

          res = answer[iIndex];
          NumComms = (int)res; /* Number of commands implemented in this 
UPS */
-        upsdebugx(3, "comms %d", res);
+        upsdebugx(3, "Number of commands implemented in ups %d", res);
          iIndex++;
          res = answer[iIndex]; /* Entry length - bytes reported for 
each command */
          iIndex++;
@@ -656,11 +656,11 @@ void init_command_map(int size)

                  if (answer[iIndex] == PW_INIT_BAT_TEST)
                  {
-                    dstate_addcmd ("test.battery.start");
+                    dstate_addcmd("test.battery.start");
                  }
                  else if (answer[iIndex] == PW_INIT_SYS_TEST)
                  {
-                    dstate_addcmd ("test.system.start");
+                    dstate_addcmd("test.system.start");
                  }
                  iIndex++;
              }
@@ -1036,11 +1036,8 @@ void init_config(void)
          dstate_setinfo("output.frequency.nominal", "%d", frequency);

      /*UPS Part Number*/
-
      snprintf(sPartNumber, sizeof(sPartNumber) , "%s", answer + 
BCMXCP_CONFIG_BLOCK_PART_NUMBER);
-
      dstate_setinfo("device.part", "%s", sPartNumber);
-
  }

  void init_limit(void)
@@ -1310,8 +1307,6 @@ void upsdrv_initinfo(void)

      upsh.instcmd = instcmd;
      upsh.setvar = setvar;
-
-    return;
  }

  void upsdrv_updateinfo(void)
@@ -1568,7 +1563,6 @@ void upsdrv_shutdown(void)
      0x37 Accepted with parameter adjusted
      */
      switch ((unsigned char) answer[0]) {
-
          case BCMXCP_RETURN_ACCEPTED: {
              upsdrv_comm_good();
              upslogx(LOG_NOTICE,"Going down in %d sec", sec);
@@ -1631,7 +1625,6 @@ static int instcmd(const char *cmdname, const char 
*extra)
          sec = (256 * (unsigned char)answer[3]) + (unsigned char)answer[2];

          switch ((unsigned char) answer[0]) {
-
              case BCMXCP_RETURN_ACCEPTED: {
                  upslogx(LOG_NOTICE,"Going down in %d sec", sec);
                  return STAT_INSTCMD_HANDLED;
@@ -1676,7 +1669,6 @@ static int instcmd(const char *cmdname, const char 
*extra)
          sec = (256 * (unsigned char)answer[3]) + (unsigned char)answer[2];

          switch ((unsigned char) answer[0]) {
-
              case BCMXCP_RETURN_ACCEPTED: {
                  upslogx(LOG_NOTICE,"Going down in %d sec", sec);
                  return STAT_INSTCMD_HANDLED;
@@ -1714,7 +1706,6 @@ static int instcmd(const char *cmdname, const char 
*extra)
          }

          switch ((unsigned char) answer[0]) {
-
              case BCMXCP_RETURN_ACCEPTED: {
                  upslogx(LOG_NOTICE,"[%s] Going down NOW", cmdname);
                  return STAT_INSTCMD_HANDLED;
@@ -1760,7 +1751,6 @@ static int instcmd(const char *cmdname, const char 
*extra)
          }

          switch ((unsigned char) answer[0]) {
-
              case BCMXCP_RETURN_ACCEPTED: {
                  upslogx(LOG_NOTICE,"[%s] Testing now", cmdname);
                  return STAT_INSTCMD_HANDLED;
@@ -1792,11 +1782,11 @@ static int instcmd(const char *cmdname, const 
char *extra)
      if (!strcasecmp(cmdname, "test.system.start")) {
          send_write_command(AUTHOR, 4);

-        sleep(1);    /* Need to. Have to wait at least 0,25 sec max 16 
sec */
+        sleep(PW_SLEEP);    /* Need to. Have to wait at least 0,25 sec 
max 16 sec */

          cbuf[0] = PW_INIT_SYS_TEST;
-        cbuf[1] = 0x01;            /* Initiate General system Test */
-                                /* 0x02 = Schedule Battery 
Commissioning Test*/
+        cbuf[1] = 0x01;         /* 0x01 = Initiate General system Test */
+                                /* 0x02 = Schedule Battery 
Commissioning Test */
                                  /* 0x03 = Test Alternate AC Input */
                                  /* 0x04 = Flash the Lights Test */
                                  /* 0xFF = Report Systems Test 
Capabilities */
@@ -1808,7 +1798,6 @@ static int instcmd(const char *cmdname, const char 
*extra)
          }

          switch ((unsigned char) answer[0]) {
-
              case BCMXCP_RETURN_ACCEPTED: {
                  upslogx(LOG_NOTICE,"[%s] Testing now", cmdname);
                  return STAT_INSTCMD_HANDLED;
@@ -1905,7 +1894,6 @@ int setvar (const char *varname, const char *val)
      }

      switch ((unsigned char) answer[0]) {
-
          case 0x31: {
              upslogx(LOG_NOTICE,"Outlet %d %s delay set to %d sec",
                  outlet_num, (onOff_setting == 
PW_AUTO_ON_DELAY)?"start":"shutdown", sec);
-- 
1.8.1.2




More information about the Nut-upsdev mailing list