View | Details | Raw Unified | Return to bug 12718
Collapse All | Expand All

(-)nut-2.0.4.old/drivers/powercom.h (-1 / +2 lines)
Lines 43-49 Link Here
43
enum commands {
43
enum commands {
44
	SEND_DATA    = '\x01',
44
	SEND_DATA    = '\x01',
45
	BATTERY_TEST = '\x03',
45
	BATTERY_TEST = '\x03',
46
	SHUTDOWN     = '\xbc'
46
	SHUTDOWN     = '\xbc',
47
	SHUTDOWN0	 ='\xb9'
47
};
48
};
48
49
49
/* location of data in received string */
50
/* location of data in received string */
(-)nut-2.0.4.old/drivers/powercom.c (-9 / +52 lines)
Lines 117-122 Link Here
117
                {  5.0000,  0.3268,  -825.00,  0.46511, 0 },
117
                {  5.0000,  0.3268,  -825.00,  0.46511, 0 },
118
                {  1.9216, -0.0977,  0.82857,  0.0000 },
118
                {  1.9216, -0.0977,  0.82857,  0.0000 },
119
        },
119
        },
120
        {
121
                "BNT1200AP",
122
                16,
123
				{  "no_flow_control", no_flow_control },
124
                { { 7U, 0U }, { 8U, 0U }, { 8U, 0U } },
125
                { { 2U, 0U }, 'y' },
126
                {  0.00020997, 0.0 },
127
                {  6.1343, -0.3808,  1.075,  0.1811 },
128
                {  5.0000,  0.3268,  -825.00,  0.46511, 0 },
129
                {  1.9216, -0.0977,  0.82857,  0.0000 },
130
        },
120
};
131
};
121
132
122
133
Lines 124-141 Link Here
124
 * local used functions
135
 * local used functions
125
 */
136
 */
126
137
127
static void nut_shutdown(void)
138
static void shutdown(void)
139
{
140
//printf ("Initiating UPS shutdown!\n");
141
	ser_send_char (upsfd, SHUTDOWN);
142
	if (types[type].shutdown_arguments.minutesShouldBeUsed != 'n') 
143
		ser_send_char (upsfd, '\x00');
144
	ser_send_char (upsfd, '\x10');
145
	upslogx(LOG_INFO, "Shutdown (stayoff) initiated.");
146
	exit (0);
147
}
148
static void shutdown_ret(void)
128
{
149
{
129
	printf ("Initiating UPS shutdown!\n");
150
//	printf ("Initiating UPS shutdown!\n");
130
        
151
	ser_send_char (upsfd, SHUTDOWN0);
131
	ser_send_char (upsfd, SHUTDOWN);
152
	ser_send_char (upsfd, SHUTDOWN);
132
	if (types[type].shutdown_arguments.minutesShouldBeUsed != 'n') 
153
	if (types[type].shutdown_arguments.minutesShouldBeUsed != 'n') 
133
	    ser_send_char (upsfd, types[type].shutdown_arguments.delay[0]);
154
		ser_send_char (upsfd, '\x00');
134
	ser_send_char (upsfd, types[type].shutdown_arguments.delay[1]);
155
	ser_send_char (upsfd, '\x10');
135
			
156
	upslogx(LOG_INFO, "Shutdown (return) initiated.");
136
	exit (0);
157
	exit (0);
137
}
158
}
138
159
160
139
/* registered instant commands */
161
/* registered instant commands */
140
static int instcmd (const char *cmdname, const char *extra)
162
static int instcmd (const char *cmdname, const char *extra)
141
{
163
{
Lines 143-148 Link Here
143
	    ser_send_char (upsfd, BATTERY_TEST);
165
	    ser_send_char (upsfd, BATTERY_TEST);
144
	    return STAT_INSTCMD_HANDLED;
166
	    return STAT_INSTCMD_HANDLED;
145
    }
167
    }
168
//	if (types[type].name=="BNT1200AP"){
169
		if (!strcasecmp(cmdname, "shutdown.return")) { 
170
			shutdown_ret();
171
			return STAT_INSTCMD_HANDLED;
172
		}
