### PyOWL
# Py daemon storing OWL data on MySQL
+Requires a python-serial or pyserial (depending of your Linux distribution) module version >= 2.7 to be able to set the correct baud rate when connecting the CM160.
+If not, it will die during initialisation.
+
+If you really cannot update to it (there is no dependencies on Debian Jessie but who knows ...) then you will have to hack a bit :
+- copy the cp210.c file in "driver" directory to you kernel source tree and recompile
+or
+- recompile only the cp210.ko module using you kernel headers and overwrite the existing one found into /lib/modules/blablabla
+- rmmod cp210; modprobe cp210
+- find the following line in cm160Server.py :
+self.__ser = serial.Serial(self.__serialPortName, 250000, bytesize=8, parity='N', stopbits=1, xonxoff=False, rtscts=False, dsrdtr = False, timeout=30)
+and change "250000" to "0" like this :
+self.__ser = serial.Serial(self.__serialPortName, 0, bytesize=8, parity='N', stopbits=1, xonxoff=False, rtscts=False, dsrdtr = False, timeout=30)
+
+The daemon should know being able to find, connect and retrieve data from the CM160.
self.__ser = None
try:
- # TODO WHY : why must we use a custom cp210x driver ? why can't we just specify the baud rate here ?
- # self.__ser = serial.Serial(self.__serialPortName, 250000, bytesize=8, parity='N', stopbits=1, xonxoff=False, rtscts=False, dsrdtr = False, timeout=30)
- #Assume we have the custom cp210x driver loaded that maps the requested baud rate of 0 to a physical port speed of 250000 Bps required
- #for the CM160 device.
- self.__ser = serial.Serial(self.__serialPortName, 0, bytesize=8, parity='N', stopbits=1, xonxoff=False, rtscts=False, dsrdtr = False, timeout=30)
+# Important here : you MUST have a python-serial (or pyserial) module version >= 2.7 (take a look at the README)
+ self.__ser = serial.Serial(self.__serialPortName, 250000, bytesize=8, parity='N', stopbits=1, xonxoff=False, rtscts=False, dsrdtr = False, timeout=30)
sd = self.__ser.getSettingsDict()
keys = sd.keys()
+++ /dev/null
-Patched serial driver for kernel 3.16.2
-
-diff :
-
-407,408c407,408
-< if( baud == 0) baud = 250000; /* KLUDGE for Owl Energy Monitor, Use baud rate (B0 Hang up) that is unlikely to be of any use */
-< else if (baud <= 300) baud = 300;
----
-> if (baud <= 300)
-> baud = 300;
-
-
-Warning : Makefile does not fully handle installation (just take a look at it).
-You have to manually copy/remove/delete stuff yourself (mainly because I'm lazy, but also because I don't like scripts playing with things in /lib/modules).
--- /dev/null
+REALLY READ the main README before doing anything with that stuff !!!
+
+
+Patched serial driver for kernel 3.16.2
+
+diff :
+
+407,408c407,408
+< if( baud == 0) baud = 250000; /* KLUDGE for Owl Energy Monitor, Use baud rate (B0 Hang up) that is unlikely to be of any use */
+< else if (baud <= 300) baud = 300;
+---
+> if (baud <= 300)
+> baud = 300;
+
+
+Warning : Makefile does not fully handle installation (just take a look at it).
+You have to manually copy/remove/delete stuff yourself (mainly because I'm lazy, but also because I don't like scripts playing with things in /lib/modules).
+
+
+** The Debian package came from testing (stable == Jessie) and can be installed as simple as "dpkg -i *.deb" on Jessie. Works like a charm **
. /lib/lsb/init-functions
-DAEMON=/usr/local/owl/cm160server.py
-PIDFILE=/usr/local/owl/cm160server.pid
-OPTIONS="-s 1"
+DAEMON_PATH=/usr/local/owl/
+DAEMON=cm160Server.py
+PIDFILE=cm160Server.pid
+OPTIONS="-s 0"
+cd $DAEMON_PATH
test -x $DAEMON || exit 5
# RUNASUSER=ntp
case $1 in
start)
+ DATE=`date +%Y%m%d-%H:%m:%S`
+ if [ -f $DAEMON_PATH/cm160Server.log ]
+ then
+ mv $DAEMON_PATH/cm160Server.log $DAEMON_PATH/cm160Server.log_$DATE
+ fi
log_daemon_msg "Starting OWL data graber daemon" "cm160server.py"
- start-stop-daemon --start --quiet --oknodo --background --pidfile $PIDFILE --startas $DAEMON -- $OPTIONS
+ start-stop-daemon --start --quiet --oknodo --background --pidfile $PIDFILE --chdir $DAEMON_PATH --startas $DAEMON -- $OPTIONS
status=$?
log_end_msg $status
;;
stop)
log_daemon_msg "Stopping OWL data graber daemon" "cm160server.py"
- start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
+ start-stop-daemon --stop --quiet --oknodo --name $DAEMON
log_end_msg $?
rm -f $PIDFILE
;;