]> gitweb.maison.local Git - pyowl.git/commitdiff
Patch : no more need of a custom cp210.ko kernel module !
authorlionel <lionel@stargate.enneade.fdn.org>
Tue, 29 Dec 2015 09:01:17 +0000 (10:01 +0100)
committerlionel <lionel@stargate.enneade.fdn.org>
Tue, 29 Dec 2015 09:01:17 +0000 (10:01 +0100)
README
cm160Server.py
driver/README [deleted file]
driver/README.serial [new file with mode: 0644]
driver/python-serial_2.7-1_all.deb [new file with mode: 0644]
init/cm160

diff --git a/README b/README
index 7504097a92ffc40db4e7f525c7a4226dc5117a0c..973b280aee9d624154011337f9f1e8de281d3309 100644 (file)
--- a/README
+++ b/README
@@ -1,3 +1,17 @@
 ### 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.
index a5f4c27ae0c12b93f6bc451aef0e54c47ae0be50..d309b84a37ad18962e3b553bf5000f760db3401c 100755 (executable)
@@ -377,11 +377,8 @@ class 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()
diff --git a/driver/README b/driver/README
deleted file mode 100644 (file)
index 4bafa5e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-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).
diff --git a/driver/README.serial b/driver/README.serial
new file mode 100644 (file)
index 0000000..6ebfd87
--- /dev/null
@@ -0,0 +1,20 @@
+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 **
diff --git a/driver/python-serial_2.7-1_all.deb b/driver/python-serial_2.7-1_all.deb
new file mode 100644 (file)
index 0000000..fee90b5
Binary files /dev/null and b/driver/python-serial_2.7-1_all.deb differ
index c23f6e86fe3c00a9d3d1029bc20b23969a714689..02dd7c7faa5289fb610bf00654aa3208e4897c5f 100755 (executable)
@@ -13,24 +13,31 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
 . /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
                ;;