173
		if (!strcasecmp(cmdname, "shutdown.stayoff")) {
174
			shutdown(); 
175
			return STAT_INSTCMD_HANDLED;
176
		}
177
//    }
146
178
147
    upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname);
179
    upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname);
148
    return STAT_INSTCMD_UNKNOWN;
180
    return STAT_INSTCMD_UNKNOWN;
Lines 353-360 Link Here
353
void upsdrv_shutdown(void)
385
void upsdrv_shutdown(void)
354
{
386
{
355
	/* power down the attached load immediately */
387
	/* power down the attached load immediately */
356
	printf("Forced UPS shutdown triggered, do it...\n");
388
//	printf("Forced UPS shutdown (and wait for power)...\n");
357
	nut_shutdown();
389
	shutdown_ret();
358
}
390
}
359
391
360
/* initialize UPS */
392
/* initialize UPS */
Lines 533-538 Link Here
533
	
565
	
534
	/* setup flow control */
566
	/* setup flow control */
535
	types[type].flowControl.setup_flow_control();
567
	types[type].flowControl.setup_flow_control();
568
	
569
	/* tested only for BNT1200AP! */
570
	if (types[type].name=="BNT1200AP"){
571
		if (ser_send_char(upsfd,BATTERY_TEST)!=1){
572
				upslogx(LOG_NOTICE, "writing error");
573
				dstate_datastale();
574
				return;
575
		}
576
	};
536
}
577
}
537
578
538
/* display help */
579
/* display help */
Lines 562-567 Link Here
562
603
563
	/* now add the instant commands */
604
	/* now add the instant commands */
564
    dstate_addcmd ("test.battery.start");
605
    dstate_addcmd ("test.battery.start");
606
    dstate_addcmd ("shutdown.return");
607
    dstate_addcmd ("shutdown.stayoff");
565
	upsh.instcmd = instcmd;
608
	upsh.instcmd = instcmd;
566
}
609
}
567
610
Lines 572-578 Link Here
572
	addvar(VAR_VALUE, "linevoltage",   "Specify line voltage (110-120 or 220-240 V), because it cannot detect automagically (default: 230 V)");
615
	addvar(VAR_VALUE, "linevoltage",   "Specify line voltage (110-120 or 220-240 V), because it cannot detect automagically (default: 230 V)");
573
	addvar(VAR_VALUE, "modelname",     "Specify model name, because it cannot detect automagically (default: Unknown)");
616
	addvar(VAR_VALUE, "modelname",     "Specify model name, because it cannot detect automagically (default: Unknown)");
574
	addvar(VAR_VALUE, "serialnumber",  "Specify serial number, because it cannot detect automagically (default: Unknown)");
617
	addvar(VAR_VALUE, "serialnumber",  "Specify serial number, because it cannot detect automagically (default: Unknown)");
575
	addvar(VAR_VALUE, "type",       "Type of UPS like 'Trust', 'KP625AP', 'KIN2200AP', 'Egys', 'KIN525AP' or 'KIN1500AP' (default: 'Trust')");
618
	addvar(VAR_VALUE, "type",       "Type of UPS like 'Trust', 'KP625AP', 'KIN2200AP', 'Egys', 'KIN525AP' or 'KIN1500AP' or 'BNT1200AP' (default: 'Trust')");
576
	addvar(VAR_VALUE, "numOfBytesFromUPS",  "The number of bytes in a UPS frame");
619
	addvar(VAR_VALUE, "numOfBytesFromUPS",  "The number of bytes in a UPS frame");
577
	addvar(VAR_VALUE, "voltage",  "A quad to convert the raw data to human readable voltage");
620
	addvar(VAR_VALUE, "voltage",  "A quad to convert the raw data to human readable voltage");
578
	addvar(VAR_VALUE, "methodOfFlowControl",  "The flow control method engaged by the UPS");
621
	addvar(VAR_VALUE, "methodOfFlowControl",  "The flow control method engaged by the UPS");

Return to bug 12718