From owner-FreeBSD-users-jp@jp.freebsd.org  Wed Jan 21 22:56:09 1998
Received: by jaz.jp.freebsd.org (8.8.8+3.0Wbeta7/8.7.3) id WAA03137
	Wed, 21 Jan 1998 22:56:09 +0900 (JST)
Received: by jaz.jp.freebsd.org (8.8.8+3.0Wbeta7/8.7.3) with ESMTP id WAA03132
	for <FreeBSD-users-jp@jp.freebsd.org>; Wed, 21 Jan 1998 22:56:08 +0900 (JST)
Received: from localhost (localhost [127.0.0.1])
	by altair.aa.cs.keio.ac.jp (8.8.8/3.6Wbeta6) with ESMTP id WAA02410
	for <FreeBSD-users-jp@jp.freebsd.org>; Wed, 21 Jan 1998 22:56:07 +0900 (JST)
To: FreeBSD-users-jp@jp.freebsd.org
X-Mailer: Mew version 1.92.1 on Emacs 19.28 / Mule 2.3 (SUETSUMUHANA)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Message-Id: <19980121225607A.hanawa@aa.cs.keio.ac.jp>
Date: Wed, 21 Jan 1998 22:56:07 +0900
From: Toshihiro Hanawa <hanawa@aa.cs.keio.ac.jp>
X-Dispatcher: imput version 980119
Lines: 268
Reply-To: FreeBSD-users-jp@jp.freebsd.org
Precedence: bulk
X-Distribute: distribute [version 2.1 (Alpha) patchlevel=24]
X-Sequence: FreeBSD-users-jp 23577
Subject: [FreeBSD-users-jp 23577] upsd for Japanese APC SmartUPS
Errors-To: owner-FreeBSD-users-jp@jp.freebsd.org
Sender: owner-FreeBSD-users-jp@jp.freebsd.org

----Next_Part(Wed_Jan_21_22:55:10_1998_945)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

$B$O$J$o!w7DXf$H?=$7$^$9!#(B
# $B:G6a(B UPS$B$NOCBj$,B?$$$N$G(B...

