2013-11-24 17:00:12 +02:00
|
|
|
/* nutdrv_qx_mustek.c - Subdriver for Mustek protocol based UPSes
|
|
|
|
*
|
|
|
|
* Copyright (C)
|
|
|
|
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
|
|
|
*
|
|
|
|
* 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 "main.h"
|
|
|
|
#include "nutdrv_qx.h"
|
|
|
|
#include "nutdrv_qx_blazer-common.h"
|
|
|
|
|
|
|
|
#include "nutdrv_qx_mustek.h"
|
|
|
|
|
2016-07-18 03:11:41 +03:00
|
|
|
#define MUSTEK_VERSION "Mustek 0.07"
|
2013-11-24 17:00:12 +02:00
|
|
|
|
|
|
|
/* qx2nut lookup table */
|
|
|
|
static item_t mustek_qx2nut[] = {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* > [QS\r]
|
|
|
|
* < [(226.0 195.0 226.0 014 49.0 27.5 30.0 00001000\r]
|
|
|
|
* 01234567890123456789012345678901234567890123456
|
|
|
|
* 0 1 2 3 4
|
|
|
|
*/
|
|
|
|
|
2016-07-18 03:11:41 +03:00
|
|
|
{ "input.voltage", 0, NULL, "QS\r", "", 47, '(', "", 1, 5, "%.1f", 0, NULL, NULL, NULL },
|
|
|
|
{ "input.voltage.fault", 0, NULL, "QS\r", "", 47, '(', "", 7, 11, "%.1f", 0, NULL, NULL, NULL },
|
|
|
|
{ "output.voltage", 0, NULL, "QS\r", "", 47, '(', "", 13, 17, "%.1f", 0, NULL, NULL, NULL },
|
|
|
|
{ "ups.load", 0, NULL, "QS\r", "", 47, '(', "", 19, 21, "%.0f", 0, NULL, NULL, NULL },
|
|
|
|
{ "input.frequency", 0, NULL, "QS\r", "", 47, '(', "", 23, 26, "%.1f", 0, NULL, NULL, NULL },
|
|
|
|
{ "battery.voltage", 0, NULL, "QS\r", "", 47, '(', "", 28, 31, "%.2f", 0, NULL, NULL, NULL },
|
|
|
|
{ "ups.temperature", 0, NULL, "QS\r", "", 47, '(', "", 33, 36, "%.1f", 0, NULL, NULL, NULL },
|
2013-11-24 17:00:12 +02:00
|
|
|
/* Status bits */
|
2016-07-18 03:11:41 +03:00
|
|
|
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 38, 38, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Utility Fail (Immediate) */
|
|
|
|
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 39, 39, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Battery Low */
|
|
|
|
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 40, 40, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Bypass/Boost or Buck Active */
|
|
|
|
{ "ups.alarm", 0, NULL, "QS\r", "", 47, '(', "", 41, 41, NULL, 0, NULL, NULL, blazer_process_status_bits }, /* UPS Failed */
|
|
|
|
{ "ups.type", 0, NULL, "QS\r", "", 47, '(', "", 42, 42, "%s", QX_FLAG_STATIC, NULL, NULL, blazer_process_status_bits }, /* UPS Type */
|
|
|
|
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 43, 43, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Test in Progress */
|
|
|
|
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 44, 44, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Shutdown Active */
|
|
|
|
{ "ups.beeper.status", 0, NULL, "QS\r", "", 47, '(', "", 45, 45, "%s", 0, NULL, NULL, blazer_process_status_bits }, /* Beeper status */
|
2013-11-24 17:00:12 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* > [F\r]
|
|
|
|
* < [#220.0 000 024.0 50.0\r]
|
|
|
|
* 0123456789012345678901
|
|
|
|
* 0 1 2
|
|
|
|
*/
|
|
|
|
|
2016-07-18 03:11:41 +03:00
|
|
|
{ "input.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 1, 5, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL },
|
|
|
|
{ "input.current.nominal", 0, NULL, "F\r", "", 22, '#', "", 7, 9, "%.1f", QX_FLAG_STATIC, NULL, NULL, NULL },
|
|
|
|
{ "battery.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 11, 15, "%.1f", QX_FLAG_STATIC, NULL, NULL, NULL },
|
|
|
|
{ "input.frequency.nominal", 0, NULL, "F\r", "", 22, '#', "", 17, 20, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL },
|
2013-11-24 17:00:12 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* > [I\r]
|
|
|
|
* < [#------------- ------ VT12046Q \r]
|
|
|
|
* 012345678901234567890123456789012345678
|
|
|
|
* 0 1 2 3
|
|
|
|
*/
|
|
|
|
|
2016-07-18 03:11:41 +03:00
|
|
|
{ "device.mfr", 0, NULL, "I\r", "", 39, '#', "", 1, 15, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL },
|
|
|
|
{ "device.model", 0, NULL, "I\r", "", 39, '#', "", 17, 26, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL },
|
|
|
|
{ "ups.firmware", 0, NULL, "I\r", "", 39, '#', "", 28, 37, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL },
|
2013-11-24 17:00:12 +02:00
|
|
|
|
|
|
|
/* Instant commands */
|
2016-07-18 03:11:41 +03:00
|
|
|
{ "beeper.toggle", 0, NULL, "Q\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL },
|
|
|
|
{ "load.off", 0, NULL, "S00R0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL },
|
|
|
|
{ "load.on", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL },
|
|
|
|
{ "shutdown.return", 0, NULL, "S%s\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, blazer_process_command },
|
|
|
|
{ "shutdown.stayoff", 0, NULL, "S%sR0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, blazer_process_command },
|
|
|
|
{ "shutdown.stop", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL },
|
|
|
|
{ "test.battery.start", 0, NULL, "T%02d\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, blazer_process_command },
|
|
|
|
{ "test.battery.start.deep", 0, NULL, "TL\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL },
|
|
|
|
{ "test.battery.start.quick", 0, NULL, "T\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL },
|
|
|
|
{ "test.battery.stop", 0, NULL, "CT\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL },
|
2013-11-24 17:00:12 +02:00
|
|
|
|
|
|
|
/* Server-side settable vars */
|
2016-07-18 03:11:41 +03:00
|
|
|
{ "ups.delay.start", ST_FLAG_RW, blazer_r_ondelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_ONDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, NULL, NULL, blazer_process_setvar },
|
|
|
|
{ "ups.delay.shutdown", ST_FLAG_RW, blazer_r_offdelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_OFFDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, NULL, NULL, blazer_process_setvar },
|
2013-11-24 17:00:12 +02:00
|
|
|
|
|
|
|
/* End of structure. */
|
2016-07-18 03:11:41 +03:00
|
|
|
{ NULL, 0, NULL, NULL, "", 0, 0, "", 0, 0, NULL, 0, NULL, NULL, NULL }
|
2013-11-24 17:00:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Testing table */
|
|
|
|
#ifdef TESTING
|
|
|
|
static testing_t mustek_testing[] = {
|
2015-04-30 16:53:36 +03:00
|
|
|
{ "QS\r", "(215.0 195.0 230.0 014 49.0 22.7 30.0 00000000\r", -1 },
|
|
|
|
{ "F\r", "#230.0 000 024.0 50.0\r", -1 },
|
|
|
|
{ "I\r", "#NOT_A_LIVE_UPS TESTING TESTING \r", -1 },
|
|
|
|
{ "Q\r", "", -1 },
|
|
|
|
{ "S03\r", "", -1 },
|
|
|
|
{ "C\r", "", -1 },
|
|
|
|
{ "S02R0005\r", "", -1 },
|
|
|
|
{ "S.5R0000\r", "", -1 },
|
|
|
|
{ "T04\r", "", -1 },
|
|
|
|
{ "TL\r", "", -1 },
|
|
|
|
{ "T\r", "", -1 },
|
|
|
|
{ "CT\r", "", -1 },
|
2013-11-24 17:00:12 +02:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
#endif /* TESTING */
|
|
|
|
|
|
|
|
/* Subdriver-specific initups */
|
|
|
|
static void mustek_initups(void)
|
|
|
|
{
|
|
|
|
blazer_initups(mustek_qx2nut);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Subdriver interface */
|
|
|
|
subdriver_t mustek_subdriver = {
|
|
|
|
MUSTEK_VERSION,
|
2014-04-22 21:39:47 +03:00
|
|
|
blazer_claim_light,
|
2013-11-24 17:00:12 +02:00
|
|
|
mustek_qx2nut,
|
|
|
|
mustek_initups,
|
|
|
|
NULL,
|
|
|
|
blazer_makevartable,
|
|
|
|
"ACK",
|
|
|
|
NULL,
|
|
|
|
#ifdef TESTING
|
|
|
|
mustek_testing,
|
|
|
|
#endif /* TESTING */
|
|
|
|
};
|