Projects/Sysutils/UpsDaemon

UpsDaemon 1.0

A Simple UPS Program for UNIX

About UpsDaemon

The upsdaemon is a simple program to monitor os (UPS) series APC-Pro. When the power fails, the UpsDaemon it effects shutdown the system.

Keywords:
UpsDaemon, Shell-script, Serial-ports, Sedgesort (Sedgewick quicksort optimization)
Downloads section
The UpsDaemon follows the standard of serial programming for Posix; see: README

Accessing Serial Ports
As with all devices, UNIX provides access to serial via device files.

Serial Port Files
Serial port on a Unix:
System Port 1 Port 2
FreeBSD /dev/cuad0 /dev/cuad1
Irix /dev/ttyf1 /dev/ttyf2
Aix /dev/tty01 /dev/tty02

Pinout Serial
RS-574 (IBM PC/AT)
The interface is used exclusively by PC manufacturers and uses a 9-pin male D-Sub coonector:
db9.gif
Pin Description Pin Description
1 DCD - Data Carrier Detect 6 Data Set Ready
2 RXD - Received Data 7 RTS - Request Send
3 TXD - Transmitted Data 8 CTS - Clear To Sent
4 DTR - Data Terminal Ready 9 Ring Detect
5 GND - Logic Ground

Ascii Control Codes
Table control purposes:
Name Binary Octal Decimal Hexadecimal
NUL 00000000 000 0 00
SOH 00000001 001 1 01
STX 00000010 002 2 02
ETX 00000011 003 3 03
EOT 00000100 004 4 04
ENQ 00000101 005 5 05
ACK 00000110 006 6 06
BEL 00000111 007 7 07
BS 00001000 010 8 08
HT 00001001 011 9 09
NL 00001010 012 10 0A
VT 00001011 013 11 0B
NP, FF 00001100 014 12 0C
Name Binary Octal Decimal Hexadecimal
CR 00001101 015 13 0D
SO 00001110 016 14 0E
SI 00001111 017 15 0F
DLE 00010000 020 16 10
XON, DC1 00010001 021 17 11
DC2 00010010 022 18 12
XOFF, DC3 00010011 023 19 13
DC4 00010100 024 20 14
NAK 00010101 025 21 15
SYN 00010110 026 22 16
ETB 00010111 027 23 17
CAN 00011000 030 24 18
EM 00011001 031 25 19
SUB 00011010 032 26 1A
ESC 00011011 033 27 1B
FS 00011100 034 28 1C
GS 00011101 035 29 1D
RS 00011110 036 30 1E
US 00011111 037 31 1F

Installation

Using the FreeBSD ports system:
cd /usr/ports/sysutils/upsdaemon make install clean
Using the FreeBSD pkg system:
pkg install sysutils/upsdaemon