$B$&$A$N8&5f<<$G!"(B1$BG/0J>e(B APC$B$N(BSmartUPS 1000J $B$r;H$C$F$$$^$9!#(B
$BF3F~$7$?$H$-$K(B upsd $B$K<j$rF~$l$F!"F|K\;EMMBP1~$K$7$F$_$^$7$?!#(B

$B$=$N$H$-$O(B upsd-2.0.1.6.tar.gz $B$H$$$&$b$N$rF~<j$7$?$N$G!"$=$l$KBP$9$k(B
$B%Q%C%A$K$J$C$F$$$^$9$,!"$*$=$i$/(B xperiment$B$N2<$K$"$k(B upsd $B$K$b$=$N$^$^(B
$BEv$?$k$N$G$O$J$$$+$H;W$$$^$9!#(B
(SmartUPS$B0J30$K;H$($k$+$I$&$+$OCN$j$^$;$s!#(B)
SmartUPS$BIUB0$N%^%K%e%"%k$H!"(BUPS $B$H(B tip $B$G$*OC$7$7$F$_$?7k2L$@$1$r85$K(B
$B$7$F$$$^$9$N$G!"0c$C$F$$$k$H$3$m$,$"$k$+$bCN$l$^$;$s!#(B
$BFC$K!"(Btune $B%3%^%s%I$G@_DjCM$NJQ99$,$&$^$/$$$/$+$I$&$+$o$+$j$^$;$s$N$G!"(B
$B$*$+$7$$$h$&$G$7$?$i65$($F$/$@$5$$!#(B

$B8=:_1?MQ$7$F$$$k%^%7%s$N(B upsd.conf$B$b$D$1$F$*$-$^$9!#(B


$B8=:_$N@_Dj$G$9$H!"$3$s$J46$8$G%m%0$,;D$j$^$9!#(B

Jan 21 22:06:33 galaxy upsd[234]: frequency: 50.00, maxvac: 100.7,
minvac: 98.8, voltage: 100.1
Jan 21 22:06:33 galaxy upsd[234]: load: 41.0, recharge: 100.0, temp:
28.3, vdc: 27.87, output voltage: 100.1

$B$=$l$>$l!"(B $B<~GH?t!":GBgEE05!":G>.EE05!"$=$N;~E@$NF~NOEE05(B
           $BIi2Y!"=<EEN(!"29EY!"%P%C%F%j!<$N=PNOEE05(B?$B!"=PNOEE05(B
$B$G$9!#(B

$B%1!<%V%k$O0J2<$N7k@~$GF0$$$F$$$^$9!#(B($B6&$K(B 9pin)

UPS   PC
1 --- 3 TxD
2 --- 2 RxD
9 --- 5 Gnd

-------------------------------------------------------------
	$B7DXf5A=NBg3X(B $BBg3X1!(B $BM}9)3X8&5f2J(B $BGn;N2]Dx(B
		$B7W;;5!2J3X@l96(B  $BE7Ln8&5f<<(B
	         $BH9(B $BIRGn(B (Toshihiro Hanawa)
               == hanawa@aa.cs.keio.ac.jp ==
	<http://www-amano.aa.cs.keio.ac.jp/~hanawa>
-------------------------------------------------------------


----Next_Part(Wed_Jan_21_22:55:10_1998_945)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Description: upsd.diff

--- upsd.c.org	Tue Jan 21 21:49:01 1997
+++ upsd.c	Tue Jan 21 21:49:13 1997
@@ -112,5 +112,5 @@
 
 	/* Set up the system log. */
-	openlog(NULL, LOG_CONS | LOG_PID, LOG_DAEMON);
+	openlog("upsd", LOG_CONS | LOG_PID, LOG_DAEMON);
 
 	/* Configure the daemon. */
--- apc.h.org	Fri Jan 17 21:00:39 1997
+++ apc.h	Fri Jan 17 21:00:52 1997
@@ -67,4 +67,5 @@
 extern int apc_tune(struct ups_val *);
 
+extern struct ups_model apc_SmartUPS_100;
 extern struct ups_model apc_SmartUPS_230;
 extern struct ups_model apc_SmartUPS_vs_420;
--- apc_static.c.org	Fri Jan 17 21:01:07 1997
+++ apc_static.c	Tue Jan 21 22:04:13 1997
@@ -44,5 +44,5 @@
 	{SMART_RECHARGE, "recharge", R_STATUS, 0, T_NUMBER, 5+2, 1, "f", 1},
 	{SMART_SELFTEST, "self-test", R_COMMAND, 0, T_BINARY, 0, 0, "W", 1},
-	{SMART_SERIAL, "serial", R_INFO, 0, T_BINARY, 8+2, 2, "n", 1},
+	{SMART_SERIAL, "serial", R_INFO, 0, T_BINARY, 14+2, 2, "n", 1},
 	{SMART_SHUTDELAY, "shutdown-delay", R_OPTION, APC_TOGGLE, T_NUMBER, 3+2, 0, "p", 1},
 	{SMART_SHUTDOWN, "shutdown", R_COMMAND, APC_WRITE, T_BINARY, 0, 0, "S", 1},
@@ -75,4 +75,54 @@
 };
 
+/* Legal values for SmartUPS(R) 100V units. */
+static struct ups_val apc_SmartUPS_100_values[] = {
+	{SMART_HTPOINT, {number: 108}},
+	{SMART_HTPOINT, {number: 110}},
+	{SMART_HTPOINT, {number: 112}},
+	{SMART_HTPOINT, {number: 114}},
+
+	{SMART_LTPOINT, {number: 81}},
+	{SMART_LTPOINT, {number: 85}},
+	{SMART_LTPOINT, {number: 90}},
+	{SMART_LTPOINT, {number: 92}},
+
+	{SMART_LOWBATDUR, {number: 2}},
+	{SMART_LOWBATDUR, {number: 5}},
+	{SMART_LOWBATDUR, {number: 7}},
+	{SMART_LOWBATDUR, {number: 10}},
+
+	{SMART_WAKEUPBCAP, {number: 0}},
+	{SMART_WAKEUPBCAP, {number: 15}},
+	{SMART_WAKEUPBCAP, {number: 50}},
+	{SMART_WAKEUPBCAP, {number: 90}},
+
+	{SMART_WAKEUPDELAY, {number: 0}},
+	{SMART_WAKEUPDELAY, {number: 60}},
+	{SMART_WAKEUPDELAY, {number: 180}},
+	{SMART_WAKEUPDELAY, {number: 300}},
+
+	{SMART_NVOLTAGE, {number: 100}},
+
+	{SMART_SHUTDELAY, {number: 20}},
+	{SMART_SHUTDELAY, {number: 180}},
+	{SMART_SHUTDELAY, {number: 300}},
+	{SMART_SHUTDELAY, {number: 600}},
+
+	{SMART_LINESENS, {binary: "L"}},
+	{SMART_LINESENS, {binary: "M"}},
+	{SMART_LINESENS, {binary: "H"}},
+
+	{SMART_LINEALARM, {binary: "0"}},
+	{SMART_LINEALARM, {binary: "L"}},
+	{SMART_LINEALARM, {binary: "T"}},
+	{SMART_LINEALARM, {binary: "N"}},
+
+	{SMART_LABEL, {binary: NULL}},
+
+	{SMART_BREPL, {binary: NULL}},
+
+	{0, {binary: NULL}}
+};
+
 /* Legal values for SmartUPS(R) 230V units. */
 static struct ups_val apc_SmartUPS_230_values[] = {
@@ -139,4 +189,16 @@
 	{SMART_TBRST, "batteries-restore", SMART_TBLOW, "+", 1},
 	{0, NULL, 0, NULL, 0}
+};
+
+struct ups_model apc_SmartUPS_100 = {
+	"apc-smart",
+	"smart-ups",
+	100,
+	sizeof(apc_SmartUPS_registers)/sizeof(struct ups_reg),
+	apc_SmartUPS_registers,
+	apc_SmartUPS_triggers,
+	apc_SmartUPS_100_values,
+	apc_poll,
+	apc_tune
 };
 

----Next_Part(Wed_Jan_21_22:55:10_1998_945)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Description: upsd.conf

# $Id: upsd.conf,v 2.0 1996/01/28 11:50:37 alexis Exp $
#
# UPS Daemon
# The Wild Wind Communications, 1995, 1996
#
# See file LICENSE for the distribution terms of this software.
#

ups "smart-ups" (100) proto "apc-smart" {
	device			"/dev/cuaa1"
	speed			2400
	read-timeout		2
	write-block-size	1
	write-block-delay	50
	queue-size		64
}


every 5 {# check events every 5 seconds
	nop
}

on "initialize" != "SM" {
	poll "initialize"
	poll "copyright"
	poll "firmware"
	poll "serial"
	poll "manufactured"
	poll "batteries-replaced"
	log notice "Copyright %copyright% firmware %firmware% serial no. %serial% manufactured %manufactured% battery replace %batteries-replaced%"
	after 60 every 60 {
		log emerg "Cannot put the UPS into smart mode!"
	}
}

#every 600 {
#	tune "high-transfer-point"		110	#108,110,112,114
#	tune "low-transfer-point"		90	#81,85,90,92
#	tune "line-alarm"			"0"	#0,L,T,N
#	tune "line-sensitivity"			"L"	#L,M,H
#	tune "low-batteries-duration"		2	#2,5,7,10
#	tune "nominal-voltage"			100
#	tune "shutdown-delay"			20	#20,180,300,600
#	tune "wakeup-batteries-capacity"	0	#0,15,50,90
#	tune "wakeup-delay"			0	#0,60,180,300
#	tune "batteries-replaced"		"01/01/77"
#	tune "label"				"WildWind"
#}

every 600 {			# poll the UPS
#	poll "last-test"
#	poll "light-test"
	poll "line-frequency"
	poll "line-maxvac"
	poll "line-minvac"
	poll "line-voltage"
	poll "load"
	poll "recharge"
	poll "temperature"
	poll "vdc"
	poll "voltage"

#	log notice "last test: %last-test%, light test: %light-test%"
#	log notice "last test: %last-test%"
	log notice "frequency: %line-frequency%, maxvac: %line-maxvac%, minvac: %line-minvac%, voltage: %line-voltage%"
	log notice "load: %load%, recharge: %recharge%, temp: %temperature%, vdc: %vdc%, output voltage: %voltage%"

	on "load" > 95 {
		log alert "UPS load is too high: %load%"
	}
}

on "line-fail" {
	log emerg "*** ALERT! Source power line failed, save your work! ***"
}

on "line-fail" after 120 {
	log emerg "*** ALERT! System shutdown in 60 seconds, LOGOUT NOW! ***"
}

on "line-restore" {
	log emerg "Source power line restored, you may continue your work."
}

on "line-fail" after 180 {
	log emerg "*** ALERT! THE SYSTEM IS SHUTTING DOWN! ***"

	poll "shutdown"
	poll "shutdown"
	poll "power-test"
	poll "power-test"
	poll "shutdown"
	poll "shutdown"

	sleep 2

	exec "/sbin/halt &"

	poll "power-test"
	poll "shutdown"
	poll "power-test"
	poll "shutdown"
	poll "power-test"
	poll "shutdown"
	poll "power-test"

	sleep 1000	# let us wait peacefully
}

----Next_Part(Wed_Jan_21_22:55:10_1998_945)----
