From a7c331257449686e24f798b73fd28130e774c5f1 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 12 May 2026 18:30:46 +0200 Subject: [PATCH] Creazione folder x 2.6 e 3.0... --- IOB-PI/vers2.6 12bit/IOB.cfg | 68 ++ IOB-PI/vers2.6 12bit/IOB.cfg.donati | 35 + IOB-PI/vers2.6 12bit/IOB.cfg.steamware | 35 + IOB-PI/vers2.6 12bit/Mapo.zip | Bin 0 -> 20767 bytes IOB-PI/vers2.6 12bit/Mapo.zip.md5 | 1 + IOB-PI/vers2.6 12bit/MapoIOB | 41 + IOB-PI/vers2.6 12bit/MapoIOB.service | 24 + IOB-PI/vers2.6 12bit/MapoIOB_logrot | 28 + IOB-PI/vers2.6 12bit/checkAlive.sh | 20 + IOB-PI/vers2.6 12bit/cleanPython.sh | 14 + IOB-PI/vers2.6 12bit/convertLogFile.py | 46 + IOB-PI/vers2.6 12bit/crontab | 1 + IOB-PI/vers2.6 12bit/install-RPI-IOB.sh | 54 ++ IOB-PI/vers2.6 12bit/readFile.py | 152 ++++ IOB-PI/vers2.6 12bit/readParallela.py | 796 ++++++++++++++++++ .../{ => vers2.6 12bit}/readParallela_12.py | 0 IOB-PI/vers2.6 12bit/readSeriale.py | 363 ++++++++ IOB-PI/vers2.6 12bit/saveTemp.sh | 17 + IOB-PI/vers2.6 12bit/sendReboot.py | 135 +++ IOB-PI/vers2.6 12bit/sendRebootIOB | 33 + IOB-PI/vers2.6 12bit/sendRebootIOB.service | 22 + IOB-PI/vers2.6 12bit/setIobConf.sh | 26 + IOB-PI/vers2.6 12bit/unix.py | 31 + IOB-PI/vers2.6 12bit/unix.pyc | Bin 0 -> 669 bytes IOB-PI/vers2.6 12bit/update-RPI-IOB.sh | 54 ++ IOB-PI/vers2.6 12bit/win.py | 32 + IOB-PI/vers2.6 8bit/IOB.cfg | 56 ++ IOB-PI/vers2.6 8bit/IOB.cfg.donati | 35 + IOB-PI/vers2.6 8bit/IOB.cfg.steamware | 35 + IOB-PI/vers2.6 8bit/MapoIOB | 41 + IOB-PI/vers2.6 8bit/MapoIOB.service | 24 + IOB-PI/vers2.6 8bit/MapoIOB_logrot | 28 + IOB-PI/vers2.6 8bit/checkAlive.sh | 20 + IOB-PI/vers2.6 8bit/cleanPython.sh | 14 + IOB-PI/vers2.6 8bit/convertLogFile.py | 46 + IOB-PI/vers2.6 8bit/crontab | 1 + IOB-PI/vers2.6 8bit/install-RPI-IOB.sh | 54 ++ IOB-PI/vers2.6 8bit/readFile.py | 152 ++++ IOB-PI/vers2.6 8bit/readParallela.py | 733 ++++++++++++++++ IOB-PI/{ => vers2.6 8bit}/readParallela_8.py | 0 IOB-PI/vers2.6 8bit/readSeriale.py | 363 ++++++++ IOB-PI/vers2.6 8bit/saveTemp.sh | 17 + IOB-PI/vers2.6 8bit/sendReboot.py | 135 +++ IOB-PI/vers2.6 8bit/sendRebootIOB | 33 + IOB-PI/vers2.6 8bit/sendRebootIOB.service | 22 + IOB-PI/vers2.6 8bit/setIobConf.sh | 26 + IOB-PI/vers2.6 8bit/unix.py | 31 + IOB-PI/vers2.6 8bit/unix.pyc | Bin 0 -> 669 bytes IOB-PI/vers2.6 8bit/update-RPI-IOB.sh | 54 ++ IOB-PI/vers2.6 8bit/win.py | 32 + IOB-PI/vers3.x/IOB.cfg | 72 ++ IOB-PI/vers3.x/IOB.cfg.donati | 35 + IOB-PI/vers3.x/IOB.cfg.steamware | 35 + IOB-PI/vers3.x/Mapo.zip | Bin 0 -> 20767 bytes IOB-PI/vers3.x/Mapo.zip.md5 | 1 + IOB-PI/vers3.x/MapoIOB | 41 + IOB-PI/vers3.x/MapoIOB.service | 24 + IOB-PI/vers3.x/MapoIOB_logrot | 28 + IOB-PI/vers3.x/checkAlive.sh | 20 + IOB-PI/vers3.x/cleanPython.sh | 14 + IOB-PI/vers3.x/convertLogFile.py | 46 + IOB-PI/vers3.x/crontab | 1 + IOB-PI/vers3.x/install-RPI-IOB.sh | 54 ++ IOB-PI/vers3.x/readFile.py | 152 ++++ IOB-PI/vers3.x/readParallela.py | 435 ++++++++++ IOB-PI/vers3.x/readSeriale.py | 363 ++++++++ IOB-PI/vers3.x/saveTemp.sh | 17 + IOB-PI/vers3.x/sendReboot.py | 138 +++ IOB-PI/vers3.x/sendRebootIOB | 33 + IOB-PI/vers3.x/sendRebootIOB.service | 22 + IOB-PI/vers3.x/setIobConf.sh | 26 + IOB-PI/vers3.x/testRedis.py | 48 ++ IOB-PI/vers3.x/unix.py | 31 + IOB-PI/vers3.x/unix.pyc | Bin 0 -> 669 bytes IOB-PI/vers3.x/update-RPI-IOB.sh | 54 ++ IOB-PI/vers3.x/win.py | 32 + 76 files changed, 5702 insertions(+) create mode 100644 IOB-PI/vers2.6 12bit/IOB.cfg create mode 100644 IOB-PI/vers2.6 12bit/IOB.cfg.donati create mode 100644 IOB-PI/vers2.6 12bit/IOB.cfg.steamware create mode 100644 IOB-PI/vers2.6 12bit/Mapo.zip create mode 100644 IOB-PI/vers2.6 12bit/Mapo.zip.md5 create mode 100644 IOB-PI/vers2.6 12bit/MapoIOB create mode 100644 IOB-PI/vers2.6 12bit/MapoIOB.service create mode 100644 IOB-PI/vers2.6 12bit/MapoIOB_logrot create mode 100644 IOB-PI/vers2.6 12bit/checkAlive.sh create mode 100644 IOB-PI/vers2.6 12bit/cleanPython.sh create mode 100644 IOB-PI/vers2.6 12bit/convertLogFile.py create mode 100644 IOB-PI/vers2.6 12bit/crontab create mode 100644 IOB-PI/vers2.6 12bit/install-RPI-IOB.sh create mode 100644 IOB-PI/vers2.6 12bit/readFile.py create mode 100644 IOB-PI/vers2.6 12bit/readParallela.py rename IOB-PI/{ => vers2.6 12bit}/readParallela_12.py (100%) create mode 100644 IOB-PI/vers2.6 12bit/readSeriale.py create mode 100644 IOB-PI/vers2.6 12bit/saveTemp.sh create mode 100644 IOB-PI/vers2.6 12bit/sendReboot.py create mode 100644 IOB-PI/vers2.6 12bit/sendRebootIOB create mode 100644 IOB-PI/vers2.6 12bit/sendRebootIOB.service create mode 100644 IOB-PI/vers2.6 12bit/setIobConf.sh create mode 100644 IOB-PI/vers2.6 12bit/unix.py create mode 100644 IOB-PI/vers2.6 12bit/unix.pyc create mode 100644 IOB-PI/vers2.6 12bit/update-RPI-IOB.sh create mode 100644 IOB-PI/vers2.6 12bit/win.py create mode 100644 IOB-PI/vers2.6 8bit/IOB.cfg create mode 100644 IOB-PI/vers2.6 8bit/IOB.cfg.donati create mode 100644 IOB-PI/vers2.6 8bit/IOB.cfg.steamware create mode 100644 IOB-PI/vers2.6 8bit/MapoIOB create mode 100644 IOB-PI/vers2.6 8bit/MapoIOB.service create mode 100644 IOB-PI/vers2.6 8bit/MapoIOB_logrot create mode 100644 IOB-PI/vers2.6 8bit/checkAlive.sh create mode 100644 IOB-PI/vers2.6 8bit/cleanPython.sh create mode 100644 IOB-PI/vers2.6 8bit/convertLogFile.py create mode 100644 IOB-PI/vers2.6 8bit/crontab create mode 100644 IOB-PI/vers2.6 8bit/install-RPI-IOB.sh create mode 100644 IOB-PI/vers2.6 8bit/readFile.py create mode 100644 IOB-PI/vers2.6 8bit/readParallela.py rename IOB-PI/{ => vers2.6 8bit}/readParallela_8.py (100%) create mode 100644 IOB-PI/vers2.6 8bit/readSeriale.py create mode 100644 IOB-PI/vers2.6 8bit/saveTemp.sh create mode 100644 IOB-PI/vers2.6 8bit/sendReboot.py create mode 100644 IOB-PI/vers2.6 8bit/sendRebootIOB create mode 100644 IOB-PI/vers2.6 8bit/sendRebootIOB.service create mode 100644 IOB-PI/vers2.6 8bit/setIobConf.sh create mode 100644 IOB-PI/vers2.6 8bit/unix.py create mode 100644 IOB-PI/vers2.6 8bit/unix.pyc create mode 100644 IOB-PI/vers2.6 8bit/update-RPI-IOB.sh create mode 100644 IOB-PI/vers2.6 8bit/win.py create mode 100644 IOB-PI/vers3.x/IOB.cfg create mode 100644 IOB-PI/vers3.x/IOB.cfg.donati create mode 100644 IOB-PI/vers3.x/IOB.cfg.steamware create mode 100644 IOB-PI/vers3.x/Mapo.zip create mode 100644 IOB-PI/vers3.x/Mapo.zip.md5 create mode 100644 IOB-PI/vers3.x/MapoIOB create mode 100644 IOB-PI/vers3.x/MapoIOB.service create mode 100644 IOB-PI/vers3.x/MapoIOB_logrot create mode 100644 IOB-PI/vers3.x/checkAlive.sh create mode 100644 IOB-PI/vers3.x/cleanPython.sh create mode 100644 IOB-PI/vers3.x/convertLogFile.py create mode 100644 IOB-PI/vers3.x/crontab create mode 100644 IOB-PI/vers3.x/install-RPI-IOB.sh create mode 100644 IOB-PI/vers3.x/readFile.py create mode 100644 IOB-PI/vers3.x/readParallela.py create mode 100644 IOB-PI/vers3.x/readSeriale.py create mode 100644 IOB-PI/vers3.x/saveTemp.sh create mode 100644 IOB-PI/vers3.x/sendReboot.py create mode 100644 IOB-PI/vers3.x/sendRebootIOB create mode 100644 IOB-PI/vers3.x/sendRebootIOB.service create mode 100644 IOB-PI/vers3.x/setIobConf.sh create mode 100644 IOB-PI/vers3.x/testRedis.py create mode 100644 IOB-PI/vers3.x/unix.py create mode 100644 IOB-PI/vers3.x/unix.pyc create mode 100644 IOB-PI/vers3.x/update-RPI-IOB.sh create mode 100644 IOB-PI/vers3.x/win.py diff --git a/IOB-PI/vers2.6 12bit/IOB.cfg b/IOB-PI/vers2.6 12bit/IOB.cfg new file mode 100644 index 0000000..44f53bd --- /dev/null +++ b/IOB-PI/vers2.6 12bit/IOB.cfg @@ -0,0 +1,68 @@ +[id] +idxMacchina = 0001 + +[web] +URLBASE = http://10.74.82.218/MP/IO/IOB/input/ +URLALIVE = http://10.74.82.218/MP/IO/IOB +URLENABLED = http://10.74.82.218/MP/IO/IOB/enabled/ +URLADV1 = ?valore= +URLREBO = http://10.74.82.218/MP/IO/sendReboot.aspx?idxMacchina= + +[time] +SAMPLETIME = 0.05 +TIMEOUTSHORT = 0.30 +TIMEOUTLONG = 50 +SENDURLTIME = 0.15 +NMAXSEND = 5 + +[log] +LOGLEVEL = 10 +LOGFILE = logfile.txt +LOGREBO = logReboot.txt + +[comm] +port = /dev/ttyAMA0 + +[blink] +MAX_COUNTER_BLINK = 30 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 0 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 +bit8 = 0 +bit9 = 0 +bit10 = 0 +bit11 = 0 + +[invert] +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 0 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 +bit8 = 0 +bit9 = 0 +bit10 = 0 +bit11 = 0 + +[filter] +MAX_COUNTER_FILTER = 8 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 0 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 +bit8 = 0 +bit9 = 0 +bit10 = 0 +bit11 = 0 diff --git a/IOB-PI/vers2.6 12bit/IOB.cfg.donati b/IOB-PI/vers2.6 12bit/IOB.cfg.donati new file mode 100644 index 0000000..29c3d61 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/IOB.cfg.donati @@ -0,0 +1,35 @@ +[id] +idxMacchina = 2007 + +[web] +URLBASE = http://192.168.51.77/MP/IO/IOB/input/ +URLALIVE = http://192.168.51.77/MP/IO/IOB +URLENABLED = http://192.168.51.77/MP/IO/IOB/enabled/ +URLADV1 = ?valore= +URLREBO = http://192.168.51.77/MP/IO/sendReboot.aspx?idxMacchina= + +[time] +SAMPLETIME = 0.05 +TIMEOUTSHORT = 0.30 +TIMEOUTLONG = 50 +SENDURLTIME = 0.15 +NMAXSEND = 5 + +[log] +LOGLEVEL = 10 +LOGFILE = logfile.txt +LOGREBO = logReboot.txt + +[comm] +port = /dev/ttyAMA0 + +[blink] +MAX_COUNTER_BLINK = 30 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 1 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 diff --git a/IOB-PI/vers2.6 12bit/IOB.cfg.steamware b/IOB-PI/vers2.6 12bit/IOB.cfg.steamware new file mode 100644 index 0000000..920043f --- /dev/null +++ b/IOB-PI/vers2.6 12bit/IOB.cfg.steamware @@ -0,0 +1,35 @@ +[id] +idxMacchina = 1005 + +[web] +URLBASE = http://10.74.82.218/MP/IO/IOB/input/ +URLALIVE = http://10.74.82.218/MP/IO/IOB +URLENABLED = http://10.74.82.218/MP/IO/IOB/enabled/ +URLADV1 = ?valore= +URLREBO = http://10.74.82.218/MPIO/sendReboot.aspx?idxMacchina= + +[time] +SAMPLETIME = 0.05 +TIMEOUTSHORT = 0.30 +TIMEOUTLONG = 50 +SENDURLTIME = 0.15 +NMAXSEND = 5 + +[log] +LOGLEVEL = 10 +LOGFILE = logfile.txt +LOGREBO = logReboot.txt + +[comm] +port = /dev/ttyAMA0 + +[blink] +MAX_COUNTER_BLINK = 30 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 1 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 diff --git a/IOB-PI/vers2.6 12bit/Mapo.zip b/IOB-PI/vers2.6 12bit/Mapo.zip new file mode 100644 index 0000000000000000000000000000000000000000..1a8e9bc08a28dc99798531d3d43e6ea18c192345 GIT binary patch literal 20767 zcmZ6yV{mBO(ls30wr$(CwPV}1ZQFLTW7~FiZ133qa_Zi?}~#X*;W5A20J7{|A^6=-S#^Vp7>gT zvn#?QBg}w4j73vpDGjJ4D3xO7bD&hnEPPLcnnf8^Z+>cOHgkFo_5$agWcHNj{ccEM zvD$PyhqSItJ;{2i$RRUc8hzC;ANpShW*_NNRi^1@0|F=GntDv|P(ai_M3i8Q$?(6S zf%|Y%o={%|S>1ID$jDp+1A>#O?A()}?YYzkc&Qd(gQn2XIs8U*Eiz}g+1V`HJ$}=_ zFiIqtD^d>me7Qu6Gyo@d`jkEUYstK^i9iooJVmjM*sgNxh1Y$sDa)A_kC(jWhp5Wf z=+r6PnKPW31}U<$BFAu*1r7+LG-GYg@|=Wjz!sOorq*#Rp@okOXLz|nVqv>$3@Kjd>YTdhn3_9y?L2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zD?Lc{Fy!_hF78&vk{_f{?)}9-Ui%foFd8;OZl0x#_Sn&?ULgP7JC%t zn}kP=0j?#Tz(d$RHJP44kh^`fmUsXNM)*02FBFut;VvfsivpqRHV9BH7$}? z`gR&l&=i|{_9@gPi|u*h#`WTlpIwTa*dGsH&3gYf*8(ZfwkQ``cW2G0Lg4tD{#@mYc<_V`g9-+$_P5^;_C1i1*mv z3-xW+P9ScKC9XMGe5fpQyF5!hsc#k}QB*dYeSg%j9 z9{(KiI<9|UOSVyKXjS@o{rtFq_~!jX<8NcF}f^g@wa`;xLv>WwILoH6xJd+FUm*+5)g6CcU{m|ik_ya%9h^w)4Pcu8m!A_D2mA4m@Fie{ z9J=#>p`(%dz+Hy~A*g=lwFBnCz9}TW7Vrc*G?oBEV51Kb1f~5B9ol|?S+I8niN!!j z>~|-NqxjG47)Ur1(1bgbh98A~CetTDl7OHbB-#hVVEH)-P6H(WKZ?=8ELiwWVod?{ z-Vqr%7zFG5NMJ6Y{yPAVs{X(<`1Aycj*+jCZTRH5c*F|4Soc;DkME(TJzu$M`}bc3a)iXsHXP! z)E5kaGvot^>}zy_>3)YC!PL=(evpzKT;Bo{mHtl>G%ya{Y)QB~{GYA&;(4lreVB{` N_~`@DqwV~`-QSy{yHx-H literal 0 HcmV?d00001 diff --git a/IOB-PI/vers2.6 12bit/Mapo.zip.md5 b/IOB-PI/vers2.6 12bit/Mapo.zip.md5 new file mode 100644 index 0000000..f6a6154 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/Mapo.zip.md5 @@ -0,0 +1 @@ +50249a64efeef80bad924f3f6351edbc \ No newline at end of file diff --git a/IOB-PI/vers2.6 12bit/MapoIOB b/IOB-PI/vers2.6 12bit/MapoIOB new file mode 100644 index 0000000..1d8f821 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/MapoIOB @@ -0,0 +1,41 @@ +#! /bin/bash +### BEGIN INIT INFO +# Provides: MapoIOB: script Steamware per avvio driver IOB +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Steamware's MapoIOB driver +# Description: Steamware's MapoIOB driver, versione lettura porta parallela +### END INIT INFO + +# /etc/init.d/MapoIOB + +export HOME +case "$1" in + start) + echo "Starting readParallela" + cd /home/pi/steamware + /usr/bin/python ./readParallela.py 2>&1 & + ;; + stop) + echo "Stopping readParallela" + RS_PID=`ps auxwww | grep readParallela.py | head -1 | awk '{print $2}'` + kill -9 $RS_PID + cd /home/pi/steamware + rm .lockfile + ;; + restart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + $0 stop + killall python + $0 start + ;; + *) + echo "Usage: /etc/init.d/MapoIOB {start|stop|restart}" + exit 1 + ;; +esac +exit 0 + diff --git a/IOB-PI/vers2.6 12bit/MapoIOB.service b/IOB-PI/vers2.6 12bit/MapoIOB.service new file mode 100644 index 0000000..7803ccc --- /dev/null +++ b/IOB-PI/vers2.6 12bit/MapoIOB.service @@ -0,0 +1,24 @@ +[Unit] +SourcePath=/etc/init.d/MapoIOB +Description=LSB: Steamware's MapoIOB driver +Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target +Wants=network-online.target +After=network.target network-online.target auditd.service +Conflicts=shutdown.target + +[Service] +Type=forking +Restart=on-failure +RestartSec=5 +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=yes +SysVStartPriority=1 +ExecStartPre=/bin/sleep 5 +ExecStart=/etc/init.d/MapoIOB start +ExecStop=/etc/init.d/MapoIOB stop + +[Install] +WantedBy=multi-user.target diff --git a/IOB-PI/vers2.6 12bit/MapoIOB_logrot b/IOB-PI/vers2.6 12bit/MapoIOB_logrot new file mode 100644 index 0000000..13410b9 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/MapoIOB_logrot @@ -0,0 +1,28 @@ +/var/log/MapoIOB.log { + size 8M + copytruncate + create 700 pi pi + dateext + rotate 100 + compress + maxage 366 + missingok +} +/var/log/logReboot.txt { + size 1M + copytruncate + create 700 pi pi + dateext + rotate 30 + compress + missingok +} +/var/log/logTemp.txt { + size 1M + copytruncate + create 700 pi pi + dateext + rotate 30 + compress + missingok +} diff --git a/IOB-PI/vers2.6 12bit/checkAlive.sh b/IOB-PI/vers2.6 12bit/checkAlive.sh new file mode 100644 index 0000000..aace73d --- /dev/null +++ b/IOB-PI/vers2.6 12bit/checkAlive.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# controlla se il logfile è correntemente scritto (quindi MapoIOB è alive) altrimenti riavvia! + +DATE=`date +%Y-%m-%d` +cd /var/log +if [ -f MapoIOB.log ] + then + # controllo SE sia stato acceduto da meno di 2 minuti (=alive da log...) + trovato=`find . -name 'MapoIOB*' -cmin -1` + if [[ $trovato != './MapoIOB.log' ]] + then + /etc/init.d/MapoIOB restart + echo $date + "riavvio!" + fi +else + # in questo caso AVVIO il processo MapoIOB + /etc/init.d/MapoIOB start + echo $date + "file non trovato, avvio!" +fi diff --git a/IOB-PI/vers2.6 12bit/cleanPython.sh b/IOB-PI/vers2.6 12bit/cleanPython.sh new file mode 100644 index 0000000..c4f616a --- /dev/null +++ b/IOB-PI/vers2.6 12bit/cleanPython.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +DATE=`date +%Y-%m-%d_%T` +# log inizio pulizia +echo $DATE " - INIZIO pulizia processi python" >> clean.log +# effettua pulizia processi: killa tutti i processi python +killall python + +# avvia MapoIob +/etc/init.d/MapoIOB start + +# log fatto! +DATE=`date +%Y-%m-%d_%T` +echo $DATE " - FINE pulizia processi python + riavvio MapoIOB" >> clean.log diff --git a/IOB-PI/vers2.6 12bit/convertLogFile.py b/IOB-PI/vers2.6 12bit/convertLogFile.py new file mode 100644 index 0000000..760c2a9 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/convertLogFile.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# readFile v. 0.1 +# - single instance timer +# - invio multiplo x send eventi accodati +#--------------------------------------------------------------- +import os, sys +import argparse +#-------------------------------------------------------------- + +# gestione parser argomenti in input +parser = argparse.ArgumentParser() +parser.add_argument("inFile") +parser.add_argument("outFile") +args = parser.parse_args() + +#with open('logfile.txt', 'r') as inf, open('persMem.dat',"w") as outf: +with open(args.inFile, 'r') as inf, open(args.outFile,"w") as outf: + data = inf.readlines() + + lastDt = "" + lastMs = 0 + stepMs = 200 + + for line in data: + words = line.split() + if words[2] == 'queue': + # recupero dataOra + newDt = words[0].replace("-","") + words[1].replace(":","") + + # verifico se data/ora identica... + if (lastDt == newDt): + # --> aggiungo stepMs + lastMs += stepMs + else: + lastMs = 0 + + lastDt = newDt + + newDt = newDt + '{:03d}'.format(lastMs) #str(lastMs) + #print words[0].replace("-","") + words[1].replace(":","") + " | " + newDt + "\n" + + # print words + # outf.write(words[0].replace("-","") + words[1].replace(":","") + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n') + outf.write(newDt + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n') \ No newline at end of file diff --git a/IOB-PI/vers2.6 12bit/crontab b/IOB-PI/vers2.6 12bit/crontab new file mode 100644 index 0000000..74fe381 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/crontab @@ -0,0 +1 @@ +* * * * * /bin/bash /home/pi/steamware/checkAlive.sh >> /home/pi/stdout 2>> /home/pi/stderr diff --git a/IOB-PI/vers2.6 12bit/install-RPI-IOB.sh b/IOB-PI/vers2.6 12bit/install-RPI-IOB.sh new file mode 100644 index 0000000..d521931 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/install-RPI-IOB.sh @@ -0,0 +1,54 @@ +#|/bin/bash + +#installa il necessario per RPI-3-IOB partendo dal contenuto della folder /home/pi/steamware + +#step 1: creo file di log nuovi +rm /var/log/log*.txt +rm /var/log/MapoIOB* +rm /home/pi/steamware/log*.txt + +touch /var/log/logReboot.txt +touch /var/log/logTemp.txt +touch /var/log/MapoIOB.log + +ln -sf /var/log/logReboot.txt /home/pi/steamware/logReboot.txt +ln -sf /var/log/logTemp.txt /home/pi/steamware/logTemp.txt +ln -sf /var/log/MapoIOB.log /home/pi/steamware/logfile.txt + +chown pi:pi /home/pi -R +chmod 666 /var/log/log*.txt +chmod 666 /var/log/MapoIOB.log + +#step 2: copio files in /usr/local/bin +cd /home/pi/steamware +chmod +x *.sh +cp *.sh /usr/local/bin/ + +#step 3: copio files x logrotate... +cd /home/pi/steamware +cp MapoIOB_logrot /etc/logrotate.d/ + +# step 4: copio target systemd in avvio... +cp -f sendRebootIOB /etc/init.d/sendRebootIOB +cp -f sendRebootIOB.service /etc/systemd/system/sendRebootIOB.service +#echo "" +#echo "-----------------------------------------------" +#echo "Completare registrazione servizio avvio: digitare i seguenti comandi" +#echo "systemctl enable sendRebootIOB" +#echo "systemctl daemon-reload" +#echo "systemctl status sendRebootIOB" +#echo "-----------------------------------------------" +#echo "" + +# step 5: copio target MapoIOB in avvio... +cp -f MapoIOB /etc/init.d/MapoIOB +cp -f MapoIOB.service /etc/systemd/system/MapoIOB.service + + +#echo "" +#echo "" +#echo "-----------------------------------------------" +#echo "Infine creare voce crontab che salvi temperatura CPU/GPU ogni 20 minuti..." +#echo "crontab -e" +#echo "*/20 * * * * /usr/local/bin/saveTemp.sh" +#echo "-----------------------------------------------" diff --git a/IOB-PI/vers2.6 12bit/readFile.py b/IOB-PI/vers2.6 12bit/readFile.py new file mode 100644 index 0000000..887118d --- /dev/null +++ b/IOB-PI/vers2.6 12bit/readFile.py @@ -0,0 +1,152 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# readFile v. 0.1 +# - single instance timer +# - invio multiplo x send eventi accodati + +#--------------------------------------------------------------- + +import time + +from datetime import datetime + +import urllib +import ConfigParser +import os, sys + +import logging +import logging.handlers +import Queue + +import argparse +#-------------------------------------------------------------- + +# gestione parser argomenti in input +parser = argparse.ArgumentParser() +parser.add_argument("memFile") +parser.add_argument("logFile") +args = parser.parse_args() + +#definizione variabili BASE +stepQueuePut=25000 +stepQueueGet=250 +NMAXSEND=500000 # limite invio file x fare prove... +idxMacchina = "2003" + +#-------------------------------------------------------------- +# Gestione coda (condivisa) x registrazione eventi ed invio URL +#print "Creazione coda illimitata" +Coda = Queue.Queue(0) + +#--------------------------------------------------------------- +#Funzione di scrittura su coda con try-except + +def accoda(valore): + + try: + Coda.put(valore) + except Queue.Full: + logPro.error( "Queue full" + dtEve + '#' + value + '#' + cont ) + except: + logPro.error( "NETWORK:Errore http-no com rete-timeout" + url ) + + +#-------------------------------------------------------------- +# svuotaCoda x invio dati al server +def svuota_coda(): + + global NMAXSEND + + try: + if not Coda.empty(): + # invio SOLO i primi NMAXSEND eventi... SE minore del num eventi... + if NMAXSEND > Coda.qsize(): + NMAXSEND = Coda.qsize() + + + i = 0 + + with open(args.logFile,"w") as outf: + while i <= NMAXSEND: + if not Coda.empty(): + + # formatto dataOra corrente + dtCurr = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3] + + #prendo primo elemento dalla coda + resp = Coda.get() + + # recupero valori da elemento coda! + dtEve = resp.split("#")[0] + value = resp.split("#")[1] + cnt = resp.split("#")[2] + url = URLBASE + idxMacchina + URLADV1 + value + url = url + '&dtCurr=' + dtCurr + '&dtEve=' + dtEve + '&cnt=' + cnt + # CHIAMO URL + response3 = urllib.urlopen ( url ) + answ3 = response3.read() + + # registro chiamata + risposta + # outf.write(url + " --> " + answ3 + "\n") + + # incremento e controllo se mostrare output + i += 1 + if (i % stepQueueGet) == 0: + print "Inviati %d valori..." % i + + print "Inviati %d valori..." % i + except: + print "Errore in svuotamento coda!" + + +#--------------------------------------------------------------- +# MAIN + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'IOB.cfg' ) + + # NMAXSEND = config.getint ( 'time' , 'NMAXSEND' ) + # idxMacchina = config.get ( 'id' , 'idxMacchina' ) + + + URLBASE = config.get ( 'web' , 'URLBASE' ) + URLADV1 = config.get ( 'web' , 'URLADV1' ) + + LOGFILE = config.get ( 'log' , 'LOGFILE' ) + LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' ) +except: + print "\n\n" + PROGRAM_NAME + ' - Error 4 - in config file ' 'IOB.cfg' + sys.exit(1) + +#--------------------------------------------------------------- + +dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3] +print "Inizio elaborazione: %s" % dtCurr + +# Leggo il file! +i = 0 +with open(args.memFile, 'r') as inf, open(args.logFile,"w") as outf: + data = inf.readlines() + + print "Trovate %d da processare..." % len(data) + +# leggo e metto in QUEUE... + for line in data: + accoda(line) + i += 1 + if (i % stepQueuePut) == 0: + print "Accodati %d valori..." % i + +print "Completata lettura file! %d righe accodate da trasmettere" % Coda.qsize() + +dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3] +print "Inizio invio: %s" % dtCurr + + +# chiamo procedura x svuotare coda... +svuota_coda() + +dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3] +print "Completato invio: %s" % dtCurr \ No newline at end of file diff --git a/IOB-PI/vers2.6 12bit/readParallela.py b/IOB-PI/vers2.6 12bit/readParallela.py new file mode 100644 index 0000000..669253b --- /dev/null +++ b/IOB-PI/vers2.6 12bit/readParallela.py @@ -0,0 +1,796 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# readParallela v. 2.5.2 12 Ingressi +# - single instance timer +# - invio multiplo x send eventi accodati +# - gestione segnali BLINKING +# - gestione INVERSIONE segnali cv 10-VII-2018 +# - gestione FILTRAGGIO segnali brevi cv 23-VII-2018 +# - (2.3) gestione 12 bit cv 14-I-2020 +# - (2.4) fix ingressi e conf apertura parallela + gestione vari bit filtraggio x nuovi ingressi + update conf con 12 parametri bit SEL 15-I-2020 +# - (2.4.8) versione adatta a raspberry PI vecchia generazione (GPIO corto, 8bit) +# - (2.5) Fix (hope) ciclo "wait send to complete", gestione timeout (rety infinito se IO riparte in modo anomalo) +# - (2.5.1) Fix numero versione 18.05.2023 +# - (2.5.2) Fix gestione eccezioni con report dettagliato + +#--------------------------------------------------------------- +# levare locking +# timer semplificata +# GPIO global + + +import time +import sys + + +from datetime import datetime + +import urllib +import ConfigParser +import os, sys + +import logging +import logging.handlers +import threading +import Queue + +from array import * + +#-------------------------------------------------------------- + +# COSTANTI +MSGLEN = 9 +TIMEOUTSERIALE = 10 +MAXRETRY = 10 + +# numero campioni filtraggio segnale ballerino +MAX_COUNTER_BLINK = 10 + +PROGRAM_NAME ="ReadPar IOB-pi v.2.5.2" + +# DA FILE CONF +idxMacchina = "1001" +SAMPLETIME = 0.1 +TIMEOUTSHORT = (SAMPLETIME*20) +TIMEOUTLONG = (SAMPLETIME*600) +SENDURLTIME = 0.08 +NMAXSEND = 5 # numero massimo di invii per singolo ciclo di svuotamento + +# VAR +to_enable = False +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG +to_serial = TIMEOUTSERIALE +to_retry = MAXRETRY +errormsglen = 0 + +# VAR + +out_0 = 24 +out_1 = 26 + +in_0 = 11 +in_1 = 12 +in_2 = 13 +in_3 = 15 +in_4 = 16 +in_5 = 18 +in_6 = 22 +in_7 = 7 +in_8 = 29 +in_9 = 31 +in_10 = 32 +in_11 = 36 + +# contatore: serve x match tra accoda ed invia x possibile controllo a posteriori... ogni volta che accodo incremento di 1, va da 0 a 9999 +cont = '0' + +# variabile stato online/offline della macchina +onLine = '1' + +# variabile stato seinding/waiting x la parte invio URL +sending = '0' + +# variabile stato timer thread busy +timer_busy = False + +# +# array per ingressi filtrati + +i_counters = array ( 'i',[0,0,0,0,0,0,0,0,0,0,0,0]) +B_blinking = array ( 'B',[0,0,0,0,0,0,0,0,0,0,0,0]) +B_previous = array ( 'B',[0,0,0,0,0,0,0,0,0,0,0,0]) +B_input = array ( 'B',[0,0,0,0,0,0,0,0,0,0,0,0]) +B_output = array ( 'B',[0,0,0,0,0,0,0,0,0,0,0,0]) + +B_inverting = array ( 'B',[0,0,0,0,0,0,0,0,0,0,0,0]) + +B_filter = array ( 'B',[0,0,0,0,0,0,0,0,0,0,0,0]) +B_filter_prev = array ( 'B',[0,0,0,0,0,0,0,0,0,0,0,0]) +B_temp = array ( 'B',[0,0,0,0,0,0,0,0,0,0,0,0]) +i_filter_counters = array ( 'i',[0,0,0,0,0,0,0,0,0,0,0,0]) + +#-------------------------------------------------------------- +# Gestione coda (condivisa) x registrazione eventi ed invio URL +#print "Creazione coda illimitata" + +Coda = Queue.Queue(0) + +#queueLock = threading.Lock() + +#--------------------------------------------------------------- +# lettura parallela +# ritorna il byte letto pulito ( due char hex ) + +def readParallelaFiltrata(): + + global in_0 + global in_1 + global in_2 + global in_3 + global in_4 + global in_5 + global in_6 + global in_7 + + global in_8 + global in_9 + global in_10 + global in_11 + + + global GPIO + + current = '' + + + try: + + if GPIO.input(in_0): + B_input[0] = 0 + else: + B_input[0] = 1 + + if GPIO.input(in_1): + B_input[1] = 0 + else: + B_input[1] = 1 + + if GPIO.input(in_2): + B_input[2] = 0 + else: + B_input[2] = 1 + + if GPIO.input(in_3): + B_input[3] = 0 + else: + B_input[3] = 1 + + if GPIO.input(in_4): + B_input[4] = 0 + else: + B_input[4] = 1 + + if GPIO.input(in_5): + B_input[5] = 0 + else: + B_input[5] = 1 + + if GPIO.input(in_6): + B_input[6] = 0 + else: + B_input[6] = 1 + + if GPIO.input(in_7): + B_input[7] = 0 + else: + B_input[7] = 1 + + + if GPIO.input(in_8): + B_input[8] = 0 + else: + B_input[8] = 1 + + if GPIO.input(in_9): + B_input[9] = 0 + else: + B_input[9] = 1 + + if GPIO.input(in_10): + B_input[10] = 0 + else: + B_input[10] = 1 + + if GPIO.input(in_11): + B_input[11] = 0 + else: + B_input[11] = 1 + + + + + + + #ciclo per ogni segnale + for i in xrange(12) : + #print (i) + + # v2.1 gestione inversione bit ingresso + + if ( B_inverting[i] == 1 ) : + if ( B_input[i] == 0 ) : + B_input[i] = 1 + else : + B_input[i] = 0 + + # v2.2 gestione filtro segnali brevi + + if ( B_filter[i] == 1 ) : + + # fronte 0 -> 1 + if ( B_input[i] == 1 ) and ( B_filter_prev [i] == 0 ) : + if ( i_filter_counters[i] == 0 ) : + # vero fronte 0 -> 1 + i_filter_counters[i] = MAX_COUNTER_FILTER + B_temp[i] = 0 # tengo l' ingresso a 0 + #logPro.info("START spike 0->1 on bit " + `i` ) + else : + # fine disturbo breve di uno stato 1 + i_filter_counters[i] = 0 + B_temp[i] = 1 # tengo l' ingresso a 1 + logPro.info("END spike 0->1 on bit " + `i` ) + + # stabile 1 -> 1 + if ( B_input[i] == 1 ) and ( B_filter_prev [i] == 1 ) : + if ( i_filter_counters[i] == 0 ) : + # segnale stabile a 1 + B_temp[i] = 1 # tengo l' ingresso a 1 + else : + # poco dopo il fronte + i_filter_counters[i] = i_filter_counters[i] - 1 + B_temp[i] = 0 # tengo l' ingresso a 0 + + # fronte 1 -> 0 + if ( B_input[i] == 0 ) and ( B_filter_prev [i] == 1 ) : + if ( i_filter_counters[i] == 0 ) : + # vero fronte 1 -> 0 + i_filter_counters[i] = MAX_COUNTER_FILTER + B_temp[i] = 1 # tengo l' ingresso a 1 + #logPro.info("START spike 1->0 on bit " + `i` ) + else : + # fine disturbo breve di uno stato 0 + i_filter_counters[i] = 0 + B_temp[i] = 0 # tengo l' ingresso a 0 + logPro.info("END spike 1->0 on bit " + `i` ) + + # stabile 0 -> 0 + if ( B_input[i] == 0 ) and ( B_filter_prev [i] == 0 ) : + if ( i_filter_counters[i] == 0 ) : + # segnale stabile a 0 + B_temp[i] = 0 # tengo l' ingresso a 0 + else : + # poco dopo il fronte + i_filter_counters[i] = i_filter_counters[i] - 1 + B_temp[i] = 1 # tengo l' ingresso a 1 + + B_filter_prev [i] = B_input[i] + B_input[i] = B_temp[i] + + # fine gestione filtro segnali brevi + + + # se non blinking, copia ingresso + if ( B_blinking[i] == 0 ) : + B_output[i] = B_input[i] + else: + # gestione segnale blinking + # se fronte del segnale + if ( B_previous[i] != B_input[i] ) : + B_previous[i] = B_input[i] + # se fronte di salita + if ( B_input[i] == 1 ) : + # subito uscita = 1 + B_output[i] = 1 + i_counters[i] = MAX_COUNTER_BLINK + #else : + # # loggo che ho rilevato un blink... + # logPro.info("Blink down on bit " + `i`) + else: + # no , segnale eguale a prima + # se input a 0 + if ( B_input[i] == 0 ) : + # E CONTEGGIO IN CORSO + if ( i_counters[i] > 0 ) : + i_counters[i] = i_counters[i] -1 + if ( i_counters[i] == 0 ) : + B_output[i] = 0 + logPro.info("END Blink on bit " + `i` ) + + #Rimettiamo insieme i bit + new_value = 0 + + if ( B_output[0] == 1 ) : + new_value = new_value + 1 + if ( B_output[1] == 1 ) : + new_value = new_value + 2 + if ( B_output[2] == 1 ) : + new_value = new_value + 4 + if ( B_output[3] == 1 ) : + new_value = new_value + 8 + if ( B_output[4] == 1 ) : + new_value = new_value + 16 + if ( B_output[5] == 1 ) : + new_value = new_value + 32 + if ( B_output[6] == 1 ) : + new_value = new_value + 64 + if ( B_output[7] == 1 ) : + new_value = new_value + 128 + + if ( B_output[8] == 1 ) : + new_value = new_value + 256 + if ( B_output[9] == 1 ) : + new_value = new_value + 512 + if ( B_output[10] == 1 ) : + new_value = new_value + 1024 + if ( B_output[11] == 1 ) : + new_value = new_value + 2048 + + + current = hex( new_value ).replace ( "0x" , "" ).upper() + + except Exception as e: + print "Errore in readParallelaFiltrata \n\n" + print str(e) + pass + + return current + +#--------------------------------------------------------------- +#Funzione di scrittura su coda con try-except + +def accoda(): + + try: + dtEve = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3] + Coda.put(dtEve + '#' + value + '#' + cont) + + except Queue.Full: + logPro.error( "Queue full" + `dtEve` + '#' + `value` + '#' + `cont` ) + except Exception as e: + logPro.error( "NETWORK:Errore http-no com rete-timeout" + url ) + logPro.error(str(e)) + +#-------------------------------------------------------------- +# svuotaCoda x invio dati al server +def svuota_coda(): + + global onLine + global sending + global timer_busy + global NMAXSEND + + #print "start timer " + + if ( timer_busy == False ): + timer_busy = True + #print "start timer ok " + + try: + if not Coda.empty(): + #print "coda da svuotare!" + response = urllib.urlopen(URLALIVE) + answ = response.read() + if answ == 'OK': + #print "OK alive" + response2 = urllib.urlopen(URLENABLED + idxMacchina) + answ2 = response2.read() + if answ2 == 'OK': + # aggiorno stato ad online + if onLine == '0': + logPro.info("IOB ONLINE!") + #print("IOB ONLINE") + + onLine = '1' # imposto comunque online + else: + if onLine == '1': + logPro.error("IOB offline") + #print("IOB offline") + + onLine = '0' + else: + if onLine == '1': + logPro.error("Server offline") + #print("Server offline") + + onLine = '0' + + # ora verifico SE si possa inviare (ovvero sia online server e NON ci siano altri send attivi...) + if onLine == '1': + if sending == '0': + #segnalo che sono in sending! + sending = '1' + + # SAM 2016.12.23: modifica x invio FINO A nMaxSend ELEMENTI ad ogni ciclo di svuotamento + i = NMAXSEND + + while i >= 0: + if not Coda.empty(): + + # formatto dataOra corrente + dtCurr = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3] + + #prendo primo elemento dalla coda + resp = Coda.get() + + # recupero valori da elemento coda! + dtEve = resp.split("#")[0] + value = resp.split("#")[1] + cnt = resp.split("#")[2] + url = URLBASE + idxMacchina + URLADV1 + value + url = url + '&dtCurr=' + dtCurr + '&dtEve=' + dtEve + '&cnt=' + cnt + # CHIAMO URL + response3 = urllib.urlopen ( url ) + answ3 = response3.read() + #print(url) + + # log valore inviato! + logSnd.info( value + ' ['+ cnt +']' + ' R:' + answ3 ) + #print "Valore smaltito dalla coda" + + # tolgo 1 al contatore + i -= 1 + + # completato invio, riporto sending a zero! + sending = '0' + else: + if to_retry > 0: + to_retry -= 1 + logPro.info("WAIT active send to complete") + else: + sending = '0' + to_retry = MAXRETRY + logPro.info("END WAIT, reset to_retry var") + + else: + pass + + else: + pass + + except Exception as e: + if onLine == '1': + logPro.error("Server Non raggiungibile") + logPro.error(str(e)) + #print "Non raggiungibile" + + onLine = '0' + + # in ogni caso + + timer_busy = False + #print "end timer ok" + + + #print "end timer " + + +#--------------------------------------------------------------- +# funzione timer thread +#--------------------------------------------------------------- +def do_every (interval, worker_func, iterations = 0): + if iterations != 1: + threading.Timer ( + interval, + do_every, [interval, worker_func, 0 if iterations == 0 else iterations-1] + ).start (); + + worker_func (); + +#--------------------------------------------------------------- +# gestione contatore +#--------------------------------------------------------------- +def contatore(): + + try: + global cont + ctr = int(cont) + ctr +=1 + ctr = ctr % 10000 # round robin 10000 eventi x track + cont = str(ctr) + except Exception as e: + print("errore incremento contatore \n\n") + print(str(e)) + +#--------------------------------------------------------------- +# avvia porta parallela +#--------------------------------------------------------------- +def avviaParallela(): + + global in_0 + global in_1 + global in_2 + global in_3 + global in_4 + global in_5 + global in_6 + global in_7 + global in_8 + global in_9 + global in_10 + global in_11 + + global GPIO + + try: + + GPIO.setmode(GPIO.BOARD) + + GPIO.setwarnings(False) + + #GPIO.setup(out_0, GPIO.OUT) # output 0 + #GPIO.setup(out_1, GPIO.OUT) # output 1 + + GPIO.setup(in_0, GPIO.IN) # input 0 + GPIO.setup(in_1, GPIO.IN) # input 1 + GPIO.setup(in_2, GPIO.IN) # input 2 + GPIO.setup(in_3, GPIO.IN) # input 3 + GPIO.setup(in_4, GPIO.IN) # input 4 + GPIO.setup(in_5, GPIO.IN) # input 5 + GPIO.setup(in_6, GPIO.IN) # input 6 + GPIO.setup(in_7, GPIO.IN) # input 7 + GPIO.setup(in_8, GPIO.IN) # input 8 + GPIO.setup(in_9, GPIO.IN) # input 9 + GPIO.setup(in_10, GPIO.IN) # input 10 + GPIO.setup(in_11, GPIO.IN) # input 11 + + except Exception as e: + print( "\n\n" + PROGRAM_NAME + " - Error 3 on RPi.GPIO ! \n\n") + print str(e) + sys.exit(1) + + + print( "\n\n" + PROGRAM_NAME + " - init ok \n\n") + + +#--------------------------------------------------------------- +#--------------------------------------------------------------- +# MAIN + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'IOB.cfg' ) + + SAMPLETIME = config.getfloat ( 'time' , 'SAMPLETIME' ) + TIMEOUTSHORT = config.getfloat ( 'time' , 'TIMEOUTSHORT' ) + TIMEOUTLONG = config.getfloat ( 'time' , 'TIMEOUTLONG' ) + SENDURLTIME = config.getfloat ( 'time' , 'SENDURLTIME' ) + NMAXSEND = config.getint ( 'time' , 'NMAXSEND' ) + + idxMacchina = config.get ( 'id' , 'idxMacchina' ) + + + URLBASE = config.get ( 'web' , 'URLBASE' ) + URLENABLED = config.get('web' , 'URLENABLED') + URLALIVE = config.get ('web' , 'URLALIVE') + URLADV1 = config.get ( 'web' , 'URLADV1' ) + + LOGFILE = config.get ( 'log' , 'LOGFILE' ) + LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' ) + + B_blinking[0] = config.getint ( 'blink' , 'bit0' ) + B_blinking[1] = config.getint ( 'blink' , 'bit1' ) + B_blinking[2] = config.getint ( 'blink' , 'bit2' ) + B_blinking[3] = config.getint ( 'blink' , 'bit3' ) + B_blinking[4] = config.getint ( 'blink' , 'bit4' ) + B_blinking[5] = config.getint ( 'blink' , 'bit5' ) + B_blinking[6] = config.getint ( 'blink' , 'bit6' ) + B_blinking[7] = config.getint ( 'blink' , 'bit7' ) + B_blinking[8] = config.getint ( 'blink' , 'bit8' ) + B_blinking[9] = config.getint ( 'blink' , 'bit9' ) + B_blinking[10] = config.getint ( 'blink' , 'bit10' ) + B_blinking[11] = config.getint ( 'blink' , 'bit11' ) + + MAX_COUNTER_BLINK = config.getint ( 'blink' , 'MAX_COUNTER_BLINK' ) + + # cv 2.1 se bit = 1 allora inverto segnale in ingresso... + + B_inverting[0] = config.getint ( 'invert' , 'bit0' ) + B_inverting[1] = config.getint ( 'invert' , 'bit1' ) + B_inverting[2] = config.getint ( 'invert' , 'bit2' ) + B_inverting[3] = config.getint ( 'invert' , 'bit3' ) + B_inverting[4] = config.getint ( 'invert' , 'bit4' ) + B_inverting[5] = config.getint ( 'invert' , 'bit5' ) + B_inverting[6] = config.getint ( 'invert' , 'bit6' ) + B_inverting[7] = config.getint ( 'invert' , 'bit7' ) + B_inverting[8] = config.getint ( 'invert' , 'bit8' ) + B_inverting[9] = config.getint ( 'invert' , 'bit9' ) + B_inverting[10] = config.getint ( 'invert' , 'bit10' ) + B_inverting[11] = config.getint ( 'invert' , 'bit11' ) + + # cv 2.2 se bit = 1 allora filtro segnali brevi ... + + B_filter[0] = config.getint ( 'filter' , 'bit0' ) + B_filter[1] = config.getint ( 'filter' , 'bit1' ) + B_filter[2] = config.getint ( 'filter' , 'bit2' ) + B_filter[3] = config.getint ( 'filter' , 'bit3' ) + B_filter[4] = config.getint ( 'filter' , 'bit4' ) + B_filter[5] = config.getint ( 'filter' , 'bit5' ) + B_filter[6] = config.getint ( 'filter' , 'bit6' ) + B_filter[7] = config.getint ( 'filter' , 'bit7' ) + B_filter[8] = config.getint ( 'filter' , 'bit8' ) + B_filter[9] = config.getint ( 'filter' , 'bit9' ) + B_filter[10] = config.getint ( 'filter' , 'bit10' ) + B_filter[11] = config.getint ( 'filter' , 'bit11' ) + + MAX_COUNTER_FILTER = config.getint ( 'filter' , 'MAX_COUNTER_FILTER' ) + + +except Exception as e: + print "\n\n" + PROGRAM_NAME + ' - Error 4 - in config file ' 'IOB.cfg' + print str(e) + sys.exit(1) + +#-------------------------------------------- +# oggetto Logger +#-------------------------------------------- +try: + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(name)-8s %(levelname)-8s %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + filename=LOGFILE, + filemode='a' + ) + + # aggiungo 2 logger specifici x queue e send... + logQue = logging.getLogger('queue') + logSnd = logging.getLogger('sendUrl') + logPro = logging.getLogger('program') + +except Exception as e: + # manda mail o simili - FARE!!! + print "LOG: Impossibile creare file log con nome" + print (LOGFILE) + print "\n\n" + print str(e) +#-------------------------------------------- + + +print "\n\n" + PROGRAM_NAME + "\n\n" + +global startstatus +startstatus = 1 + +if startstatus == 1: + logPro.info("Avvio Programma" + PROGRAM_NAME) + +## Verifica l'OS e di conseguenza carica il file relativo con metodo di lockfile appropriato + check singola istanza +if os.name == 'posix': + import unix +else: + import win + +logPro.info( "Start " + PROGRAM_NAME ) + + +# lettura file configurazione + +# [id] +# idxMacchina = 2001 +# [time] +# SAMPLETIME = 0.1 +# TIMEOUTSHORT = 200 +# TIMEOUTLONG = 6000 + + +print ( ' idxMacchina = %s' % ( idxMacchina ) ) +print ( ' SAMPLETIME = %4.2f' % ( SAMPLETIME ) ) +print ( ' TIMEOUTSHORT = %4.2f' % ( TIMEOUTSHORT ) ) +print ( ' TIMEOUTLONG = %4.2f' % ( TIMEOUTLONG ) ) +print ( ' SENDURLTIME = %4.2f' % ( SENDURLTIME ) ) +print ( ' URLBASE = %s' % ( URLBASE ) ) +print ( ' URLADV1 = %s' % ( URLADV1 ) ) +print ( ' LOGFILE = %s' % ( LOGFILE ) ) +print ( ' LOGLEVEL = %s' % ( LOGLEVEL ) ) + +# -sys.stdout.write ( 'idxMacchina ?' + idxMacchina + '\n') + +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG + + +#-------------------------------------------------------------- +# apertura parallela + +try: + import RPi.GPIO as GPIO +except RuntimeError: + print( "\n\n" + PROGRAM_NAME + " - Error 1 - you need superuser privileges") +except Exception as e: + print( "\n\n" + PROGRAM_NAME + " - Error 2 - you need superuser privileges. USE 'sudo' to run your script\n\n") + print str(e) + sys.exit(1) + + +avviaParallela() + + +#-------------------------------------------------------------- +# MARCO: qui inserire avvio thread di "svuotaCoda" + +# avviaSvuotaCoda +#print "Avvia svuota coda" + +do_every ( SENDURLTIME , svuota_coda ); + +#--------------------------------------------------------------- +# ciclo forever and ever + +old = '' + +#print "Avvio ciclo" +logPro.info("Avvio loop principale") +while 1: + + try: + time.sleep (SAMPLETIME) + except Exception as e: + logPro.info("First_SLEEP: errore attesa sampletime") + logPro.error(str(e)) + + # lettura dati da IOB + value = readParallelaFiltrata() + + if ( value != '' ) : + if value != old : + #loggo e invio dati + try: + logQue.info( value + ' ['+ cont +']') + errormsglen = 0 + accoda() + contatore() + except Exception as e: + logPro.error("URLBROWSER: errore registrazione valore e accoda") + logPro.error(str(e)) + pass + #enable e reset timer + to_enable = True + to_short = TIMEOUTSHORT + to_long = TIMEOUTLONG + + old = value + + + # gestione timeout breve + if ( to_enable ) : + to_short = to_short - SAMPLETIME + if to_short <= 0: + #loggo e invio dati + try: + logQue.info( '>' + value + ' ['+ cont +']') + errormsglen = 0 + accoda() + contatore() + except Exception as e: + logPro.error("URLBROWSER: errore registrazione valore e accoda TO_short") + logPro.error(str(e)) + pass + to_short = TIMEOUTSHORT + to_enable = False # dopo un colpo il timer breve viene disabilitato + to_long = TIMEOUTLONG + + # gestione timeout lungo + to_long = to_long - SAMPLETIME + if to_long <= 0: + #loggo e invio dati + try: + logQue.info( '>>' + value + ' ['+ cont +']') + errormsglen = 0 + accoda() + contatore() + except Exception as e: + logPro.error("URLBROWSER: errore registrazione valore e accoda TO_long") + logPro.error(str(e)) + pass + to_long = TIMEOUTLONG diff --git a/IOB-PI/readParallela_12.py b/IOB-PI/vers2.6 12bit/readParallela_12.py similarity index 100% rename from IOB-PI/readParallela_12.py rename to IOB-PI/vers2.6 12bit/readParallela_12.py diff --git a/IOB-PI/vers2.6 12bit/readSeriale.py b/IOB-PI/vers2.6 12bit/readSeriale.py new file mode 100644 index 0000000..3c00644 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/readSeriale.py @@ -0,0 +1,363 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +#--------------------------------------------------------------- + +import serial +import time +import sys +import datetime +import urllib +import ConfigParser +import os, sys + +#--------------------------------------------------------------- + +# COSTANTI +MSGLEN = 9 +TIMEOUTSERIALE = 10 +MAXRETRY = 3 + +# DA FILE CONF +idxMacchina = "2001" +SAMPLETIME = 0.1 +TIMEOUTSHORT = (SAMPLETIME*20) +TIMEOUTLONG = (SAMPLETIME*600) + +# VAR +to_enable = False +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG +to_serial = TIMEOUTSERIALE +to_retry = MAXRETRY +errormsglen = 0 + +#--------------------------------------------------------------- +# classe logger + +class Logger: + def __init__(self, filename): + try: + self.filename = filename + except: + logga("LOGGER: errore try su self.filename") + sys.exit(1) + def __call__(self, string): + try: + file = open(self.filename, 'a') + file.write('[' + time.strftime("%Y-%m-%d %H:%M:%S") + '] ') + file.write(string + '\n') + file.close() + except: + logga("LOGGER: errore try su scrittura") + sys.exit(1) + +#--------------------------------------------------------------- +# lettura buffer seriale e pulizia caratteri non stampabili +# ritorna '' se non c'è un messaggio buono o il messaggio pulito ( due bytes hex ) +# il messaggio ha il formato xxi00 00xxx + +def readSeriale(): + + global to_serial + global to_retry + global errormsglen + + ret = '' + current = '' + i = 0 + + # ritorna '' se non ci sono abbastanza caratteri + try: + if ser.inWaiting() < MSGLEN : +# +# to_serial = to_serial - 1 # se non mi risponde, faccio un ' altra richiesta.... +# if to_serial <= 0: +# try: +# requestData () +# except: +# logga("SERIALE: errore su requestData") +# sys.exit(1) +# to_serial = TIMEOUTSERIALE # ripristino timer +# to_retry = to_retry - 1 # contatore retry +# if to_retry <= 0: +# logga ( 'IOB not responding' ) +# return ret + logga("SERIALE: errore msglen < 9 char - Errore no. " + str(errormsglen)) + errormsglen = errormsglen +1 + avviaSeriale() + time.sleep(.2) + if errormsglen > 30: + sys.exit(1) + except: + if startstatus == 0: + logga ("Porta SERIALE non disponibile - ser.inWaiting error - exit... - Errore no. " + str(errormsglen)) + errormsglen = errormsglen +1 + avviaSeriale() + time.sleep(.2) + if errormsglen > 30: + sys.exit(1) + + # finchè c'è robba .. leggi e tieni i buoni + to_serial = TIMEOUTSERIALE + to_retry = MAXRETRY + try: + while ser.inWaiting() > 0 : + try: + c = ser.read(1) + except: + logga("SERIALE: errore su try ser.read") + sys.exit(1) + # filtra caratteri non stampabili + if c > ' ' : + current += c + #sys.stdout.write(current + '<<<<\n') + # ora il messaggio ha il formato xxxxxi00 00xxx : cerco la 'i' iniziale + try: + while i < len(current) and current[i] != 'i': + i = i + 1 + except: + logga("SERIALE: errore su ricerca i iniziale") + sys.exit(1) + # se non ho trovato la 'i' restituisco '' + if i == len(current)-1: + return ret + else: + current = current[i+1:i+3] + # richiesta dati ad IOB + requestData() + #sys.stdout.write ( current + '\n') + except: + if startstatus == 0: + logga ('Porta SERIALE non disponibile - ser.inWaiting e filtraggio error...exit') + sys.exit(1) + return current +#--------------------------------------------------------------- +# richiesta dati ad IOB : scrittura su seriale + +def requestData (): + try : + ser.write ("$i" + '\r\n') + ser.flush() + except : + if startstatus == 0: + logga ( "SERIAL: Errore di scrittura/flush") + + +#--------------------------------------------------------------- +#Funzione di scrittura su url con try-except + +def chiamaUrl(): + try: + url = URLBASE + idxMacchina + URLADV1 + value + urllib.urlopen ( url ) + except: + logga ( "NETWORK:Errore http-no com rete-timeout" + url ) + + +#--------------------------------------------------------------- +# Funzione che verifica possibilità di creare log e include testo corrente + +def logga(message) : + try: + log(message) + except : + pass + +#--------------------------------------------------------------- + + +def avviaSeriale(): + global ser + + try: + ser = serial.Serial( + port = comm_port , + baudrate = 9600 , + parity = serial.PARITY_NONE , + stopbits = serial.STOPBITS_ONE , + bytesize = serial.EIGHTBITS + ) + startstatus = 0 + except serial.serialutil.SerialException , e : + try: + if startstatus == 0: + logga ( "SERIAL:Errore apertura seriale - " + comm_port) + except: + pass + sys.stdout.write ( '\nErrore apertura seriale\n\n%s\n\n' % e ) + if errormsglen > 30: + sys.exit (1) + +#--------------------------------------------------------------- +#--------------------------------------------------------------- +# MAIN + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'readSeriale.cfg' ) + + SAMPLETIME = config.getfloat ( 'time' , 'SAMPLETIME' ) + TIMEOUTSHORT = config.getfloat ( 'time' , 'TIMEOUTSHORT' ) + TIMEOUTLONG = config.getfloat ( 'time' , 'TIMEOUTLONG' ) + + idxMacchina = config.get ( 'id' , 'idxMacchina' ) + comm_port = config.get ( 'comm' , 'port' ) + + URLBASE = config.get ( 'web' , 'URLBASE' ) + URLADV1 = config.get ( 'web' , 'URLADV1' ) + + LOGFILE = config.get ( 'log' , 'LOGFILE' ) + LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' ) +except: + sys.exit(1) + +# oggetto Logger +try: + log = Logger(LOGFILE) +except: + # manda mail o simili - FARE!!! + print "LOG: Impossibile creare file log con nome " + print (LOGFILE) + +print '\n\n Read seriale IOB v.0.2 !!!!\n' + +global startstatus +startstatus = 1 + +if startstatus == 1: + logga("Avvio Programma") + +# Verifica l'OS e di conseguenza carica il file relativo con metodo di lockfile appropriato + check singola istanza +if os.name == 'posix': + import unix +else: + import win + +logga ( "Start Read seriale IOB v.0.2") + + +# lettura file configurazione + +# [comm] +# port = /dev/ttyS0 +# [id] +# idxMacchina = 2001 +# [time] +# SAMPLETIME = 0.1 +# TIMEOUTSHORT = 200 +# TIMEOUTLONG = 6000 + +print ( ' comm_port = %s' % ( comm_port ) ) +print ( ' idxMacchina = %s' % ( idxMacchina ) ) +print ( ' SAMPLETIME = %4.2f' % ( SAMPLETIME ) ) +print ( ' TIMEOUTSHORT = %4.2f' % ( TIMEOUTSHORT ) ) +print ( ' TIMEOUTLONG = %4.2f' % ( TIMEOUTLONG ) ) +print ( ' URLBASE = %s' % ( URLBASE ) ) +print ( ' URLADV1 = %s' % ( URLADV1 ) ) +print ( ' LOGFILE = %s' % ( LOGFILE ) ) +print ( ' LOGLEVEL = %s' % ( LOGLEVEL ) ) + +# -sys.stdout.write ( 'idxMacchina ?' + idxMacchina + '\n') + +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG + + + +#-------------------------------------------------------------- + + +#--------------------------------------------------------------- +# apertura seriale + +avviaSeriale() + +#try: +# ser = serial.Serial( +# port = comm_port , +# baudrate = 9600 , +# parity = serial.PARITY_NONE , +# stopbits = serial.STOPBITS_ONE , +# bytesize = serial.EIGHTBITS +# ) +# print "Initialized!" +#except serial.serialutil.SerialException , e : +# try: +# logga ( "SERIAL:Errore apertura seriale - " + comm_port) +# except: +# pass +# sys.stdout.write ( '\nErrore apertura seriale\n\n%s\n\n' % e ) +# sys.exit (1) + +#--------------------------------------------------------------- +# ciclo forever and ever + +old = '' + +# richiesta dati ad IOB +try: + requestData() +except: + logga("SERIALE: errore sul try di requestData") + sys.exit(1) + + +while 1: + try: + time.sleep (SAMPLETIME) + except: + logga("SERIALE_SLEEP: errore attesa sampletime") + # lettura dati da IOB + try: + value = readSeriale() + except: + if startstatus == 0: + logga("errore PRIMA LETTURA SERIALE") + sys.exit(1) + if ( value != '' ) : + if value != old : + #loggo e invio dati + try: + logga ( value ) + errormsglen = 0 + chiamaUrl() + except: + logga("URLBROWSER: errore registrazione valore e chiamaUrl") + pass + #enable e reset timer + to_enable = True + to_short = TIMEOUTSHORT + to_long = TIMEOUTLONG + + old = value + + + # gestione timeout breve + if ( to_enable ) : + to_short = to_short - SAMPLETIME + if to_short <= 0: + #loggo e invio dati + try: + logga ( '>' + value ) + errormsglen = 0 + chiamaUrl() + except: + pass + to_short = TIMEOUTSHORT + to_enable = False # dopo un colpo il timer breve viene disabilitato + to_long = TIMEOUTLONG + + # gestione timeout lungo + to_long = to_long - SAMPLETIME + if to_long <= 0: + #loggo e invio dati + try: + logga ( '>>' + value ) + errormsglen = 0 + chiamaUrl() + except: + pass + to_long = TIMEOUTLONG + + diff --git a/IOB-PI/vers2.6 12bit/saveTemp.sh b/IOB-PI/vers2.6 12bit/saveTemp.sh new file mode 100644 index 0000000..a2cd2be --- /dev/null +++ b/IOB-PI/vers2.6 12bit/saveTemp.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +#salva la temperatura CPU e GPU su chiamata... + +# imposto logfile... +logFile="/var/log/logTemp.txt" + +cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp) +cpuTemp1=$(($cpuTemp0/1000)) +cpuTemp2=$(($cpuTemp0/100)) +cpuTempM=$(($cpuTemp2 % $cpuTemp1)) + +gpuTemp=`vcgencmd measure_temp` + +loadAvg=`cat /proc/loadavg` + +echo "$(date) | CPU: temp=$cpuTemp1.$cpuTempM ºC | GPU: $gpuTemp | LoadAvg: $loadAvg" >> $logFile diff --git a/IOB-PI/vers2.6 12bit/sendReboot.py b/IOB-PI/vers2.6 12bit/sendReboot.py new file mode 100644 index 0000000..7ca636d --- /dev/null +++ b/IOB-PI/vers2.6 12bit/sendReboot.py @@ -0,0 +1,135 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# sendReboot v. 1.8 +# - (2.5.2) Fix gestione eccezioni con report dettagliato +#--------------------------------------------------------------- + + +import time +import sys + + +from datetime import datetime + +import urllib +import ConfigParser +import os, sys + +import logging + +import time + +#--------------------------------------------------------------- + +# COSTANTI +SR_PROG_NAME = "SendReboot IOB-pi v.2.5.2" + +# DA FILE CONF +idxMacchina = "99" + +# registro se ho fatto chiamata +global numTry +numTry = 1 + + +#--------------------------------------------------------------- +#Funzione di scrittura su url con try-except +#--------------------------------------------------------------- + +def chiamaUrl(numTry): + + try: + urllib.urlopen ( url ) + numTry = numTry + 10 + + except Exception as e: + print("Errore in chiamaUrl") + print(str(e)) + logging.info ( str(e) ) + + print("Url chiamato: " , url) + return numTry + + +#--------------------------------------------------------------- +# Funzione di recupero mac address per poterlo inviare a MPIO +#--------------------------------------------------------------- +def getMAC(interface): + # Return the MAC address of interface + try: + str = open('/sys/class/net/' + interface + '/address').read() + except: + str = "00:00:00:00:00:00" + return str[0:17] + +#--------------------------------------------------------------- +# MAIN +#--------------------------------------------------------------- + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'IOB.cfg' ) + + idxMacchina = config.get ( 'id' , 'idxMacchina' ) + + + URLREBO = config.get ( 'web' , 'URLREBO' ) + + LOGFILE = config.get ( 'log' , 'LOGREBO' ) +except Exception as e: + print("\n\n" + SR_PROG_NAME + ' - Error 4 - in config file ' 'IOB.cfg') + print(str(e)) + sys.exit(1) + + +#-------------------------------------------- +# oggetto Logger +#-------------------------------------------- +try: +# log = Logger(LOGFILE) + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(name)-8s %(levelname)-8s %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + filename=LOGFILE, + filemode='a') + +except Exception as e: + # manda mail o simili - FARE!!! + print("LOG: Impossibile creare file log con nome ") + print(LOGFILE) + print(str(e)) +#-------------------------------------------- + + +print("\n\n" + SR_PROG_NAME + "\n\n") + +global startstatus +startstatus = 1 + +if startstatus == 1: + logging.info("Avvio Programma " + SR_PROG_NAME) + + +# lettura file configurazione +print ( ' idxMacchina = %s' % ( idxMacchina ) ) +print ( ' URLREBO = %s' % ( URLREBO ) ) +print ( ' LOGFILE = %s' % ( LOGFILE ) ) + +# lettura mac address +myMac = getMAC('eth0') +print ( ' MAC Address = %s' % ( myMac ) ) + +# configuro URL da inviare +url = URLREBO + idxMacchina + "&mac=" + myMac + +# modifica: cerco se ho inviato segnale altrimenti ritento invio... +while (numTry < 11): + logging.info("Tentativo invio URL: $numTry" ) + numTry = chiamaUrl(numTry) + time.sleep(3) + numTry = numTry + 1 + + +# registro che ho inviato! +logging.info("Inviato segnale di reboot!: " + url ) diff --git a/IOB-PI/vers2.6 12bit/sendRebootIOB b/IOB-PI/vers2.6 12bit/sendRebootIOB new file mode 100644 index 0000000..191bfff --- /dev/null +++ b/IOB-PI/vers2.6 12bit/sendRebootIOB @@ -0,0 +1,33 @@ +#!/bin/sh - +# +### BEGIN INIT INFO +# Provides: sendReboot +# Required-Start: $network $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Steamware's IOB reboot signal +# Description: Steamware's sendReboot segnalazione reboot dispositivo +### END INIT INFO + +#! /bin/sh +# /etc/init.d/sendReboot + + + +export HOME +case "$1" in + start) + cd /home/pi/steamware + echo "Starting sendReboot" + /usr/bin/python ./sendReboot.py 2>&1 & + echo "Verifica Rete e file IOB" + /usr/local/bin/setIobConf.sh + ;; + *) + echo "Usage: /etc/init.d/sendReboot {start}" + exit 1 + ;; +esac +exit 0 + diff --git a/IOB-PI/vers2.6 12bit/sendRebootIOB.service b/IOB-PI/vers2.6 12bit/sendRebootIOB.service new file mode 100644 index 0000000..48e3690 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/sendRebootIOB.service @@ -0,0 +1,22 @@ +[Unit] +SourcePath=/etc/init.d/sendRebootIOB +Description=LSB: Steamware's IOB reboot signal +Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target +Wants=network-online.target +After=network.target network-online.target auditd.service +Conflicts=shutdown.target + +[Service] +Type=forking +Restart=no +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=yes +SysVStartPriority=2 +ExecStart=/etc/init.d/sendRebootIOB start +ExecStop=/etc/init.d/sendRebootIOB stop + +[Install] +WantedBy=multi-user.target diff --git a/IOB-PI/vers2.6 12bit/setIobConf.sh b/IOB-PI/vers2.6 12bit/setIobConf.sh new file mode 100644 index 0000000..30b4781 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/setIobConf.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# verifico se sia rete donati o rete steamware o offline... +netStatus=`cat /sys/class/net/eth0/operstate` +iaddr=`ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1` + +cd /home/pi/steamware + +if [[ $netStatus != "up" ]] +then + echo "Siamo Offline, pagina demo!" +elif [[ $iaddr == "10.74.82"* ]] +then + cp IOB.cfg.steamware IOB.cfg -f + echo "Siamo in Steamware!" +elif [[ $iaddr == "192.168.51"* ]] +then + cp IOB.cfg.donati IOB.cfg -f + echo "Siamo a Passirano!" +else + echo "Siamo altrove, pagina demo!" +fi + +echo "$iaddr" + +chown pi:pi * \ No newline at end of file diff --git a/IOB-PI/vers2.6 12bit/unix.py b/IOB-PI/vers2.6 12bit/unix.py new file mode 100644 index 0000000..12fb3dc --- /dev/null +++ b/IOB-PI/vers2.6 12bit/unix.py @@ -0,0 +1,31 @@ +import fcntl +import os +import logging + +#--------------------------------------------------------------- +# meccanismo di file lock per evitare multiple instances +# The function will try to lock the file specified , if it success, return True, else return False. +# The nice thing is that the lock will be dropped when the program terminates. +# >>>Use : +# if not lockFile(".lock.pod"): +# sys.exit(0) + +def lockFile ( lockfile ) : + + fd = os.open ( lockfile , os.O_CREAT | os.O_TRUNC | os.O_WRONLY ) + try: + # Request exclusive (EX) non-blocking (NB) advisory lock. + fcntl.lockf ( fd , fcntl.LOCK_EX | fcntl.LOCK_NB ) + except IOError: + return False + + return True + +if not lockFile ( ".lockfile" ) : + print '\n noi non siamo soli ...\n' + logging.error( "LOCK: Piu istanze aperte") + #sys.exit ( 0 ) + +#- print '\n running alone ...\n' + + diff --git a/IOB-PI/vers2.6 12bit/unix.pyc b/IOB-PI/vers2.6 12bit/unix.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f528212e734a67eb0c5153f80c50aace6d1f362a GIT binary patch literal 669 zcma)3%Wl&^6g_urw~d>yU+>A9OYr`N%@ph^{s}cOyT^nX-Q@*l0+qlI zZU`U)Q~_=XCPx+G-H{Yng{UHzqsEV#q&qxT{o$3*iJ_y5*oJI|Szv(`;rbsCJ`6B$ z*${&pf$xN?1K0?w9bA(KyWa2lGMzS$5!wzeVzeh9A{%3JX7@2k9bcYy9f_mW#)fX& z$j0t67@rS|(c9@Qo)#zh(C+#CX)(@^KQSk;m^ZfesMhm~g>OC{4?mob&K__+@c8|B z)V8|y-G^mur01KqTbVk3Kip4Iwe&YyR4M1-oq5Kn|3$B5f1~=w%5wd+Y-NAjsLO0~ zb$|Gf5BIp$I9(9WDG&$Lqez$z$JyO{^OU1FX|!T%5~IqsPK>Tql4V(Jo^aL4c#(Wm z+e8^#Hs54YZe(j^>U0<0F@Tp=>*Z24%i@tsxRP{AA8!BO5?-!#wXNkV_cmTam-vf2 I`(29YFVCEWI{*Lx literal 0 HcmV?d00001 diff --git a/IOB-PI/vers2.6 12bit/update-RPI-IOB.sh b/IOB-PI/vers2.6 12bit/update-RPI-IOB.sh new file mode 100644 index 0000000..d521931 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/update-RPI-IOB.sh @@ -0,0 +1,54 @@ +#|/bin/bash + +#installa il necessario per RPI-3-IOB partendo dal contenuto della folder /home/pi/steamware + +#step 1: creo file di log nuovi +rm /var/log/log*.txt +rm /var/log/MapoIOB* +rm /home/pi/steamware/log*.txt + +touch /var/log/logReboot.txt +touch /var/log/logTemp.txt +touch /var/log/MapoIOB.log + +ln -sf /var/log/logReboot.txt /home/pi/steamware/logReboot.txt +ln -sf /var/log/logTemp.txt /home/pi/steamware/logTemp.txt +ln -sf /var/log/MapoIOB.log /home/pi/steamware/logfile.txt + +chown pi:pi /home/pi -R +chmod 666 /var/log/log*.txt +chmod 666 /var/log/MapoIOB.log + +#step 2: copio files in /usr/local/bin +cd /home/pi/steamware +chmod +x *.sh +cp *.sh /usr/local/bin/ + +#step 3: copio files x logrotate... +cd /home/pi/steamware +cp MapoIOB_logrot /etc/logrotate.d/ + +# step 4: copio target systemd in avvio... +cp -f sendRebootIOB /etc/init.d/sendRebootIOB +cp -f sendRebootIOB.service /etc/systemd/system/sendRebootIOB.service +#echo "" +#echo "-----------------------------------------------" +#echo "Completare registrazione servizio avvio: digitare i seguenti comandi" +#echo "systemctl enable sendRebootIOB" +#echo "systemctl daemon-reload" +#echo "systemctl status sendRebootIOB" +#echo "-----------------------------------------------" +#echo "" + +# step 5: copio target MapoIOB in avvio... +cp -f MapoIOB /etc/init.d/MapoIOB +cp -f MapoIOB.service /etc/systemd/system/MapoIOB.service + + +#echo "" +#echo "" +#echo "-----------------------------------------------" +#echo "Infine creare voce crontab che salvi temperatura CPU/GPU ogni 20 minuti..." +#echo "crontab -e" +#echo "*/20 * * * * /usr/local/bin/saveTemp.sh" +#echo "-----------------------------------------------" diff --git a/IOB-PI/vers2.6 12bit/win.py b/IOB-PI/vers2.6 12bit/win.py new file mode 100644 index 0000000..f679f60 --- /dev/null +++ b/IOB-PI/vers2.6 12bit/win.py @@ -0,0 +1,32 @@ +import win32api +print " Running on WINDOWS\n" +import os +#--------------------------------------------------------------- +# meccanismo di file lock per evitare multiple instances +# The function will try to lock the file specified , if it success, return True, else return False. +# The nice thing is that the lock will be dropped when the program terminates. +# >>>Use : +# if not lockFile(".lock.pod"): +# sys.exit(0) + +def lockFile ( lockfile ) : + try: + fd = os.open ( lockfile , os.O_CREAT | os.O_TRUNC | os.O_WRONLY ) + except: + logga("Errore nel file WIN.PY per FD") + try: + # Request exclusive (EX) non-blocking (NB) advisory lock. + #fcntl.lockf ( fd , fcntl.LOCK_EX | fcntl.LOCK_NB ) + print " Dummy Method! Completa Lockfile\n" + except IOError: + return False + + return True +try: + if not lockFile ( ".lockfile" ) : + print '\n noi non siamo soli ...\n' + logga ( "LOCK: Piu istanze aperte") + sys.exit ( 0 ) +except: + logga("if not lockfile NON RIUSCITO in file WIN.PY") + sys.exit(1) diff --git a/IOB-PI/vers2.6 8bit/IOB.cfg b/IOB-PI/vers2.6 8bit/IOB.cfg new file mode 100644 index 0000000..248eb83 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/IOB.cfg @@ -0,0 +1,56 @@ +[id] +idxMacchina = 0001 + +[web] +URLBASE = http://10.74.82.218/MP/IO/IOB/input/ +URLALIVE = http://10.74.82.218/MP/IO/IOB +URLENABLED = http://10.74.82.218/MP/IO/IOB/enabled/ +URLADV1 = ?valore= +URLREBO = http://10.74.82.218/MP/IO/sendReboot.aspx?idxMacchina= + +[time] +SAMPLETIME = 0.05 +TIMEOUTSHORT = 0.30 +TIMEOUTLONG = 50 +SENDURLTIME = 0.15 +NMAXSEND = 5 + +[log] +LOGLEVEL = 10 +LOGFILE = logfile.txt +LOGREBO = logReboot.txt + +[comm] +port = /dev/ttyAMA0 + +[blink] +MAX_COUNTER_BLINK = 30 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 0 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 + +[invert] +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 0 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 + +[filter] +MAX_COUNTER_FILTER = 8 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 0 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 diff --git a/IOB-PI/vers2.6 8bit/IOB.cfg.donati b/IOB-PI/vers2.6 8bit/IOB.cfg.donati new file mode 100644 index 0000000..29c3d61 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/IOB.cfg.donati @@ -0,0 +1,35 @@ +[id] +idxMacchina = 2007 + +[web] +URLBASE = http://192.168.51.77/MP/IO/IOB/input/ +URLALIVE = http://192.168.51.77/MP/IO/IOB +URLENABLED = http://192.168.51.77/MP/IO/IOB/enabled/ +URLADV1 = ?valore= +URLREBO = http://192.168.51.77/MP/IO/sendReboot.aspx?idxMacchina= + +[time] +SAMPLETIME = 0.05 +TIMEOUTSHORT = 0.30 +TIMEOUTLONG = 50 +SENDURLTIME = 0.15 +NMAXSEND = 5 + +[log] +LOGLEVEL = 10 +LOGFILE = logfile.txt +LOGREBO = logReboot.txt + +[comm] +port = /dev/ttyAMA0 + +[blink] +MAX_COUNTER_BLINK = 30 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 1 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 diff --git a/IOB-PI/vers2.6 8bit/IOB.cfg.steamware b/IOB-PI/vers2.6 8bit/IOB.cfg.steamware new file mode 100644 index 0000000..920043f --- /dev/null +++ b/IOB-PI/vers2.6 8bit/IOB.cfg.steamware @@ -0,0 +1,35 @@ +[id] +idxMacchina = 1005 + +[web] +URLBASE = http://10.74.82.218/MP/IO/IOB/input/ +URLALIVE = http://10.74.82.218/MP/IO/IOB +URLENABLED = http://10.74.82.218/MP/IO/IOB/enabled/ +URLADV1 = ?valore= +URLREBO = http://10.74.82.218/MPIO/sendReboot.aspx?idxMacchina= + +[time] +SAMPLETIME = 0.05 +TIMEOUTSHORT = 0.30 +TIMEOUTLONG = 50 +SENDURLTIME = 0.15 +NMAXSEND = 5 + +[log] +LOGLEVEL = 10 +LOGFILE = logfile.txt +LOGREBO = logReboot.txt + +[comm] +port = /dev/ttyAMA0 + +[blink] +MAX_COUNTER_BLINK = 30 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 1 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 diff --git a/IOB-PI/vers2.6 8bit/MapoIOB b/IOB-PI/vers2.6 8bit/MapoIOB new file mode 100644 index 0000000..1d8f821 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/MapoIOB @@ -0,0 +1,41 @@ +#! /bin/bash +### BEGIN INIT INFO +# Provides: MapoIOB: script Steamware per avvio driver IOB +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Steamware's MapoIOB driver +# Description: Steamware's MapoIOB driver, versione lettura porta parallela +### END INIT INFO + +# /etc/init.d/MapoIOB + +export HOME +case "$1" in + start) + echo "Starting readParallela" + cd /home/pi/steamware + /usr/bin/python ./readParallela.py 2>&1 & + ;; + stop) + echo "Stopping readParallela" + RS_PID=`ps auxwww | grep readParallela.py | head -1 | awk '{print $2}'` + kill -9 $RS_PID + cd /home/pi/steamware + rm .lockfile + ;; + restart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + $0 stop + killall python + $0 start + ;; + *) + echo "Usage: /etc/init.d/MapoIOB {start|stop|restart}" + exit 1 + ;; +esac +exit 0 + diff --git a/IOB-PI/vers2.6 8bit/MapoIOB.service b/IOB-PI/vers2.6 8bit/MapoIOB.service new file mode 100644 index 0000000..7803ccc --- /dev/null +++ b/IOB-PI/vers2.6 8bit/MapoIOB.service @@ -0,0 +1,24 @@ +[Unit] +SourcePath=/etc/init.d/MapoIOB +Description=LSB: Steamware's MapoIOB driver +Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target +Wants=network-online.target +After=network.target network-online.target auditd.service +Conflicts=shutdown.target + +[Service] +Type=forking +Restart=on-failure +RestartSec=5 +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=yes +SysVStartPriority=1 +ExecStartPre=/bin/sleep 5 +ExecStart=/etc/init.d/MapoIOB start +ExecStop=/etc/init.d/MapoIOB stop + +[Install] +WantedBy=multi-user.target diff --git a/IOB-PI/vers2.6 8bit/MapoIOB_logrot b/IOB-PI/vers2.6 8bit/MapoIOB_logrot new file mode 100644 index 0000000..13410b9 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/MapoIOB_logrot @@ -0,0 +1,28 @@ +/var/log/MapoIOB.log { + size 8M + copytruncate + create 700 pi pi + dateext + rotate 100 + compress + maxage 366 + missingok +} +/var/log/logReboot.txt { + size 1M + copytruncate + create 700 pi pi + dateext + rotate 30 + compress + missingok +} +/var/log/logTemp.txt { + size 1M + copytruncate + create 700 pi pi + dateext + rotate 30 + compress + missingok +} diff --git a/IOB-PI/vers2.6 8bit/checkAlive.sh b/IOB-PI/vers2.6 8bit/checkAlive.sh new file mode 100644 index 0000000..aace73d --- /dev/null +++ b/IOB-PI/vers2.6 8bit/checkAlive.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# controlla se il logfile è correntemente scritto (quindi MapoIOB è alive) altrimenti riavvia! + +DATE=`date +%Y-%m-%d` +cd /var/log +if [ -f MapoIOB.log ] + then + # controllo SE sia stato acceduto da meno di 2 minuti (=alive da log...) + trovato=`find . -name 'MapoIOB*' -cmin -1` + if [[ $trovato != './MapoIOB.log' ]] + then + /etc/init.d/MapoIOB restart + echo $date + "riavvio!" + fi +else + # in questo caso AVVIO il processo MapoIOB + /etc/init.d/MapoIOB start + echo $date + "file non trovato, avvio!" +fi diff --git a/IOB-PI/vers2.6 8bit/cleanPython.sh b/IOB-PI/vers2.6 8bit/cleanPython.sh new file mode 100644 index 0000000..c4f616a --- /dev/null +++ b/IOB-PI/vers2.6 8bit/cleanPython.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +DATE=`date +%Y-%m-%d_%T` +# log inizio pulizia +echo $DATE " - INIZIO pulizia processi python" >> clean.log +# effettua pulizia processi: killa tutti i processi python +killall python + +# avvia MapoIob +/etc/init.d/MapoIOB start + +# log fatto! +DATE=`date +%Y-%m-%d_%T` +echo $DATE " - FINE pulizia processi python + riavvio MapoIOB" >> clean.log diff --git a/IOB-PI/vers2.6 8bit/convertLogFile.py b/IOB-PI/vers2.6 8bit/convertLogFile.py new file mode 100644 index 0000000..760c2a9 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/convertLogFile.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# readFile v. 0.1 +# - single instance timer +# - invio multiplo x send eventi accodati +#--------------------------------------------------------------- +import os, sys +import argparse +#-------------------------------------------------------------- + +# gestione parser argomenti in input +parser = argparse.ArgumentParser() +parser.add_argument("inFile") +parser.add_argument("outFile") +args = parser.parse_args() + +#with open('logfile.txt', 'r') as inf, open('persMem.dat',"w") as outf: +with open(args.inFile, 'r') as inf, open(args.outFile,"w") as outf: + data = inf.readlines() + + lastDt = "" + lastMs = 0 + stepMs = 200 + + for line in data: + words = line.split() + if words[2] == 'queue': + # recupero dataOra + newDt = words[0].replace("-","") + words[1].replace(":","") + + # verifico se data/ora identica... + if (lastDt == newDt): + # --> aggiungo stepMs + lastMs += stepMs + else: + lastMs = 0 + + lastDt = newDt + + newDt = newDt + '{:03d}'.format(lastMs) #str(lastMs) + #print words[0].replace("-","") + words[1].replace(":","") + " | " + newDt + "\n" + + # print words + # outf.write(words[0].replace("-","") + words[1].replace(":","") + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n') + outf.write(newDt + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n') \ No newline at end of file diff --git a/IOB-PI/vers2.6 8bit/crontab b/IOB-PI/vers2.6 8bit/crontab new file mode 100644 index 0000000..74fe381 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/crontab @@ -0,0 +1 @@ +* * * * * /bin/bash /home/pi/steamware/checkAlive.sh >> /home/pi/stdout 2>> /home/pi/stderr diff --git a/IOB-PI/vers2.6 8bit/install-RPI-IOB.sh b/IOB-PI/vers2.6 8bit/install-RPI-IOB.sh new file mode 100644 index 0000000..d521931 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/install-RPI-IOB.sh @@ -0,0 +1,54 @@ +#|/bin/bash + +#installa il necessario per RPI-3-IOB partendo dal contenuto della folder /home/pi/steamware + +#step 1: creo file di log nuovi +rm /var/log/log*.txt +rm /var/log/MapoIOB* +rm /home/pi/steamware/log*.txt + +touch /var/log/logReboot.txt +touch /var/log/logTemp.txt +touch /var/log/MapoIOB.log + +ln -sf /var/log/logReboot.txt /home/pi/steamware/logReboot.txt +ln -sf /var/log/logTemp.txt /home/pi/steamware/logTemp.txt +ln -sf /var/log/MapoIOB.log /home/pi/steamware/logfile.txt + +chown pi:pi /home/pi -R +chmod 666 /var/log/log*.txt +chmod 666 /var/log/MapoIOB.log + +#step 2: copio files in /usr/local/bin +cd /home/pi/steamware +chmod +x *.sh +cp *.sh /usr/local/bin/ + +#step 3: copio files x logrotate... +cd /home/pi/steamware +cp MapoIOB_logrot /etc/logrotate.d/ + +# step 4: copio target systemd in avvio... +cp -f sendRebootIOB /etc/init.d/sendRebootIOB +cp -f sendRebootIOB.service /etc/systemd/system/sendRebootIOB.service +#echo "" +#echo "-----------------------------------------------" +#echo "Completare registrazione servizio avvio: digitare i seguenti comandi" +#echo "systemctl enable sendRebootIOB" +#echo "systemctl daemon-reload" +#echo "systemctl status sendRebootIOB" +#echo "-----------------------------------------------" +#echo "" + +# step 5: copio target MapoIOB in avvio... +cp -f MapoIOB /etc/init.d/MapoIOB +cp -f MapoIOB.service /etc/systemd/system/MapoIOB.service + + +#echo "" +#echo "" +#echo "-----------------------------------------------" +#echo "Infine creare voce crontab che salvi temperatura CPU/GPU ogni 20 minuti..." +#echo "crontab -e" +#echo "*/20 * * * * /usr/local/bin/saveTemp.sh" +#echo "-----------------------------------------------" diff --git a/IOB-PI/vers2.6 8bit/readFile.py b/IOB-PI/vers2.6 8bit/readFile.py new file mode 100644 index 0000000..887118d --- /dev/null +++ b/IOB-PI/vers2.6 8bit/readFile.py @@ -0,0 +1,152 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# readFile v. 0.1 +# - single instance timer +# - invio multiplo x send eventi accodati + +#--------------------------------------------------------------- + +import time + +from datetime import datetime + +import urllib +import ConfigParser +import os, sys + +import logging +import logging.handlers +import Queue + +import argparse +#-------------------------------------------------------------- + +# gestione parser argomenti in input +parser = argparse.ArgumentParser() +parser.add_argument("memFile") +parser.add_argument("logFile") +args = parser.parse_args() + +#definizione variabili BASE +stepQueuePut=25000 +stepQueueGet=250 +NMAXSEND=500000 # limite invio file x fare prove... +idxMacchina = "2003" + +#-------------------------------------------------------------- +# Gestione coda (condivisa) x registrazione eventi ed invio URL +#print "Creazione coda illimitata" +Coda = Queue.Queue(0) + +#--------------------------------------------------------------- +#Funzione di scrittura su coda con try-except + +def accoda(valore): + + try: + Coda.put(valore) + except Queue.Full: + logPro.error( "Queue full" + dtEve + '#' + value + '#' + cont ) + except: + logPro.error( "NETWORK:Errore http-no com rete-timeout" + url ) + + +#-------------------------------------------------------------- +# svuotaCoda x invio dati al server +def svuota_coda(): + + global NMAXSEND + + try: + if not Coda.empty(): + # invio SOLO i primi NMAXSEND eventi... SE minore del num eventi... + if NMAXSEND > Coda.qsize(): + NMAXSEND = Coda.qsize() + + + i = 0 + + with open(args.logFile,"w") as outf: + while i <= NMAXSEND: + if not Coda.empty(): + + # formatto dataOra corrente + dtCurr = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3] + + #prendo primo elemento dalla coda + resp = Coda.get() + + # recupero valori da elemento coda! + dtEve = resp.split("#")[0] + value = resp.split("#")[1] + cnt = resp.split("#")[2] + url = URLBASE + idxMacchina + URLADV1 + value + url = url + '&dtCurr=' + dtCurr + '&dtEve=' + dtEve + '&cnt=' + cnt + # CHIAMO URL + response3 = urllib.urlopen ( url ) + answ3 = response3.read() + + # registro chiamata + risposta + # outf.write(url + " --> " + answ3 + "\n") + + # incremento e controllo se mostrare output + i += 1 + if (i % stepQueueGet) == 0: + print "Inviati %d valori..." % i + + print "Inviati %d valori..." % i + except: + print "Errore in svuotamento coda!" + + +#--------------------------------------------------------------- +# MAIN + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'IOB.cfg' ) + + # NMAXSEND = config.getint ( 'time' , 'NMAXSEND' ) + # idxMacchina = config.get ( 'id' , 'idxMacchina' ) + + + URLBASE = config.get ( 'web' , 'URLBASE' ) + URLADV1 = config.get ( 'web' , 'URLADV1' ) + + LOGFILE = config.get ( 'log' , 'LOGFILE' ) + LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' ) +except: + print "\n\n" + PROGRAM_NAME + ' - Error 4 - in config file ' 'IOB.cfg' + sys.exit(1) + +#--------------------------------------------------------------- + +dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3] +print "Inizio elaborazione: %s" % dtCurr + +# Leggo il file! +i = 0 +with open(args.memFile, 'r') as inf, open(args.logFile,"w") as outf: + data = inf.readlines() + + print "Trovate %d da processare..." % len(data) + +# leggo e metto in QUEUE... + for line in data: + accoda(line) + i += 1 + if (i % stepQueuePut) == 0: + print "Accodati %d valori..." % i + +print "Completata lettura file! %d righe accodate da trasmettere" % Coda.qsize() + +dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3] +print "Inizio invio: %s" % dtCurr + + +# chiamo procedura x svuotare coda... +svuota_coda() + +dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3] +print "Completato invio: %s" % dtCurr \ No newline at end of file diff --git a/IOB-PI/vers2.6 8bit/readParallela.py b/IOB-PI/vers2.6 8bit/readParallela.py new file mode 100644 index 0000000..4513b4d --- /dev/null +++ b/IOB-PI/vers2.6 8bit/readParallela.py @@ -0,0 +1,733 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# readParallela v. 2.5.2 8 Ingressi +# - single instance timer +# - invio multiplo x send eventi accodati +# - gestione segnali BLINKING +# - gestione INVERSIONE segnali cv 10-VII-2018 +# - gestione FILTRAGGIO segnali brevi cv 23-VII-2018 +# - (2.3) gestione 12 bit cv 14-I-2020 +# - (2.4) fix ingressi e conf apertura parallela + gestione vari bit filtraggio x nuovi ingressi + update conf con 12 parametri bit SEL 15-I-2020 +# - (2.4.8) versione adatta a raspberry PI vecchia generazione (GPIO corto, 8bit) +# - (2.5) Fix (hope) ciclo "wait send to complete", gestione timeout (rety infinito se IO riparte in modo anomalo) +# - (2.5.1) Fix numero versione 18.05.2023 +# - (2.5.2) Fix gestione eccezioni con report dettagliato + +#--------------------------------------------------------------- +# levare locking +# timer semplificata +# GPIO global + + +import time +import sys + + +from datetime import datetime + +import urllib +import ConfigParser +import os, sys + +import logging +import logging.handlers +import threading +import Queue + +from array import * + +#-------------------------------------------------------------- + +# COSTANTI +MSGLEN = 9 +TIMEOUTSERIALE = 10 +MAXRETRY = 10 + +# numero campioni filtraggio segnale ballerino +MAX_COUNTER_BLINK = 10 + +PROGRAM_NAME ="ReadPar IOB-pi v.2.5.2" + +# DA FILE CONF +idxMacchina = "1001" +SAMPLETIME = 0.1 +TIMEOUTSHORT = (SAMPLETIME*20) +TIMEOUTLONG = (SAMPLETIME*600) +SENDURLTIME = 0.08 +NMAXSEND = 5 # numero massimo di invii per singolo ciclo di svuotamento + +# VAR +to_enable = False +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG +to_serial = TIMEOUTSERIALE +to_retry = MAXRETRY +errormsglen = 0 + +# VAR + +out_0 = 24 +out_1 = 26 + +in_0 = 11 +in_1 = 12 +in_2 = 13 +in_3 = 15 +in_4 = 16 +in_5 = 18 +in_6 = 22 +in_7 = 7 + +# contatore: serve x match tra accoda ed invia x possibile controllo a posteriori... ogni volta che accodo incremento di 1, va da 0 a 9999 +cont = '0' + +# variabile stato online/offline della macchina +onLine = '1' + +# variabile stato seinding/waiting x la parte invio URL +sending = '0' + +# variabile stato timer thread busy +timer_busy = False + +# +# array per ingressi filtrati + +i_counters = array ( 'i',[0,0,0,0,0,0,0,0]) +B_blinking = array ( 'B',[0,0,0,0,0,0,0,0]) +B_previous = array ( 'B',[0,0,0,0,0,0,0,0]) +B_input = array ( 'B',[0,0,0,0,0,0,0,0]) +B_output = array ( 'B',[0,0,0,0,0,0,0,0]) + +B_inverting = array ( 'B',[0,0,0,0,0,0,0,0]) + +B_filter = array ( 'B',[0,0,0,0,0,0,0,0]) +B_filter_prev = array ( 'B',[0,0,0,0,0,0,0,0]) +B_temp = array ( 'B',[0,0,0,0,0,0,0,0]) +i_filter_counters = array ( 'i',[0,0,0,0,0,0,0,0]) + +#-------------------------------------------------------------- +# Gestione coda (condivisa) x registrazione eventi ed invio URL +#print "Creazione coda illimitata" + +Coda = Queue.Queue(0) + +#queueLock = threading.Lock() + +#--------------------------------------------------------------- +# lettura parallela +# ritorna il byte letto pulito ( due char hex ) + +def readParallelaFiltrata(): + + global in_0 + global in_1 + global in_2 + global in_3 + global in_4 + global in_5 + global in_6 + global in_7 + + global GPIO + + current = '' + + + try: + + if GPIO.input(in_0): + B_input[0] = 0 + else: + B_input[0] = 1 + + if GPIO.input(in_1): + B_input[1] = 0 + else: + B_input[1] = 1 + + if GPIO.input(in_2): + B_input[2] = 0 + else: + B_input[2] = 1 + + if GPIO.input(in_3): + B_input[3] = 0 + else: + B_input[3] = 1 + + if GPIO.input(in_4): + B_input[4] = 0 + else: + B_input[4] = 1 + + if GPIO.input(in_5): + B_input[5] = 0 + else: + B_input[5] = 1 + + if GPIO.input(in_6): + B_input[6] = 0 + else: + B_input[6] = 1 + + if GPIO.input(in_7): + B_input[7] = 0 + else: + B_input[7] = 1 + + + + #ciclo per ogni segnale + for i in xrange(8) : + #print (i) + + # v2.1 gestione inversione bit ingresso + + if ( B_inverting[i] == 1 ) : + if ( B_input[i] == 0 ) : + B_input[i] = 1 + else : + B_input[i] = 0 + + # v2.2 gestione filtro segnali brevi + + if ( B_filter[i] == 1 ) : + + # fronte 0 -> 1 + if ( B_input[i] == 1 ) and ( B_filter_prev [i] == 0 ) : + if ( i_filter_counters[i] == 0 ) : + # vero fronte 0 -> 1 + i_filter_counters[i] = MAX_COUNTER_FILTER + B_temp[i] = 0 # tengo l' ingresso a 0 + #logPro.info("START spike 0->1 on bit " + `i` ) + else : + # fine disturbo breve di uno stato 1 + i_filter_counters[i] = 0 + B_temp[i] = 1 # tengo l' ingresso a 1 + logPro.info("END spike 0->1 on bit " + `i` ) + + # stabile 1 -> 1 + if ( B_input[i] == 1 ) and ( B_filter_prev [i] == 1 ) : + if ( i_filter_counters[i] == 0 ) : + # segnale stabile a 1 + B_temp[i] = 1 # tengo l' ingresso a 1 + else : + # poco dopo il fronte + i_filter_counters[i] = i_filter_counters[i] - 1 + B_temp[i] = 0 # tengo l' ingresso a 0 + + # fronte 1 -> 0 + if ( B_input[i] == 0 ) and ( B_filter_prev [i] == 1 ) : + if ( i_filter_counters[i] == 0 ) : + # vero fronte 1 -> 0 + i_filter_counters[i] = MAX_COUNTER_FILTER + B_temp[i] = 1 # tengo l' ingresso a 1 + #logPro.info("START spike 1->0 on bit " + `i` ) + else : + # fine disturbo breve di uno stato 0 + i_filter_counters[i] = 0 + B_temp[i] = 0 # tengo l' ingresso a 0 + logPro.info("END spike 1->0 on bit " + `i` ) + + # stabile 0 -> 0 + if ( B_input[i] == 0 ) and ( B_filter_prev [i] == 0 ) : + if ( i_filter_counters[i] == 0 ) : + # segnale stabile a 0 + B_temp[i] = 0 # tengo l' ingresso a 0 + else : + # poco dopo il fronte + i_filter_counters[i] = i_filter_counters[i] - 1 + B_temp[i] = 1 # tengo l' ingresso a 1 + + B_filter_prev [i] = B_input[i] + B_input[i] = B_temp[i] + + # fine gestione filtro segnali brevi + + + # se non blinking, copia ingresso + if ( B_blinking[i] == 0 ) : + B_output[i] = B_input[i] + else: + # gestione segnale blinking + # se fronte del segnale + if ( B_previous[i] != B_input[i] ) : + B_previous[i] = B_input[i] + # se fronte di salita + if ( B_input[i] == 1 ) : + # subito uscita = 1 + B_output[i] = 1 + i_counters[i] = MAX_COUNTER_BLINK + #else : + # # loggo che ho rilevato un blink... + # logPro.info("Blink down on bit " + `i`) + else: + # no , segnale eguale a prima + # se input a 0 + if ( B_input[i] == 0 ) : + # E CONTEGGIO IN CORSO + if ( i_counters[i] > 0 ) : + i_counters[i] = i_counters[i] -1 + if ( i_counters[i] == 0 ) : + B_output[i] = 0 + logPro.info("END Blink on bit " + `i` ) + + #Rimettiamo insieme i bit + new_value = 0 + + if ( B_output[0] == 1 ) : + new_value = new_value + 1 + if ( B_output[1] == 1 ) : + new_value = new_value + 2 + if ( B_output[2] == 1 ) : + new_value = new_value + 4 + if ( B_output[3] == 1 ) : + new_value = new_value + 8 + if ( B_output[4] == 1 ) : + new_value = new_value + 16 + if ( B_output[5] == 1 ) : + new_value = new_value + 32 + if ( B_output[6] == 1 ) : + new_value = new_value + 64 + if ( B_output[7] == 1 ) : + new_value = new_value + 128 + + + current = hex( new_value ).replace ( "0x" , "" ).upper() + + except Exception as e: + print "Errore in readParallelaFiltrata \n\n" + print str(e) + pass + + return current + +#--------------------------------------------------------------- +#Funzione di scrittura su coda con try-except + +def accoda(): + + try: + dtEve = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3] + Coda.put(dtEve + '#' + value + '#' + cont) + + except Queue.Full: + logPro.error( "Queue full" + `dtEve` + '#' + `value` + '#' + `cont` ) + except Exception as e: + logPro.error( "NETWORK:Errore http-no com rete-timeout" + url ) + logPro.error(str(e)) + +#-------------------------------------------------------------- +# svuotaCoda x invio dati al server +def svuota_coda(): + + global onLine + global sending + global timer_busy + global NMAXSEND + + #print "start timer " + + if ( timer_busy == False ): + timer_busy = True + #print "start timer ok " + + try: + if not Coda.empty(): + #print "coda da svuotare!" + response = urllib.urlopen(URLALIVE) + answ = response.read() + if answ == 'OK': + #print "OK alive" + response2 = urllib.urlopen(URLENABLED + idxMacchina) + answ2 = response2.read() + if answ2 == 'OK': + # aggiorno stato ad online + if onLine == '0': + logPro.info("IOB ONLINE!") + #print("IOB ONLINE") + + onLine = '1' # imposto comunque online + else: + if onLine == '1': + logPro.error("IOB offline") + #print("IOB offline") + + onLine = '0' + else: + if onLine == '1': + logPro.error("Server offline") + #print("Server offline") + + onLine = '0' + + # ora verifico SE si possa inviare (ovvero sia online server e NON ci siano altri send attivi...) + if onLine == '1': + if sending == '0': + #segnalo che sono in sending! + sending = '1' + + # SAM 2016.12.23: modifica x invio FINO A nMaxSend ELEMENTI ad ogni ciclo di svuotamento + i = NMAXSEND + + while i >= 0: + if not Coda.empty(): + + # formatto dataOra corrente + dtCurr = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3] + + #prendo primo elemento dalla coda + resp = Coda.get() + + # recupero valori da elemento coda! + dtEve = resp.split("#")[0] + value = resp.split("#")[1] + cnt = resp.split("#")[2] + url = URLBASE + idxMacchina + URLADV1 + value + url = url + '&dtCurr=' + dtCurr + '&dtEve=' + dtEve + '&cnt=' + cnt + # CHIAMO URL + response3 = urllib.urlopen ( url ) + answ3 = response3.read() + #print(url) + + # log valore inviato! + logSnd.info( value + ' ['+ cnt +']' + ' R:' + answ3 ) + #print "Valore smaltito dalla coda" + + # tolgo 1 al contatore + i -= 1 + + # completato invio, riporto sending a zero! + sending = '0' + else: + if to_retry > 0: + to_retry -= 1 + logPro.info("WAIT active send to complete") + else: + sending = '0' + to_retry = MAXRETRY + logPro.info("END WAIT, reset to_retry var") + + else: + pass + + else: + pass + + except Exception as e: + if onLine == '1': + logPro.error("Server Non raggiungibile") + logPro.error(str(e)) + #print "Non raggiungibile" + + onLine = '0' + + # in ogni caso + + timer_busy = False + #print "end timer ok" + + + #print "end timer " + + +#--------------------------------------------------------------- +# funzione timer thread +#--------------------------------------------------------------- +def do_every (interval, worker_func, iterations = 0): + if iterations != 1: + threading.Timer ( + interval, + do_every, [interval, worker_func, 0 if iterations == 0 else iterations-1] + ).start (); + + worker_func (); + +#--------------------------------------------------------------- +# gestione contatore +#--------------------------------------------------------------- +def contatore(): + + try: + global cont + ctr = int(cont) + ctr +=1 + ctr = ctr % 10000 # round robin 10000 eventi x track + cont = str(ctr) + except Exception as e: + print("errore incremento contatore \n\n") + print(str(e)) + +#--------------------------------------------------------------- +# avvia porta parallela +#--------------------------------------------------------------- +def avviaParallela(): + + global in_0 + global in_1 + global in_2 + global in_3 + global in_4 + global in_5 + global in_6 + global in_7 + + global GPIO + + try: + + GPIO.setmode(GPIO.BOARD) + + GPIO.setwarnings(False) + + #GPIO.setup(out_0, GPIO.OUT) # output 0 + #GPIO.setup(out_1, GPIO.OUT) # output 1 + + GPIO.setup(in_0, GPIO.IN) # input 0 + GPIO.setup(in_1, GPIO.IN) # input 1 + GPIO.setup(in_2, GPIO.IN) # input 2 + GPIO.setup(in_3, GPIO.IN) # input 3 + GPIO.setup(in_4, GPIO.IN) # input 4 + GPIO.setup(in_5, GPIO.IN) # input 5 + GPIO.setup(in_6, GPIO.IN) # input 6 + GPIO.setup(in_7, GPIO.IN) # input 7 + + except Exception as e: + print( "\n\n" + PROGRAM_NAME + " - Error 3 on RPi.GPIO ! \n\n") + print str(e) + sys.exit(1) + + + print( "\n\n" + PROGRAM_NAME + " - init ok \n\n") + + +#--------------------------------------------------------------- +#--------------------------------------------------------------- +# MAIN + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'IOB.cfg' ) + + SAMPLETIME = config.getfloat ( 'time' , 'SAMPLETIME' ) + TIMEOUTSHORT = config.getfloat ( 'time' , 'TIMEOUTSHORT' ) + TIMEOUTLONG = config.getfloat ( 'time' , 'TIMEOUTLONG' ) + SENDURLTIME = config.getfloat ( 'time' , 'SENDURLTIME' ) + NMAXSEND = config.getint ( 'time' , 'NMAXSEND' ) + + idxMacchina = config.get ( 'id' , 'idxMacchina' ) + + + URLBASE = config.get ( 'web' , 'URLBASE' ) + URLENABLED = config.get('web' , 'URLENABLED') + URLALIVE = config.get ('web' , 'URLALIVE') + URLADV1 = config.get ( 'web' , 'URLADV1' ) + + LOGFILE = config.get ( 'log' , 'LOGFILE' ) + LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' ) + + B_blinking[0] = config.getint ( 'blink' , 'bit0' ) + B_blinking[1] = config.getint ( 'blink' , 'bit1' ) + B_blinking[2] = config.getint ( 'blink' , 'bit2' ) + B_blinking[3] = config.getint ( 'blink' , 'bit3' ) + B_blinking[4] = config.getint ( 'blink' , 'bit4' ) + B_blinking[5] = config.getint ( 'blink' , 'bit5' ) + B_blinking[6] = config.getint ( 'blink' , 'bit6' ) + B_blinking[7] = config.getint ( 'blink' , 'bit7' ) + + MAX_COUNTER_BLINK = config.getint ( 'blink' , 'MAX_COUNTER_BLINK' ) + + # cv 2.1 se bit = 1 allora inverto segnale in ingresso... + + B_inverting[0] = config.getint ( 'invert' , 'bit0' ) + B_inverting[1] = config.getint ( 'invert' , 'bit1' ) + B_inverting[2] = config.getint ( 'invert' , 'bit2' ) + B_inverting[3] = config.getint ( 'invert' , 'bit3' ) + B_inverting[4] = config.getint ( 'invert' , 'bit4' ) + B_inverting[5] = config.getint ( 'invert' , 'bit5' ) + B_inverting[6] = config.getint ( 'invert' , 'bit6' ) + B_inverting[7] = config.getint ( 'invert' , 'bit7' ) + + # cv 2.2 se bit = 1 allora filtro segnali brevi ... + + B_filter[0] = config.getint ( 'filter' , 'bit0' ) + B_filter[1] = config.getint ( 'filter' , 'bit1' ) + B_filter[2] = config.getint ( 'filter' , 'bit2' ) + B_filter[3] = config.getint ( 'filter' , 'bit3' ) + B_filter[4] = config.getint ( 'filter' , 'bit4' ) + B_filter[5] = config.getint ( 'filter' , 'bit5' ) + B_filter[6] = config.getint ( 'filter' , 'bit6' ) + B_filter[7] = config.getint ( 'filter' , 'bit7' ) + + MAX_COUNTER_FILTER = config.getint ( 'filter' , 'MAX_COUNTER_FILTER' ) + + +except Exception as e: + print "\n\n" + PROGRAM_NAME + ' - Error 4 - in config file ' 'IOB.cfg' + print str(e) + sys.exit(1) + +#-------------------------------------------- +# oggetto Logger +#-------------------------------------------- +try: + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(name)-8s %(levelname)-8s %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + filename=LOGFILE, + filemode='a' + ) + + # aggiungo 2 logger specifici x queue e send... + logQue = logging.getLogger('queue') + logSnd = logging.getLogger('sendUrl') + logPro = logging.getLogger('program') + +except Exception as e: + # manda mail o simili - FARE!!! + print "LOG: Impossibile creare file log con nome" + print (LOGFILE) + print "\n\n" + print str(e) +#-------------------------------------------- + + +print "\n\n" + PROGRAM_NAME + "\n\n" + +global startstatus +startstatus = 1 + +if startstatus == 1: + logPro.info("Avvio Programma" + PROGRAM_NAME) + +## Verifica l'OS e di conseguenza carica il file relativo con metodo di lockfile appropriato + check singola istanza +if os.name == 'posix': + import unix +else: + import win + +logPro.info( "Start " + PROGRAM_NAME ) + + +# lettura file configurazione + +# [id] +# idxMacchina = 2001 +# [time] +# SAMPLETIME = 0.1 +# TIMEOUTSHORT = 200 +# TIMEOUTLONG = 6000 + + +print ( ' idxMacchina = %s' % ( idxMacchina ) ) +print ( ' SAMPLETIME = %4.2f' % ( SAMPLETIME ) ) +print ( ' TIMEOUTSHORT = %4.2f' % ( TIMEOUTSHORT ) ) +print ( ' TIMEOUTLONG = %4.2f' % ( TIMEOUTLONG ) ) +print ( ' SENDURLTIME = %4.2f' % ( SENDURLTIME ) ) +print ( ' URLBASE = %s' % ( URLBASE ) ) +print ( ' URLADV1 = %s' % ( URLADV1 ) ) +print ( ' LOGFILE = %s' % ( LOGFILE ) ) +print ( ' LOGLEVEL = %s' % ( LOGLEVEL ) ) + +# -sys.stdout.write ( 'idxMacchina ?' + idxMacchina + '\n') + +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG + + +#-------------------------------------------------------------- +# apertura parallela + +try: + import RPi.GPIO as GPIO +except RuntimeError: + print( "\n\n" + PROGRAM_NAME + " - Error 1 - you need superuser privileges") +except Exception as e: + print( "\n\n" + PROGRAM_NAME + " - Error 2 - you need superuser privileges. USE 'sudo' to run your script\n\n") + print str(e) + sys.exit(1) + + +avviaParallela() + + +#-------------------------------------------------------------- +# MARCO: qui inserire avvio thread di "svuotaCoda" + +# avviaSvuotaCoda +#print "Avvia svuota coda" + +do_every ( SENDURLTIME , svuota_coda ); + +#--------------------------------------------------------------- +# ciclo forever and ever + +old = '' + +#print "Avvio ciclo" +logPro.info("Avvio loop principale") +while 1: + + try: + time.sleep (SAMPLETIME) + except Exception as e: + logPro.info("First_SLEEP: errore attesa sampletime") + logPro.error(str(e)) + + # lettura dati da IOB + value = readParallelaFiltrata() + + if ( value != '' ) : + if value != old : + #loggo e invio dati + try: + logQue.info( value + ' ['+ cont +']') + errormsglen = 0 + accoda() + contatore() + except Exception as e: + logPro.error("URLBROWSER: errore registrazione valore e accoda") + logPro.error(str(e)) + pass + #enable e reset timer + to_enable = True + to_short = TIMEOUTSHORT + to_long = TIMEOUTLONG + + old = value + + + # gestione timeout breve + if ( to_enable ) : + to_short = to_short - SAMPLETIME + if to_short <= 0: + #loggo e invio dati + try: + logQue.info( '>' + value + ' ['+ cont +']') + errormsglen = 0 + accoda() + contatore() + except Exception as e: + logPro.error("URLBROWSER: errore registrazione valore e accoda TO_short") + logPro.error(str(e)) + pass + to_short = TIMEOUTSHORT + to_enable = False # dopo un colpo il timer breve viene disabilitato + to_long = TIMEOUTLONG + + # gestione timeout lungo + to_long = to_long - SAMPLETIME + if to_long <= 0: + #loggo e invio dati + try: + logQue.info( '>>' + value + ' ['+ cont +']') + errormsglen = 0 + accoda() + contatore() + except Exception as e: + logPro.error("URLBROWSER: errore registrazione valore e accoda TO_long") + logPro.error(str(e)) + pass + to_long = TIMEOUTLONG diff --git a/IOB-PI/readParallela_8.py b/IOB-PI/vers2.6 8bit/readParallela_8.py similarity index 100% rename from IOB-PI/readParallela_8.py rename to IOB-PI/vers2.6 8bit/readParallela_8.py diff --git a/IOB-PI/vers2.6 8bit/readSeriale.py b/IOB-PI/vers2.6 8bit/readSeriale.py new file mode 100644 index 0000000..3c00644 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/readSeriale.py @@ -0,0 +1,363 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +#--------------------------------------------------------------- + +import serial +import time +import sys +import datetime +import urllib +import ConfigParser +import os, sys + +#--------------------------------------------------------------- + +# COSTANTI +MSGLEN = 9 +TIMEOUTSERIALE = 10 +MAXRETRY = 3 + +# DA FILE CONF +idxMacchina = "2001" +SAMPLETIME = 0.1 +TIMEOUTSHORT = (SAMPLETIME*20) +TIMEOUTLONG = (SAMPLETIME*600) + +# VAR +to_enable = False +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG +to_serial = TIMEOUTSERIALE +to_retry = MAXRETRY +errormsglen = 0 + +#--------------------------------------------------------------- +# classe logger + +class Logger: + def __init__(self, filename): + try: + self.filename = filename + except: + logga("LOGGER: errore try su self.filename") + sys.exit(1) + def __call__(self, string): + try: + file = open(self.filename, 'a') + file.write('[' + time.strftime("%Y-%m-%d %H:%M:%S") + '] ') + file.write(string + '\n') + file.close() + except: + logga("LOGGER: errore try su scrittura") + sys.exit(1) + +#--------------------------------------------------------------- +# lettura buffer seriale e pulizia caratteri non stampabili +# ritorna '' se non c'è un messaggio buono o il messaggio pulito ( due bytes hex ) +# il messaggio ha il formato xxi00 00xxx + +def readSeriale(): + + global to_serial + global to_retry + global errormsglen + + ret = '' + current = '' + i = 0 + + # ritorna '' se non ci sono abbastanza caratteri + try: + if ser.inWaiting() < MSGLEN : +# +# to_serial = to_serial - 1 # se non mi risponde, faccio un ' altra richiesta.... +# if to_serial <= 0: +# try: +# requestData () +# except: +# logga("SERIALE: errore su requestData") +# sys.exit(1) +# to_serial = TIMEOUTSERIALE # ripristino timer +# to_retry = to_retry - 1 # contatore retry +# if to_retry <= 0: +# logga ( 'IOB not responding' ) +# return ret + logga("SERIALE: errore msglen < 9 char - Errore no. " + str(errormsglen)) + errormsglen = errormsglen +1 + avviaSeriale() + time.sleep(.2) + if errormsglen > 30: + sys.exit(1) + except: + if startstatus == 0: + logga ("Porta SERIALE non disponibile - ser.inWaiting error - exit... - Errore no. " + str(errormsglen)) + errormsglen = errormsglen +1 + avviaSeriale() + time.sleep(.2) + if errormsglen > 30: + sys.exit(1) + + # finchè c'è robba .. leggi e tieni i buoni + to_serial = TIMEOUTSERIALE + to_retry = MAXRETRY + try: + while ser.inWaiting() > 0 : + try: + c = ser.read(1) + except: + logga("SERIALE: errore su try ser.read") + sys.exit(1) + # filtra caratteri non stampabili + if c > ' ' : + current += c + #sys.stdout.write(current + '<<<<\n') + # ora il messaggio ha il formato xxxxxi00 00xxx : cerco la 'i' iniziale + try: + while i < len(current) and current[i] != 'i': + i = i + 1 + except: + logga("SERIALE: errore su ricerca i iniziale") + sys.exit(1) + # se non ho trovato la 'i' restituisco '' + if i == len(current)-1: + return ret + else: + current = current[i+1:i+3] + # richiesta dati ad IOB + requestData() + #sys.stdout.write ( current + '\n') + except: + if startstatus == 0: + logga ('Porta SERIALE non disponibile - ser.inWaiting e filtraggio error...exit') + sys.exit(1) + return current +#--------------------------------------------------------------- +# richiesta dati ad IOB : scrittura su seriale + +def requestData (): + try : + ser.write ("$i" + '\r\n') + ser.flush() + except : + if startstatus == 0: + logga ( "SERIAL: Errore di scrittura/flush") + + +#--------------------------------------------------------------- +#Funzione di scrittura su url con try-except + +def chiamaUrl(): + try: + url = URLBASE + idxMacchina + URLADV1 + value + urllib.urlopen ( url ) + except: + logga ( "NETWORK:Errore http-no com rete-timeout" + url ) + + +#--------------------------------------------------------------- +# Funzione che verifica possibilità di creare log e include testo corrente + +def logga(message) : + try: + log(message) + except : + pass + +#--------------------------------------------------------------- + + +def avviaSeriale(): + global ser + + try: + ser = serial.Serial( + port = comm_port , + baudrate = 9600 , + parity = serial.PARITY_NONE , + stopbits = serial.STOPBITS_ONE , + bytesize = serial.EIGHTBITS + ) + startstatus = 0 + except serial.serialutil.SerialException , e : + try: + if startstatus == 0: + logga ( "SERIAL:Errore apertura seriale - " + comm_port) + except: + pass + sys.stdout.write ( '\nErrore apertura seriale\n\n%s\n\n' % e ) + if errormsglen > 30: + sys.exit (1) + +#--------------------------------------------------------------- +#--------------------------------------------------------------- +# MAIN + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'readSeriale.cfg' ) + + SAMPLETIME = config.getfloat ( 'time' , 'SAMPLETIME' ) + TIMEOUTSHORT = config.getfloat ( 'time' , 'TIMEOUTSHORT' ) + TIMEOUTLONG = config.getfloat ( 'time' , 'TIMEOUTLONG' ) + + idxMacchina = config.get ( 'id' , 'idxMacchina' ) + comm_port = config.get ( 'comm' , 'port' ) + + URLBASE = config.get ( 'web' , 'URLBASE' ) + URLADV1 = config.get ( 'web' , 'URLADV1' ) + + LOGFILE = config.get ( 'log' , 'LOGFILE' ) + LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' ) +except: + sys.exit(1) + +# oggetto Logger +try: + log = Logger(LOGFILE) +except: + # manda mail o simili - FARE!!! + print "LOG: Impossibile creare file log con nome " + print (LOGFILE) + +print '\n\n Read seriale IOB v.0.2 !!!!\n' + +global startstatus +startstatus = 1 + +if startstatus == 1: + logga("Avvio Programma") + +# Verifica l'OS e di conseguenza carica il file relativo con metodo di lockfile appropriato + check singola istanza +if os.name == 'posix': + import unix +else: + import win + +logga ( "Start Read seriale IOB v.0.2") + + +# lettura file configurazione + +# [comm] +# port = /dev/ttyS0 +# [id] +# idxMacchina = 2001 +# [time] +# SAMPLETIME = 0.1 +# TIMEOUTSHORT = 200 +# TIMEOUTLONG = 6000 + +print ( ' comm_port = %s' % ( comm_port ) ) +print ( ' idxMacchina = %s' % ( idxMacchina ) ) +print ( ' SAMPLETIME = %4.2f' % ( SAMPLETIME ) ) +print ( ' TIMEOUTSHORT = %4.2f' % ( TIMEOUTSHORT ) ) +print ( ' TIMEOUTLONG = %4.2f' % ( TIMEOUTLONG ) ) +print ( ' URLBASE = %s' % ( URLBASE ) ) +print ( ' URLADV1 = %s' % ( URLADV1 ) ) +print ( ' LOGFILE = %s' % ( LOGFILE ) ) +print ( ' LOGLEVEL = %s' % ( LOGLEVEL ) ) + +# -sys.stdout.write ( 'idxMacchina ?' + idxMacchina + '\n') + +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG + + + +#-------------------------------------------------------------- + + +#--------------------------------------------------------------- +# apertura seriale + +avviaSeriale() + +#try: +# ser = serial.Serial( +# port = comm_port , +# baudrate = 9600 , +# parity = serial.PARITY_NONE , +# stopbits = serial.STOPBITS_ONE , +# bytesize = serial.EIGHTBITS +# ) +# print "Initialized!" +#except serial.serialutil.SerialException , e : +# try: +# logga ( "SERIAL:Errore apertura seriale - " + comm_port) +# except: +# pass +# sys.stdout.write ( '\nErrore apertura seriale\n\n%s\n\n' % e ) +# sys.exit (1) + +#--------------------------------------------------------------- +# ciclo forever and ever + +old = '' + +# richiesta dati ad IOB +try: + requestData() +except: + logga("SERIALE: errore sul try di requestData") + sys.exit(1) + + +while 1: + try: + time.sleep (SAMPLETIME) + except: + logga("SERIALE_SLEEP: errore attesa sampletime") + # lettura dati da IOB + try: + value = readSeriale() + except: + if startstatus == 0: + logga("errore PRIMA LETTURA SERIALE") + sys.exit(1) + if ( value != '' ) : + if value != old : + #loggo e invio dati + try: + logga ( value ) + errormsglen = 0 + chiamaUrl() + except: + logga("URLBROWSER: errore registrazione valore e chiamaUrl") + pass + #enable e reset timer + to_enable = True + to_short = TIMEOUTSHORT + to_long = TIMEOUTLONG + + old = value + + + # gestione timeout breve + if ( to_enable ) : + to_short = to_short - SAMPLETIME + if to_short <= 0: + #loggo e invio dati + try: + logga ( '>' + value ) + errormsglen = 0 + chiamaUrl() + except: + pass + to_short = TIMEOUTSHORT + to_enable = False # dopo un colpo il timer breve viene disabilitato + to_long = TIMEOUTLONG + + # gestione timeout lungo + to_long = to_long - SAMPLETIME + if to_long <= 0: + #loggo e invio dati + try: + logga ( '>>' + value ) + errormsglen = 0 + chiamaUrl() + except: + pass + to_long = TIMEOUTLONG + + diff --git a/IOB-PI/vers2.6 8bit/saveTemp.sh b/IOB-PI/vers2.6 8bit/saveTemp.sh new file mode 100644 index 0000000..a2cd2be --- /dev/null +++ b/IOB-PI/vers2.6 8bit/saveTemp.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +#salva la temperatura CPU e GPU su chiamata... + +# imposto logfile... +logFile="/var/log/logTemp.txt" + +cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp) +cpuTemp1=$(($cpuTemp0/1000)) +cpuTemp2=$(($cpuTemp0/100)) +cpuTempM=$(($cpuTemp2 % $cpuTemp1)) + +gpuTemp=`vcgencmd measure_temp` + +loadAvg=`cat /proc/loadavg` + +echo "$(date) | CPU: temp=$cpuTemp1.$cpuTempM ºC | GPU: $gpuTemp | LoadAvg: $loadAvg" >> $logFile diff --git a/IOB-PI/vers2.6 8bit/sendReboot.py b/IOB-PI/vers2.6 8bit/sendReboot.py new file mode 100644 index 0000000..7ca636d --- /dev/null +++ b/IOB-PI/vers2.6 8bit/sendReboot.py @@ -0,0 +1,135 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# sendReboot v. 1.8 +# - (2.5.2) Fix gestione eccezioni con report dettagliato +#--------------------------------------------------------------- + + +import time +import sys + + +from datetime import datetime + +import urllib +import ConfigParser +import os, sys + +import logging + +import time + +#--------------------------------------------------------------- + +# COSTANTI +SR_PROG_NAME = "SendReboot IOB-pi v.2.5.2" + +# DA FILE CONF +idxMacchina = "99" + +# registro se ho fatto chiamata +global numTry +numTry = 1 + + +#--------------------------------------------------------------- +#Funzione di scrittura su url con try-except +#--------------------------------------------------------------- + +def chiamaUrl(numTry): + + try: + urllib.urlopen ( url ) + numTry = numTry + 10 + + except Exception as e: + print("Errore in chiamaUrl") + print(str(e)) + logging.info ( str(e) ) + + print("Url chiamato: " , url) + return numTry + + +#--------------------------------------------------------------- +# Funzione di recupero mac address per poterlo inviare a MPIO +#--------------------------------------------------------------- +def getMAC(interface): + # Return the MAC address of interface + try: + str = open('/sys/class/net/' + interface + '/address').read() + except: + str = "00:00:00:00:00:00" + return str[0:17] + +#--------------------------------------------------------------- +# MAIN +#--------------------------------------------------------------- + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'IOB.cfg' ) + + idxMacchina = config.get ( 'id' , 'idxMacchina' ) + + + URLREBO = config.get ( 'web' , 'URLREBO' ) + + LOGFILE = config.get ( 'log' , 'LOGREBO' ) +except Exception as e: + print("\n\n" + SR_PROG_NAME + ' - Error 4 - in config file ' 'IOB.cfg') + print(str(e)) + sys.exit(1) + + +#-------------------------------------------- +# oggetto Logger +#-------------------------------------------- +try: +# log = Logger(LOGFILE) + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(name)-8s %(levelname)-8s %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + filename=LOGFILE, + filemode='a') + +except Exception as e: + # manda mail o simili - FARE!!! + print("LOG: Impossibile creare file log con nome ") + print(LOGFILE) + print(str(e)) +#-------------------------------------------- + + +print("\n\n" + SR_PROG_NAME + "\n\n") + +global startstatus +startstatus = 1 + +if startstatus == 1: + logging.info("Avvio Programma " + SR_PROG_NAME) + + +# lettura file configurazione +print ( ' idxMacchina = %s' % ( idxMacchina ) ) +print ( ' URLREBO = %s' % ( URLREBO ) ) +print ( ' LOGFILE = %s' % ( LOGFILE ) ) + +# lettura mac address +myMac = getMAC('eth0') +print ( ' MAC Address = %s' % ( myMac ) ) + +# configuro URL da inviare +url = URLREBO + idxMacchina + "&mac=" + myMac + +# modifica: cerco se ho inviato segnale altrimenti ritento invio... +while (numTry < 11): + logging.info("Tentativo invio URL: $numTry" ) + numTry = chiamaUrl(numTry) + time.sleep(3) + numTry = numTry + 1 + + +# registro che ho inviato! +logging.info("Inviato segnale di reboot!: " + url ) diff --git a/IOB-PI/vers2.6 8bit/sendRebootIOB b/IOB-PI/vers2.6 8bit/sendRebootIOB new file mode 100644 index 0000000..191bfff --- /dev/null +++ b/IOB-PI/vers2.6 8bit/sendRebootIOB @@ -0,0 +1,33 @@ +#!/bin/sh - +# +### BEGIN INIT INFO +# Provides: sendReboot +# Required-Start: $network $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Steamware's IOB reboot signal +# Description: Steamware's sendReboot segnalazione reboot dispositivo +### END INIT INFO + +#! /bin/sh +# /etc/init.d/sendReboot + + + +export HOME +case "$1" in + start) + cd /home/pi/steamware + echo "Starting sendReboot" + /usr/bin/python ./sendReboot.py 2>&1 & + echo "Verifica Rete e file IOB" + /usr/local/bin/setIobConf.sh + ;; + *) + echo "Usage: /etc/init.d/sendReboot {start}" + exit 1 + ;; +esac +exit 0 + diff --git a/IOB-PI/vers2.6 8bit/sendRebootIOB.service b/IOB-PI/vers2.6 8bit/sendRebootIOB.service new file mode 100644 index 0000000..48e3690 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/sendRebootIOB.service @@ -0,0 +1,22 @@ +[Unit] +SourcePath=/etc/init.d/sendRebootIOB +Description=LSB: Steamware's IOB reboot signal +Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target +Wants=network-online.target +After=network.target network-online.target auditd.service +Conflicts=shutdown.target + +[Service] +Type=forking +Restart=no +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=yes +SysVStartPriority=2 +ExecStart=/etc/init.d/sendRebootIOB start +ExecStop=/etc/init.d/sendRebootIOB stop + +[Install] +WantedBy=multi-user.target diff --git a/IOB-PI/vers2.6 8bit/setIobConf.sh b/IOB-PI/vers2.6 8bit/setIobConf.sh new file mode 100644 index 0000000..30b4781 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/setIobConf.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# verifico se sia rete donati o rete steamware o offline... +netStatus=`cat /sys/class/net/eth0/operstate` +iaddr=`ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1` + +cd /home/pi/steamware + +if [[ $netStatus != "up" ]] +then + echo "Siamo Offline, pagina demo!" +elif [[ $iaddr == "10.74.82"* ]] +then + cp IOB.cfg.steamware IOB.cfg -f + echo "Siamo in Steamware!" +elif [[ $iaddr == "192.168.51"* ]] +then + cp IOB.cfg.donati IOB.cfg -f + echo "Siamo a Passirano!" +else + echo "Siamo altrove, pagina demo!" +fi + +echo "$iaddr" + +chown pi:pi * \ No newline at end of file diff --git a/IOB-PI/vers2.6 8bit/unix.py b/IOB-PI/vers2.6 8bit/unix.py new file mode 100644 index 0000000..12fb3dc --- /dev/null +++ b/IOB-PI/vers2.6 8bit/unix.py @@ -0,0 +1,31 @@ +import fcntl +import os +import logging + +#--------------------------------------------------------------- +# meccanismo di file lock per evitare multiple instances +# The function will try to lock the file specified , if it success, return True, else return False. +# The nice thing is that the lock will be dropped when the program terminates. +# >>>Use : +# if not lockFile(".lock.pod"): +# sys.exit(0) + +def lockFile ( lockfile ) : + + fd = os.open ( lockfile , os.O_CREAT | os.O_TRUNC | os.O_WRONLY ) + try: + # Request exclusive (EX) non-blocking (NB) advisory lock. + fcntl.lockf ( fd , fcntl.LOCK_EX | fcntl.LOCK_NB ) + except IOError: + return False + + return True + +if not lockFile ( ".lockfile" ) : + print '\n noi non siamo soli ...\n' + logging.error( "LOCK: Piu istanze aperte") + #sys.exit ( 0 ) + +#- print '\n running alone ...\n' + + diff --git a/IOB-PI/vers2.6 8bit/unix.pyc b/IOB-PI/vers2.6 8bit/unix.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f528212e734a67eb0c5153f80c50aace6d1f362a GIT binary patch literal 669 zcma)3%Wl&^6g_urw~d>yU+>A9OYr`N%@ph^{s}cOyT^nX-Q@*l0+qlI zZU`U)Q~_=XCPx+G-H{Yng{UHzqsEV#q&qxT{o$3*iJ_y5*oJI|Szv(`;rbsCJ`6B$ z*${&pf$xN?1K0?w9bA(KyWa2lGMzS$5!wzeVzeh9A{%3JX7@2k9bcYy9f_mW#)fX& z$j0t67@rS|(c9@Qo)#zh(C+#CX)(@^KQSk;m^ZfesMhm~g>OC{4?mob&K__+@c8|B z)V8|y-G^mur01KqTbVk3Kip4Iwe&YyR4M1-oq5Kn|3$B5f1~=w%5wd+Y-NAjsLO0~ zb$|Gf5BIp$I9(9WDG&$Lqez$z$JyO{^OU1FX|!T%5~IqsPK>Tql4V(Jo^aL4c#(Wm z+e8^#Hs54YZe(j^>U0<0F@Tp=>*Z24%i@tsxRP{AA8!BO5?-!#wXNkV_cmTam-vf2 I`(29YFVCEWI{*Lx literal 0 HcmV?d00001 diff --git a/IOB-PI/vers2.6 8bit/update-RPI-IOB.sh b/IOB-PI/vers2.6 8bit/update-RPI-IOB.sh new file mode 100644 index 0000000..d521931 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/update-RPI-IOB.sh @@ -0,0 +1,54 @@ +#|/bin/bash + +#installa il necessario per RPI-3-IOB partendo dal contenuto della folder /home/pi/steamware + +#step 1: creo file di log nuovi +rm /var/log/log*.txt +rm /var/log/MapoIOB* +rm /home/pi/steamware/log*.txt + +touch /var/log/logReboot.txt +touch /var/log/logTemp.txt +touch /var/log/MapoIOB.log + +ln -sf /var/log/logReboot.txt /home/pi/steamware/logReboot.txt +ln -sf /var/log/logTemp.txt /home/pi/steamware/logTemp.txt +ln -sf /var/log/MapoIOB.log /home/pi/steamware/logfile.txt + +chown pi:pi /home/pi -R +chmod 666 /var/log/log*.txt +chmod 666 /var/log/MapoIOB.log + +#step 2: copio files in /usr/local/bin +cd /home/pi/steamware +chmod +x *.sh +cp *.sh /usr/local/bin/ + +#step 3: copio files x logrotate... +cd /home/pi/steamware +cp MapoIOB_logrot /etc/logrotate.d/ + +# step 4: copio target systemd in avvio... +cp -f sendRebootIOB /etc/init.d/sendRebootIOB +cp -f sendRebootIOB.service /etc/systemd/system/sendRebootIOB.service +#echo "" +#echo "-----------------------------------------------" +#echo "Completare registrazione servizio avvio: digitare i seguenti comandi" +#echo "systemctl enable sendRebootIOB" +#echo "systemctl daemon-reload" +#echo "systemctl status sendRebootIOB" +#echo "-----------------------------------------------" +#echo "" + +# step 5: copio target MapoIOB in avvio... +cp -f MapoIOB /etc/init.d/MapoIOB +cp -f MapoIOB.service /etc/systemd/system/MapoIOB.service + + +#echo "" +#echo "" +#echo "-----------------------------------------------" +#echo "Infine creare voce crontab che salvi temperatura CPU/GPU ogni 20 minuti..." +#echo "crontab -e" +#echo "*/20 * * * * /usr/local/bin/saveTemp.sh" +#echo "-----------------------------------------------" diff --git a/IOB-PI/vers2.6 8bit/win.py b/IOB-PI/vers2.6 8bit/win.py new file mode 100644 index 0000000..f679f60 --- /dev/null +++ b/IOB-PI/vers2.6 8bit/win.py @@ -0,0 +1,32 @@ +import win32api +print " Running on WINDOWS\n" +import os +#--------------------------------------------------------------- +# meccanismo di file lock per evitare multiple instances +# The function will try to lock the file specified , if it success, return True, else return False. +# The nice thing is that the lock will be dropped when the program terminates. +# >>>Use : +# if not lockFile(".lock.pod"): +# sys.exit(0) + +def lockFile ( lockfile ) : + try: + fd = os.open ( lockfile , os.O_CREAT | os.O_TRUNC | os.O_WRONLY ) + except: + logga("Errore nel file WIN.PY per FD") + try: + # Request exclusive (EX) non-blocking (NB) advisory lock. + #fcntl.lockf ( fd , fcntl.LOCK_EX | fcntl.LOCK_NB ) + print " Dummy Method! Completa Lockfile\n" + except IOError: + return False + + return True +try: + if not lockFile ( ".lockfile" ) : + print '\n noi non siamo soli ...\n' + logga ( "LOCK: Piu istanze aperte") + sys.exit ( 0 ) +except: + logga("if not lockfile NON RIUSCITO in file WIN.PY") + sys.exit(1) diff --git a/IOB-PI/vers3.x/IOB.cfg b/IOB-PI/vers3.x/IOB.cfg new file mode 100644 index 0000000..9cfc458 --- /dev/null +++ b/IOB-PI/vers3.x/IOB.cfg @@ -0,0 +1,72 @@ +[id] +idxMacchina = 0001 +#idxMacchina = SIMUL_01 +#numParams=8 +numParams=12 + +[web] +URLBASE = http://10.74.82.218/MP/RIOC/api/IOB/input/ +URLALIVE = http://10.74.82.218/MP/RIOC/api/IOB +URLENABLED = http://10.74.82.218/MP/RIOC/api/IOB/enabled/ +URLADV1 = ?valore= +URLREBO = http://10.74.82.218/MP/IOC/api/IOB/sendReboot/ +URLINFO = http://10.74.82.218/MP/RIOC/api/IOB/setM2IOB/ + +[time] +SAMPLETIME = 0.05 +TIMEOUTSHORT = 0.50 +TIMEOUTLONG = 80 +SENDURLTIME = 0.15 +NMAXSEND = 5 + +[log] +LOGLEVEL = 10 +LOGFILE = logfile.txt +LOGREBO = logReboot.txt + +[comm] +port = /dev/ttyAMA0 + +[blink] +MAX_COUNTER_BLINK = 30 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 0 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 +bit8 = 0 +bit9 = 0 +bit10 = 0 +bit11 = 0 + +[invert] +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 0 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 +bit8 = 0 +bit9 = 0 +bit10 = 0 +bit11 = 0 + +[filter] +MAX_COUNTER_FILTER = 8 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 0 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 +bit8 = 0 +bit9 = 0 +bit10 = 0 +bit11 = 0 diff --git a/IOB-PI/vers3.x/IOB.cfg.donati b/IOB-PI/vers3.x/IOB.cfg.donati new file mode 100644 index 0000000..29c3d61 --- /dev/null +++ b/IOB-PI/vers3.x/IOB.cfg.donati @@ -0,0 +1,35 @@ +[id] +idxMacchina = 2007 + +[web] +URLBASE = http://192.168.51.77/MP/IO/IOB/input/ +URLALIVE = http://192.168.51.77/MP/IO/IOB +URLENABLED = http://192.168.51.77/MP/IO/IOB/enabled/ +URLADV1 = ?valore= +URLREBO = http://192.168.51.77/MP/IO/sendReboot.aspx?idxMacchina= + +[time] +SAMPLETIME = 0.05 +TIMEOUTSHORT = 0.30 +TIMEOUTLONG = 50 +SENDURLTIME = 0.15 +NMAXSEND = 5 + +[log] +LOGLEVEL = 10 +LOGFILE = logfile.txt +LOGREBO = logReboot.txt + +[comm] +port = /dev/ttyAMA0 + +[blink] +MAX_COUNTER_BLINK = 30 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 1 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 diff --git a/IOB-PI/vers3.x/IOB.cfg.steamware b/IOB-PI/vers3.x/IOB.cfg.steamware new file mode 100644 index 0000000..920043f --- /dev/null +++ b/IOB-PI/vers3.x/IOB.cfg.steamware @@ -0,0 +1,35 @@ +[id] +idxMacchina = 1005 + +[web] +URLBASE = http://10.74.82.218/MP/IO/IOB/input/ +URLALIVE = http://10.74.82.218/MP/IO/IOB +URLENABLED = http://10.74.82.218/MP/IO/IOB/enabled/ +URLADV1 = ?valore= +URLREBO = http://10.74.82.218/MPIO/sendReboot.aspx?idxMacchina= + +[time] +SAMPLETIME = 0.05 +TIMEOUTSHORT = 0.30 +TIMEOUTLONG = 50 +SENDURLTIME = 0.15 +NMAXSEND = 5 + +[log] +LOGLEVEL = 10 +LOGFILE = logfile.txt +LOGREBO = logReboot.txt + +[comm] +port = /dev/ttyAMA0 + +[blink] +MAX_COUNTER_BLINK = 30 +bit0 = 0 +bit1 = 0 +bit2 = 0 +bit3 = 1 +bit4 = 0 +bit5 = 0 +bit6 = 0 +bit7 = 0 diff --git a/IOB-PI/vers3.x/Mapo.zip b/IOB-PI/vers3.x/Mapo.zip new file mode 100644 index 0000000000000000000000000000000000000000..1a8e9bc08a28dc99798531d3d43e6ea18c192345 GIT binary patch literal 20767 zcmZ6yV{mBO(ls30wr$(CwPV}1ZQFLTW7~FiZ133qa_Zi?}~#X*;W5A20J7{|A^6=-S#^Vp7>gT zvn#?QBg}w4j73vpDGjJ4D3xO7bD&hnEPPLcnnf8^Z+>cOHgkFo_5$agWcHNj{ccEM zvD$PyhqSItJ;{2i$RRUc8hzC;ANpShW*_NNRi^1@0|F=GntDv|P(ai_M3i8Q$?(6S zf%|Y%o={%|S>1ID$jDp+1A>#O?A()}?YYzkc&Qd(gQn2X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vH^ZKG!rnVj3p!Zu-}C%9^>Uw8bW+S)wE}B%r{k`buw_Q) z)_B7PvPY@f@OD7)zA)NPoJZ6I+hTu;*6WdCW!8&IJeBP*8e^P?`$Ax!k^Ze3`%c}< z%C#uZ_gZZt^FByTf7G+#Kwuo;mX=8U?a^PLm3$CajZl~S1zeL; zD?Lc{Fy!_hF78&vk{_f{?)}9-Ui%foFd8;OZl0x#_Sn&?ULgP7JC%t zn}kP=0j?#Tz(d$RHJP44kh^`fmUsXNM)*02FBFut;VvfsivpqRHV9BH7$}? z`gR&l&=i|{_9@gPi|u*h#`WTlpIwTa*dGsH&3gYf*8(ZfwkQ``cW2G0Lg4tD{#@mYc<_V`g9-+$_P5^;_C1i1*mv z3-xW+P9ScKC9XMGe5fpQyF5!hsc#k}QB*dYeSg%j9 z9{(KiI<9|UOSVyKXjS@o{rtFq_~!jX<8NcF}f^g@wa`;xLv>WwILoH6xJd+FUm*+5)g6CcU{m|ik_ya%9h^w)4Pcu8m!A_D2mA4m@Fie{ z9J=#>p`(%dz+Hy~A*g=lwFBnCz9}TW7Vrc*G?oBEV51Kb1f~5B9ol|?S+I8niN!!j z>~|-NqxjG47)Ur1(1bgbh98A~CetTDl7OHbB-#hVVEH)-P6H(WKZ?=8ELiwWVod?{ z-Vqr%7zFG5NMJ6Y{yPAVs{X(<`1Aycj*+jCZTRH5c*F|4Soc;DkME(TJzu$M`}bc3a)iXsHXP! z)E5kaGvot^>}zy_>3)YC!PL=(evpzKT;Bo{mHtl>G%ya{Y)QB~{GYA&;(4lreVB{` N_~`@DqwV~`-QSy{yHx-H literal 0 HcmV?d00001 diff --git a/IOB-PI/vers3.x/Mapo.zip.md5 b/IOB-PI/vers3.x/Mapo.zip.md5 new file mode 100644 index 0000000..f6a6154 --- /dev/null +++ b/IOB-PI/vers3.x/Mapo.zip.md5 @@ -0,0 +1 @@ +50249a64efeef80bad924f3f6351edbc \ No newline at end of file diff --git a/IOB-PI/vers3.x/MapoIOB b/IOB-PI/vers3.x/MapoIOB new file mode 100644 index 0000000..1d8f821 --- /dev/null +++ b/IOB-PI/vers3.x/MapoIOB @@ -0,0 +1,41 @@ +#! /bin/bash +### BEGIN INIT INFO +# Provides: MapoIOB: script Steamware per avvio driver IOB +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Steamware's MapoIOB driver +# Description: Steamware's MapoIOB driver, versione lettura porta parallela +### END INIT INFO + +# /etc/init.d/MapoIOB + +export HOME +case "$1" in + start) + echo "Starting readParallela" + cd /home/pi/steamware + /usr/bin/python ./readParallela.py 2>&1 & + ;; + stop) + echo "Stopping readParallela" + RS_PID=`ps auxwww | grep readParallela.py | head -1 | awk '{print $2}'` + kill -9 $RS_PID + cd /home/pi/steamware + rm .lockfile + ;; + restart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + $0 stop + killall python + $0 start + ;; + *) + echo "Usage: /etc/init.d/MapoIOB {start|stop|restart}" + exit 1 + ;; +esac +exit 0 + diff --git a/IOB-PI/vers3.x/MapoIOB.service b/IOB-PI/vers3.x/MapoIOB.service new file mode 100644 index 0000000..7803ccc --- /dev/null +++ b/IOB-PI/vers3.x/MapoIOB.service @@ -0,0 +1,24 @@ +[Unit] +SourcePath=/etc/init.d/MapoIOB +Description=LSB: Steamware's MapoIOB driver +Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target +Wants=network-online.target +After=network.target network-online.target auditd.service +Conflicts=shutdown.target + +[Service] +Type=forking +Restart=on-failure +RestartSec=5 +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=yes +SysVStartPriority=1 +ExecStartPre=/bin/sleep 5 +ExecStart=/etc/init.d/MapoIOB start +ExecStop=/etc/init.d/MapoIOB stop + +[Install] +WantedBy=multi-user.target diff --git a/IOB-PI/vers3.x/MapoIOB_logrot b/IOB-PI/vers3.x/MapoIOB_logrot new file mode 100644 index 0000000..13410b9 --- /dev/null +++ b/IOB-PI/vers3.x/MapoIOB_logrot @@ -0,0 +1,28 @@ +/var/log/MapoIOB.log { + size 8M + copytruncate + create 700 pi pi + dateext + rotate 100 + compress + maxage 366 + missingok +} +/var/log/logReboot.txt { + size 1M + copytruncate + create 700 pi pi + dateext + rotate 30 + compress + missingok +} +/var/log/logTemp.txt { + size 1M + copytruncate + create 700 pi pi + dateext + rotate 30 + compress + missingok +} diff --git a/IOB-PI/vers3.x/checkAlive.sh b/IOB-PI/vers3.x/checkAlive.sh new file mode 100644 index 0000000..aace73d --- /dev/null +++ b/IOB-PI/vers3.x/checkAlive.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# controlla se il logfile è correntemente scritto (quindi MapoIOB è alive) altrimenti riavvia! + +DATE=`date +%Y-%m-%d` +cd /var/log +if [ -f MapoIOB.log ] + then + # controllo SE sia stato acceduto da meno di 2 minuti (=alive da log...) + trovato=`find . -name 'MapoIOB*' -cmin -1` + if [[ $trovato != './MapoIOB.log' ]] + then + /etc/init.d/MapoIOB restart + echo $date + "riavvio!" + fi +else + # in questo caso AVVIO il processo MapoIOB + /etc/init.d/MapoIOB start + echo $date + "file non trovato, avvio!" +fi diff --git a/IOB-PI/vers3.x/cleanPython.sh b/IOB-PI/vers3.x/cleanPython.sh new file mode 100644 index 0000000..c4f616a --- /dev/null +++ b/IOB-PI/vers3.x/cleanPython.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +DATE=`date +%Y-%m-%d_%T` +# log inizio pulizia +echo $DATE " - INIZIO pulizia processi python" >> clean.log +# effettua pulizia processi: killa tutti i processi python +killall python + +# avvia MapoIob +/etc/init.d/MapoIOB start + +# log fatto! +DATE=`date +%Y-%m-%d_%T` +echo $DATE " - FINE pulizia processi python + riavvio MapoIOB" >> clean.log diff --git a/IOB-PI/vers3.x/convertLogFile.py b/IOB-PI/vers3.x/convertLogFile.py new file mode 100644 index 0000000..760c2a9 --- /dev/null +++ b/IOB-PI/vers3.x/convertLogFile.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# readFile v. 0.1 +# - single instance timer +# - invio multiplo x send eventi accodati +#--------------------------------------------------------------- +import os, sys +import argparse +#-------------------------------------------------------------- + +# gestione parser argomenti in input +parser = argparse.ArgumentParser() +parser.add_argument("inFile") +parser.add_argument("outFile") +args = parser.parse_args() + +#with open('logfile.txt', 'r') as inf, open('persMem.dat',"w") as outf: +with open(args.inFile, 'r') as inf, open(args.outFile,"w") as outf: + data = inf.readlines() + + lastDt = "" + lastMs = 0 + stepMs = 200 + + for line in data: + words = line.split() + if words[2] == 'queue': + # recupero dataOra + newDt = words[0].replace("-","") + words[1].replace(":","") + + # verifico se data/ora identica... + if (lastDt == newDt): + # --> aggiungo stepMs + lastMs += stepMs + else: + lastMs = 0 + + lastDt = newDt + + newDt = newDt + '{:03d}'.format(lastMs) #str(lastMs) + #print words[0].replace("-","") + words[1].replace(":","") + " | " + newDt + "\n" + + # print words + # outf.write(words[0].replace("-","") + words[1].replace(":","") + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n') + outf.write(newDt + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n') \ No newline at end of file diff --git a/IOB-PI/vers3.x/crontab b/IOB-PI/vers3.x/crontab new file mode 100644 index 0000000..74fe381 --- /dev/null +++ b/IOB-PI/vers3.x/crontab @@ -0,0 +1 @@ +* * * * * /bin/bash /home/pi/steamware/checkAlive.sh >> /home/pi/stdout 2>> /home/pi/stderr diff --git a/IOB-PI/vers3.x/install-RPI-IOB.sh b/IOB-PI/vers3.x/install-RPI-IOB.sh new file mode 100644 index 0000000..d521931 --- /dev/null +++ b/IOB-PI/vers3.x/install-RPI-IOB.sh @@ -0,0 +1,54 @@ +#|/bin/bash + +#installa il necessario per RPI-3-IOB partendo dal contenuto della folder /home/pi/steamware + +#step 1: creo file di log nuovi +rm /var/log/log*.txt +rm /var/log/MapoIOB* +rm /home/pi/steamware/log*.txt + +touch /var/log/logReboot.txt +touch /var/log/logTemp.txt +touch /var/log/MapoIOB.log + +ln -sf /var/log/logReboot.txt /home/pi/steamware/logReboot.txt +ln -sf /var/log/logTemp.txt /home/pi/steamware/logTemp.txt +ln -sf /var/log/MapoIOB.log /home/pi/steamware/logfile.txt + +chown pi:pi /home/pi -R +chmod 666 /var/log/log*.txt +chmod 666 /var/log/MapoIOB.log + +#step 2: copio files in /usr/local/bin +cd /home/pi/steamware +chmod +x *.sh +cp *.sh /usr/local/bin/ + +#step 3: copio files x logrotate... +cd /home/pi/steamware +cp MapoIOB_logrot /etc/logrotate.d/ + +# step 4: copio target systemd in avvio... +cp -f sendRebootIOB /etc/init.d/sendRebootIOB +cp -f sendRebootIOB.service /etc/systemd/system/sendRebootIOB.service +#echo "" +#echo "-----------------------------------------------" +#echo "Completare registrazione servizio avvio: digitare i seguenti comandi" +#echo "systemctl enable sendRebootIOB" +#echo "systemctl daemon-reload" +#echo "systemctl status sendRebootIOB" +#echo "-----------------------------------------------" +#echo "" + +# step 5: copio target MapoIOB in avvio... +cp -f MapoIOB /etc/init.d/MapoIOB +cp -f MapoIOB.service /etc/systemd/system/MapoIOB.service + + +#echo "" +#echo "" +#echo "-----------------------------------------------" +#echo "Infine creare voce crontab che salvi temperatura CPU/GPU ogni 20 minuti..." +#echo "crontab -e" +#echo "*/20 * * * * /usr/local/bin/saveTemp.sh" +#echo "-----------------------------------------------" diff --git a/IOB-PI/vers3.x/readFile.py b/IOB-PI/vers3.x/readFile.py new file mode 100644 index 0000000..887118d --- /dev/null +++ b/IOB-PI/vers3.x/readFile.py @@ -0,0 +1,152 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# readFile v. 0.1 +# - single instance timer +# - invio multiplo x send eventi accodati + +#--------------------------------------------------------------- + +import time + +from datetime import datetime + +import urllib +import ConfigParser +import os, sys + +import logging +import logging.handlers +import Queue + +import argparse +#-------------------------------------------------------------- + +# gestione parser argomenti in input +parser = argparse.ArgumentParser() +parser.add_argument("memFile") +parser.add_argument("logFile") +args = parser.parse_args() + +#definizione variabili BASE +stepQueuePut=25000 +stepQueueGet=250 +NMAXSEND=500000 # limite invio file x fare prove... +idxMacchina = "2003" + +#-------------------------------------------------------------- +# Gestione coda (condivisa) x registrazione eventi ed invio URL +#print "Creazione coda illimitata" +Coda = Queue.Queue(0) + +#--------------------------------------------------------------- +#Funzione di scrittura su coda con try-except + +def accoda(valore): + + try: + Coda.put(valore) + except Queue.Full: + logPro.error( "Queue full" + dtEve + '#' + value + '#' + cont ) + except: + logPro.error( "NETWORK:Errore http-no com rete-timeout" + url ) + + +#-------------------------------------------------------------- +# svuotaCoda x invio dati al server +def svuota_coda(): + + global NMAXSEND + + try: + if not Coda.empty(): + # invio SOLO i primi NMAXSEND eventi... SE minore del num eventi... + if NMAXSEND > Coda.qsize(): + NMAXSEND = Coda.qsize() + + + i = 0 + + with open(args.logFile,"w") as outf: + while i <= NMAXSEND: + if not Coda.empty(): + + # formatto dataOra corrente + dtCurr = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3] + + #prendo primo elemento dalla coda + resp = Coda.get() + + # recupero valori da elemento coda! + dtEve = resp.split("#")[0] + value = resp.split("#")[1] + cnt = resp.split("#")[2] + url = URLBASE + idxMacchina + URLADV1 + value + url = url + '&dtCurr=' + dtCurr + '&dtEve=' + dtEve + '&cnt=' + cnt + # CHIAMO URL + response3 = urllib.urlopen ( url ) + answ3 = response3.read() + + # registro chiamata + risposta + # outf.write(url + " --> " + answ3 + "\n") + + # incremento e controllo se mostrare output + i += 1 + if (i % stepQueueGet) == 0: + print "Inviati %d valori..." % i + + print "Inviati %d valori..." % i + except: + print "Errore in svuotamento coda!" + + +#--------------------------------------------------------------- +# MAIN + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'IOB.cfg' ) + + # NMAXSEND = config.getint ( 'time' , 'NMAXSEND' ) + # idxMacchina = config.get ( 'id' , 'idxMacchina' ) + + + URLBASE = config.get ( 'web' , 'URLBASE' ) + URLADV1 = config.get ( 'web' , 'URLADV1' ) + + LOGFILE = config.get ( 'log' , 'LOGFILE' ) + LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' ) +except: + print "\n\n" + PROGRAM_NAME + ' - Error 4 - in config file ' 'IOB.cfg' + sys.exit(1) + +#--------------------------------------------------------------- + +dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3] +print "Inizio elaborazione: %s" % dtCurr + +# Leggo il file! +i = 0 +with open(args.memFile, 'r') as inf, open(args.logFile,"w") as outf: + data = inf.readlines() + + print "Trovate %d da processare..." % len(data) + +# leggo e metto in QUEUE... + for line in data: + accoda(line) + i += 1 + if (i % stepQueuePut) == 0: + print "Accodati %d valori..." % i + +print "Completata lettura file! %d righe accodate da trasmettere" % Coda.qsize() + +dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3] +print "Inizio invio: %s" % dtCurr + + +# chiamo procedura x svuotare coda... +svuota_coda() + +dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3] +print "Completato invio: %s" % dtCurr \ No newline at end of file diff --git a/IOB-PI/vers3.x/readParallela.py b/IOB-PI/vers3.x/readParallela.py new file mode 100644 index 0000000..1b48912 --- /dev/null +++ b/IOB-PI/vers3.x/readParallela.py @@ -0,0 +1,435 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# readParallela v. 3.1.2 12 Ingressi +# - single instance timer +# - invio multiplo x send eventi accodati +# - gestione segnali BLINKING +# - gestione INVERSIONE segnali cv 10-VII-2018 +# - gestione FILTRAGGIO segnali brevi cv 23-VII-2018 +# - (2.3) gestione 12 bit cv 14-I-2020 +# - (2.4) fix ingressi e conf apertura parallela + gestione vari bit filtraggio x nuovi ingressi + update conf con 12 parametri bit SEL 15-I-2020 +# - (2.4.8) versione adatta a raspberry PI vecchia generazione (GPIO corto, 8bit) +# - (2.5) Fix (hope) ciclo "wait send to complete", gestione timeout (rety infinito se IO riparte in modo anomalo) +# - (2.5.1) Fix numero versione 18.05.2023 +# - (2.5.2) Fix gestione eccezioni con report dettagliato +# - (2.5.3) Fix gestione stringhe e print x python 3.11 in debian 12 / raspberry OS 2025 +# - (2.6.0) Aggiunto gestione Redis x code salvate ogni minuto e ricaricate all'avvio 2025.04.17 +# - (2.6.1) Cleanup generale vecchia queue post test vari +# - (2.6.2) Fix in global di to_retry in send_coda per evitare problemi +# - (3.0.0) Prima versione code-assisted: riformulazione e ottimizzazione globale programma +# - (3.1.2) Ottimizzazione gestione letture GPIO (sempre code-assisted) + + +import time +import sys +import os +import logging +import logging.handlers +import threading +import configparser +from datetime import datetime, timezone +from array import array + +import redis +import requests +import urllib3 + +# Disable urllib3 debug logging to keep application logs clean +urllib3.disable_warnings() +logging.getLogger("urllib3").setLevel(logging.WARNING) + +# Note: RPi.GPIO is imported inside the class or at runtime to prevent errors on non-Pi systems +try: + import RPi.GPIO as GPIO +except ImportError: + GPIO = None + +class ReadParallelaIOB: + def __init__(self, config_path='IOB.cfg'): + self.PROGRAM_NAME = "ReadPar IOB-pi v.3.1.2 (2026)" + self.MAXRETRY = 10 + self.MAX_COUNTER_BLINK = 10 + + # Configuration and State + self.config = configparser + + # Hardware Pin Maps + self._PINS_8 = [11, 12, 13, 15, 16, 18, 22, 7] + self._PINS_12 = [11, 12, 13, 15, 16, 18, 22, 7, 29, 31, 32, 36] + + # Default configuration (will be overwritten by load_config) + self.num_params = 12 + self.input_pins = self._PINS_12 + + # Internal State Arrays + self.i_counters = array('i', [0] * 12) + self.B_blinking = array('B', [0] * 12) + self.B_previous = array('B', [0] * 12) + self.B_input = array('B', [0] * 12) + self.B_output = array('B', [0] * 12) + self.B_inverting = array('B', [0] * 12) + self.B_filter = array('B', [0] * 12) + self.B_filter_prev = array('B', [0] * 12) + self.B_temp = array('B', [0] * 12) + self.i_filter_counters = array('i', [0] * 12) + + # Load configuration after arrays are initialized + self.load_config(config_path) + + # Control Variables + self.cont = 0 + self.onLine = '1' + self.sending = False + self.timer_busy = False + self.to_enable = False + self.to_short = self.TIMEOUTSHORT + self.to_long = self.TIMEOUTLONG + self.to_retry = self.MAXRETRY + + # Redis + self.CodaR = redis.Redis(host='localhost', port=6379, db=0, password='24068Seriate') + self.queue_name = 'IOB' + + # Logging + self.setup_logging() + + def load_config(self, path): + """ + Loads configuration parameters from the specified .cfg file. + Sets up timing, URL, logging, and bit-specific settings (blinking, inversion, filtering). + """ + config = configparser.RawConfigParser() + if not os.path.exists(path): + print(f"Error: Config file {path} not found.") + sys.exit(1) + config.read(path) + + # 1. Determine number of parameters + try: + val = config.getint('id', 'numParams', fallback=12) + if val in [8, 12]: + self.num_params = val + else: + self.num_params = 12 + except ValueError: + self.num_params = 12 + + # 2. Update hardware pins and arrays based on num_params + if self.num_params == 8: + self.input_pins = self._PINS_8 + else: + self.input_pins = self._PINS_12 + + self.i_counters = array('i', [0] * self.num_params) + self.B_blinking = array('B', [0] * self.num_params) + self.B_previous = array('B', [0] * self.num_params) + self.B_input = array('B', [0] * self.num_params) + self.B_output = array('B', [0] * self.num_params) + self.B_inverting = array('B', [0] * self.num_params) + self.B_filter = array('B', [0] * self.num_params) + self.B_filter_prev = array('B', [0] * self.num_params) + self.B_temp = array('B', [0] * self.num_params) + self.i_filter_counters = array('i', [0] * self.num_params) + + # 3. Load other parameters + self.idxMacchina = config.get('id', 'idxMacchina') + self.SAMPLETIME = config.getfloat('time', 'SAMPLETIME') + self.TIMEOUTSHORT = config.getfloat('time', 'TIMEOUTSHORT') + self.TIMEOUTLONG = config.getfloat('time', 'TIMEOUTLONG') + self.SENDURLTIME = config.getfloat('time', 'SENDURLTIME') + self.NMAXSEND = config.getint('time', 'NMAXSEND') + + self.URLBASE = config.get('web', 'URLBASE') + self.URLENABLED = config.get('web', 'URLENABLED') + self.URLALIVE = config.get('web', 'URLALIVE') + self.URLADV1 = config.get('web', 'URLADV1') + + self.LOGFILE = config.get('log', 'LOGFILE') + self.LOGLEVEL = config.get('log', 'LOGLEVEL') + + # 4. Load bit settings using loops + for i in range(self.num_params): + self.B_blinking[i] = config.getint('blink', f'bit{i}') + self.MAX_COUNTER_BLINK = config.getint('blink', 'MAX_COUNTER_BLINK') + + for i in range(self.num_params): + self.B_inverting[i] = config.getint('invert', f'bit{i}') + self.B_filter[i] = config.getint('filter', f'bit{i}') + self.MAX_COUNTER_FILTER = config.getint('filter', 'MAX_COUNTER_FILTER') + + def setup_logging(self): + """ + Configures the logging system. + """ + logging.basicConfig( + level=logging.DEBUG, + format='%(asctime)s %(name)-8s %(levelname)-8s %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + filename=self.LOGFILE, + filemode='a' + ) + self.logQue = logging.getLogger('queue') + self.logSnd = logging.getLogger('sendUrl') + self.logPro = logging.getLogger('program') + + def setup_gpio(self): + """ + Initializes the GPIO pins for input. + """ + if GPIO is None: + self.logPro.error("GPIO library not found. Are you on a Raspberry Pi?") + sys.exit(1) + try: + GPIO.setmode(GPIO.BOARD) + GPIO.setwarnings(False) + for pin in self.input_pins: + GPIO.setup(pin, GPIO.IN) + self.logPro.info("GPIO initialized successfully.") + except Exception as e: + self.logPro.error(f"GPIO Setup Error: {e}") + sys.exit(1) + + def rqEnqueue(self, item): + """ + Adds an item to the Redis queue. + """ + self.CodaR.rpush(self.queue_name, item) + + def rqDequeue(self): + """ + Removes and returns an item from the Redis queue. + """ + item = self.CodaR.lpop(self.queue_name) + return item.decode('utf-8') if item else None + + def rqLen(self): + """ + Returns the current length of the Redis queue. + """ + return self.CodaR.llen(self.queue_name) + + def readParallelaFiltrata(self): + """ + Performs the core logic: reads GPIO, applies inversion, filtering, + and blinking, then reconstructs the value as a hex string. + """ + try: + # 1. Efficient GPIO Read + # Using a local reference for speed in loops + gpio_input = GPIO.input + pins = self.input_pins + inverting = self.B_inverting + input_arr = self.B_input + + for i in range(self.num_params): + # Read and invert logic immediately if required + raw_val = 0 if gpio_input(pins[i]) else 1 + if inverting[i]: + raw_val = 1 - raw_val + input_arr[i] = raw_val + + # 2. Processing Loop (Filtering & Blinking) + # Pre-caching references to reduce attribute lookups in tight loops + filter_arr = self.B_filter + filter_prev = self.B_filter_prev + filter_counters = self.i_filter_counters + max_filter = self.MAX_COUNTER_FILTER + + blinking = self.B_blinking + previous = self.B_previous + output_arr = self.B_output + blink_counters = self.i_counters + + for i in range(self.num_params): + # Debounce / Filter logic + if filter_arr[i]: + curr_in = input_arr[i] + prev_in = filter_prev[i] + + if curr_in != prev_in: + # State change detected + if curr_in == 1: + filter_counters[i] = max_filter if filter_counters[i] == 0 else 0 + self.B_temp[i] = 0 if filter_counters[i] == max_filter else 1 + else: + filter_counters[i] = max_filter if filter_counters[i] == 0 else 0 + self.B_temp[i] = 1 if filter_counters[i] == max_filter else 0 + + filter_prev[i] = curr_in + input_arr[i] = self.B_temp[i] + else: + # No state change, maintain or decrement counter + if filter_counters[i] > 0: + filter_counters[i] -= 1 + self.B_temp[i] = 0 if curr_in == 1 else 1 + else: + self.B_temp[i] = 1 if curr_in == 1 else 0 + + # Update the actual input array with the filtered value + input_arr[i] = self.B_temp[i] + + # Blinking Logic + if blinking[i] == 0: + output_arr[i] = input_arr[i] + else: + if previous[i] != input_arr[i]: + previous[i] = input_arr[i] + if input_arr[i] == 1: + output_arr[i] = 1 + blink_counters[i] = self.MAX_COUNTER_BLINK + else: + if input_arr[i] == 0 and blink_counters[i] > 0: + blink_counters[i] -= 1 + if blink_counters[i] == 0: + output_arr[i] = 0 + + # 3. Optimized Bitwise Reconstruction + new_value = 0 + for i in range(self.num_params): + if output_arr[i]: + new_value |= (1 << i) + + if self.num_params == 8: + return f"{new_value:02X}" + else: + # For 12 bits, we want to ensure we don't have leading 0s if not needed, + # but the user's log showed F83, which is a 3-digit hex. + # hex(new_value)[2:].upper() is fine. + return hex(new_value)[2:].upper() + + except Exception as e: + self.logPro.error(f"Error in readParallelaFiltrata: {e}") + return '' + + def accoda(self, value): + try: + dt_eve = datetime.now(timezone.utc).strftime('%Y%m%d%H%M%S%f')[:-3] + self.rqEnqueue(f"{dt_eve}#{value}#{self.cont}") + except Exception as e: + self.logPro.error(f"QUEUE ERROR: {e}") + + def svuotaCoda(self): + if self.timer_busy: + return + + self.timer_busy = True + try: + if self.rqLen() > 0: + # Check connectivity using requests + try: + res_alive = requests.get(self.URLALIVE, timeout=5) + if res_alive.text == 'OK': + res_enabled = requests.get(self.URLENABLED + self.idxMacchina, timeout=5) + if res_enabled.text == 'OK': + if self.onLine == '0': + self.logPro.info("IOB ONLINE!") + self.onLine = '1' + else: + self.onLine = '0' + else: + self.onLine = '0' + except Exception as e: + self.logPro.error(f"Server Connection Error: {e}") + self.onLine = '0' + + if self.onLine == '1' and not self.sending: + self.sending = True + for _ in range(self.NMAXSEND): + if self.rqLen() == 0: + break + + resp = self.rqDequeue() + if not resp: break + + parts = resp.split("#") + dt_eve, val, cnt = parts[0], parts[1], parts[2] + dt_curr = datetime.now(timezone.utc).strftime('%Y%m%d%H%M%S%f')[:-3] + + url = f"{self.URLBASE}{self.idxMacchina}{self.URLADV1}{val}&dtCurr={dt_curr}&dtEve={dt_eve}&cnt={cnt}" + + try: + r = requests.get(url, timeout=5) + self.logSnd.info(f"{val} [{cnt}] R:{r.text}") + except Exception as e: + self.logSnd.error(f"Send Error: {e}") + + self.sending = False + elif self.sending: + if self.to_retry > 0: + self.to_retry -= 1 + self.logPro.info("WAIT active send to complete") + else: + self.sending = False + self.to_retry = self.MAXRETRY + self.logPro.info("END WAIT, reset to_retry") + except Exception as e: + self.logPro.error(f"svuotaCoda Error: {e}") + finally: + self.timer_busy = False + + def run(self): + """ + Starts the main execution loop: + 1. Initializes GPIO. + 2. Spawns a background daemon thread to empty the Redis queue. + 3. Enters a loop to sample GPIO inputs, apply filters/blinking, and queue changes. + """ + self.logPro.info("-----------------------------") + self.logPro.info(self.PROGRAM_NAME) + self.logPro.info("-----------------------------") + + self.setup_gpio() + + # Start background thread for queue emptying + def timer_worker(): + while True: + self.svuotaCoda() + time.sleep(self.SENDURLTIME) + + threading.Thread(target=timer_worker, daemon=True).start() + + old_value = '' + self.logPro.info("Starting main loop") + + while True: + try: + time.sleep(self.SAMPLETIME) + value = self.readParallelaFiltrata() + + if value != '': + if value != old_value: + self.logQue.info(f"{value} [{self.cont}]") + self.accoda(value) + self.cont = (self.cont + 1) % 10000 + + self.to_enable = True + self.to_short = self.TIMEOUTSHORT + self.to_long = self.TIMEOUTLONG + old_value = value + + # Handle Timeouts + if self.to_enable: + self.to_short -= self.SAMPLETIME + if self.to_short <= 0: + self.logQue.info(f">{value} [{self.cont}]") + self.accoda(value) + self.to_short = self.TIMEOUTSHORT + self.to_enable = False + self.to_long = self.TIMEOUTLONG + + self.to_long -= self.SAMPLETIME + if self.to_long <= 0: + self.logQue.info(f">>{value} [{self.cont}]") + self.accoda(value) + self.to_long = self.TIMEOUTLONG + + except KeyboardInterrupt: + self.logPro.info("Keyboard interrupt received. Exiting...") + break + except Exception as e: + self.logPro.error(f"Main loop error: {e}") + +if __name__ == "__main__": + app = ReadParallelaIOB() + app.run() diff --git a/IOB-PI/vers3.x/readSeriale.py b/IOB-PI/vers3.x/readSeriale.py new file mode 100644 index 0000000..3c00644 --- /dev/null +++ b/IOB-PI/vers3.x/readSeriale.py @@ -0,0 +1,363 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +#--------------------------------------------------------------- + +import serial +import time +import sys +import datetime +import urllib +import ConfigParser +import os, sys + +#--------------------------------------------------------------- + +# COSTANTI +MSGLEN = 9 +TIMEOUTSERIALE = 10 +MAXRETRY = 3 + +# DA FILE CONF +idxMacchina = "2001" +SAMPLETIME = 0.1 +TIMEOUTSHORT = (SAMPLETIME*20) +TIMEOUTLONG = (SAMPLETIME*600) + +# VAR +to_enable = False +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG +to_serial = TIMEOUTSERIALE +to_retry = MAXRETRY +errormsglen = 0 + +#--------------------------------------------------------------- +# classe logger + +class Logger: + def __init__(self, filename): + try: + self.filename = filename + except: + logga("LOGGER: errore try su self.filename") + sys.exit(1) + def __call__(self, string): + try: + file = open(self.filename, 'a') + file.write('[' + time.strftime("%Y-%m-%d %H:%M:%S") + '] ') + file.write(string + '\n') + file.close() + except: + logga("LOGGER: errore try su scrittura") + sys.exit(1) + +#--------------------------------------------------------------- +# lettura buffer seriale e pulizia caratteri non stampabili +# ritorna '' se non c'è un messaggio buono o il messaggio pulito ( due bytes hex ) +# il messaggio ha il formato xxi00 00xxx + +def readSeriale(): + + global to_serial + global to_retry + global errormsglen + + ret = '' + current = '' + i = 0 + + # ritorna '' se non ci sono abbastanza caratteri + try: + if ser.inWaiting() < MSGLEN : +# +# to_serial = to_serial - 1 # se non mi risponde, faccio un ' altra richiesta.... +# if to_serial <= 0: +# try: +# requestData () +# except: +# logga("SERIALE: errore su requestData") +# sys.exit(1) +# to_serial = TIMEOUTSERIALE # ripristino timer +# to_retry = to_retry - 1 # contatore retry +# if to_retry <= 0: +# logga ( 'IOB not responding' ) +# return ret + logga("SERIALE: errore msglen < 9 char - Errore no. " + str(errormsglen)) + errormsglen = errormsglen +1 + avviaSeriale() + time.sleep(.2) + if errormsglen > 30: + sys.exit(1) + except: + if startstatus == 0: + logga ("Porta SERIALE non disponibile - ser.inWaiting error - exit... - Errore no. " + str(errormsglen)) + errormsglen = errormsglen +1 + avviaSeriale() + time.sleep(.2) + if errormsglen > 30: + sys.exit(1) + + # finchè c'è robba .. leggi e tieni i buoni + to_serial = TIMEOUTSERIALE + to_retry = MAXRETRY + try: + while ser.inWaiting() > 0 : + try: + c = ser.read(1) + except: + logga("SERIALE: errore su try ser.read") + sys.exit(1) + # filtra caratteri non stampabili + if c > ' ' : + current += c + #sys.stdout.write(current + '<<<<\n') + # ora il messaggio ha il formato xxxxxi00 00xxx : cerco la 'i' iniziale + try: + while i < len(current) and current[i] != 'i': + i = i + 1 + except: + logga("SERIALE: errore su ricerca i iniziale") + sys.exit(1) + # se non ho trovato la 'i' restituisco '' + if i == len(current)-1: + return ret + else: + current = current[i+1:i+3] + # richiesta dati ad IOB + requestData() + #sys.stdout.write ( current + '\n') + except: + if startstatus == 0: + logga ('Porta SERIALE non disponibile - ser.inWaiting e filtraggio error...exit') + sys.exit(1) + return current +#--------------------------------------------------------------- +# richiesta dati ad IOB : scrittura su seriale + +def requestData (): + try : + ser.write ("$i" + '\r\n') + ser.flush() + except : + if startstatus == 0: + logga ( "SERIAL: Errore di scrittura/flush") + + +#--------------------------------------------------------------- +#Funzione di scrittura su url con try-except + +def chiamaUrl(): + try: + url = URLBASE + idxMacchina + URLADV1 + value + urllib.urlopen ( url ) + except: + logga ( "NETWORK:Errore http-no com rete-timeout" + url ) + + +#--------------------------------------------------------------- +# Funzione che verifica possibilità di creare log e include testo corrente + +def logga(message) : + try: + log(message) + except : + pass + +#--------------------------------------------------------------- + + +def avviaSeriale(): + global ser + + try: + ser = serial.Serial( + port = comm_port , + baudrate = 9600 , + parity = serial.PARITY_NONE , + stopbits = serial.STOPBITS_ONE , + bytesize = serial.EIGHTBITS + ) + startstatus = 0 + except serial.serialutil.SerialException , e : + try: + if startstatus == 0: + logga ( "SERIAL:Errore apertura seriale - " + comm_port) + except: + pass + sys.stdout.write ( '\nErrore apertura seriale\n\n%s\n\n' % e ) + if errormsglen > 30: + sys.exit (1) + +#--------------------------------------------------------------- +#--------------------------------------------------------------- +# MAIN + +try: + config = ConfigParser.RawConfigParser() + config.read ( 'readSeriale.cfg' ) + + SAMPLETIME = config.getfloat ( 'time' , 'SAMPLETIME' ) + TIMEOUTSHORT = config.getfloat ( 'time' , 'TIMEOUTSHORT' ) + TIMEOUTLONG = config.getfloat ( 'time' , 'TIMEOUTLONG' ) + + idxMacchina = config.get ( 'id' , 'idxMacchina' ) + comm_port = config.get ( 'comm' , 'port' ) + + URLBASE = config.get ( 'web' , 'URLBASE' ) + URLADV1 = config.get ( 'web' , 'URLADV1' ) + + LOGFILE = config.get ( 'log' , 'LOGFILE' ) + LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' ) +except: + sys.exit(1) + +# oggetto Logger +try: + log = Logger(LOGFILE) +except: + # manda mail o simili - FARE!!! + print "LOG: Impossibile creare file log con nome " + print (LOGFILE) + +print '\n\n Read seriale IOB v.0.2 !!!!\n' + +global startstatus +startstatus = 1 + +if startstatus == 1: + logga("Avvio Programma") + +# Verifica l'OS e di conseguenza carica il file relativo con metodo di lockfile appropriato + check singola istanza +if os.name == 'posix': + import unix +else: + import win + +logga ( "Start Read seriale IOB v.0.2") + + +# lettura file configurazione + +# [comm] +# port = /dev/ttyS0 +# [id] +# idxMacchina = 2001 +# [time] +# SAMPLETIME = 0.1 +# TIMEOUTSHORT = 200 +# TIMEOUTLONG = 6000 + +print ( ' comm_port = %s' % ( comm_port ) ) +print ( ' idxMacchina = %s' % ( idxMacchina ) ) +print ( ' SAMPLETIME = %4.2f' % ( SAMPLETIME ) ) +print ( ' TIMEOUTSHORT = %4.2f' % ( TIMEOUTSHORT ) ) +print ( ' TIMEOUTLONG = %4.2f' % ( TIMEOUTLONG ) ) +print ( ' URLBASE = %s' % ( URLBASE ) ) +print ( ' URLADV1 = %s' % ( URLADV1 ) ) +print ( ' LOGFILE = %s' % ( LOGFILE ) ) +print ( ' LOGLEVEL = %s' % ( LOGLEVEL ) ) + +# -sys.stdout.write ( 'idxMacchina ?' + idxMacchina + '\n') + +to_short = TIMEOUTSHORT +to_long = TIMEOUTLONG + + + +#-------------------------------------------------------------- + + +#--------------------------------------------------------------- +# apertura seriale + +avviaSeriale() + +#try: +# ser = serial.Serial( +# port = comm_port , +# baudrate = 9600 , +# parity = serial.PARITY_NONE , +# stopbits = serial.STOPBITS_ONE , +# bytesize = serial.EIGHTBITS +# ) +# print "Initialized!" +#except serial.serialutil.SerialException , e : +# try: +# logga ( "SERIAL:Errore apertura seriale - " + comm_port) +# except: +# pass +# sys.stdout.write ( '\nErrore apertura seriale\n\n%s\n\n' % e ) +# sys.exit (1) + +#--------------------------------------------------------------- +# ciclo forever and ever + +old = '' + +# richiesta dati ad IOB +try: + requestData() +except: + logga("SERIALE: errore sul try di requestData") + sys.exit(1) + + +while 1: + try: + time.sleep (SAMPLETIME) + except: + logga("SERIALE_SLEEP: errore attesa sampletime") + # lettura dati da IOB + try: + value = readSeriale() + except: + if startstatus == 0: + logga("errore PRIMA LETTURA SERIALE") + sys.exit(1) + if ( value != '' ) : + if value != old : + #loggo e invio dati + try: + logga ( value ) + errormsglen = 0 + chiamaUrl() + except: + logga("URLBROWSER: errore registrazione valore e chiamaUrl") + pass + #enable e reset timer + to_enable = True + to_short = TIMEOUTSHORT + to_long = TIMEOUTLONG + + old = value + + + # gestione timeout breve + if ( to_enable ) : + to_short = to_short - SAMPLETIME + if to_short <= 0: + #loggo e invio dati + try: + logga ( '>' + value ) + errormsglen = 0 + chiamaUrl() + except: + pass + to_short = TIMEOUTSHORT + to_enable = False # dopo un colpo il timer breve viene disabilitato + to_long = TIMEOUTLONG + + # gestione timeout lungo + to_long = to_long - SAMPLETIME + if to_long <= 0: + #loggo e invio dati + try: + logga ( '>>' + value ) + errormsglen = 0 + chiamaUrl() + except: + pass + to_long = TIMEOUTLONG + + diff --git a/IOB-PI/vers3.x/saveTemp.sh b/IOB-PI/vers3.x/saveTemp.sh new file mode 100644 index 0000000..a2cd2be --- /dev/null +++ b/IOB-PI/vers3.x/saveTemp.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +#salva la temperatura CPU e GPU su chiamata... + +# imposto logfile... +logFile="/var/log/logTemp.txt" + +cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp) +cpuTemp1=$(($cpuTemp0/1000)) +cpuTemp2=$(($cpuTemp0/100)) +cpuTempM=$(($cpuTemp2 % $cpuTemp1)) + +gpuTemp=`vcgencmd measure_temp` + +loadAvg=`cat /proc/loadavg` + +echo "$(date) | CPU: temp=$cpuTemp1.$cpuTempM ºC | GPU: $gpuTemp | LoadAvg: $loadAvg" >> $logFile diff --git a/IOB-PI/vers3.x/sendReboot.py b/IOB-PI/vers3.x/sendReboot.py new file mode 100644 index 0000000..85bdc34 --- /dev/null +++ b/IOB-PI/vers3.x/sendReboot.py @@ -0,0 +1,138 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# sendReboot v. 1.8 +# - (2.5.2) Fix gestione eccezioni con report dettagliato +#--------------------------------------------------------------- + + +import time +import sys + + +from datetime import datetime + +#import urllib +#import ConfigParser +import urllib.request +import configparser +import os, sys + +import logging + +import time + +#--------------------------------------------------------------- + +# COSTANTI +SR_PROG_NAME = "SendReboot IOB-pi v.2.5.2" + +# DA FILE CONF +idxMacchina = "99" + +# registro se ho fatto chiamata +global numTry +numTry = 1 + + +#--------------------------------------------------------------- +#Funzione di scrittura su url con try-except +#--------------------------------------------------------------- + +def chiamaUrl(numTry): + + try: + urllib.request.urlopen ( url ) + numTry = numTry + 10 + + except Exception as e: + print("Errore in chiamaUrl") + print(str(e)) + logging.info ( str(e) ) + + print("Url chiamato: " , url) + return numTry + + +#--------------------------------------------------------------- +# Funzione di recupero mac address per poterlo inviare a MPIO +#--------------------------------------------------------------- +def getMAC(interface): + # Return the MAC address of interface + try: + str = open('/sys/class/net/' + interface + '/address').read() + except: + str = "00:00:00:00:00:00" + return str[0:17] + +#--------------------------------------------------------------- +# MAIN +#--------------------------------------------------------------- + +try: + #config = ConfigParser.RawConfigParser() + config = configparser.RawConfigParser() + config.read ( 'IOB.cfg' ) + + idxMacchina = config.get ( 'id' , 'idxMacchina' ) + + + URLREBO = config.get ( 'web' , 'URLREBO' ) + + LOGFILE = config.get ( 'log' , 'LOGREBO' ) +except Exception as e: + print("\n\n" + SR_PROG_NAME + ' - Error 4 - in config file ' 'IOB.cfg') + print(str(e)) + sys.exit(1) + + +#-------------------------------------------- +# oggetto Logger +#-------------------------------------------- +try: +# log = Logger(LOGFILE) + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(name)-8s %(levelname)-8s %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + filename=LOGFILE, + filemode='a') + +except Exception as e: + # manda mail o simili - FARE!!! + print("LOG: Impossibile creare file log con nome ") + print(LOGFILE) + print(str(e)) +#-------------------------------------------- + + +print("\n\n" + SR_PROG_NAME + "\n\n") + +global startstatus +startstatus = 1 + +if startstatus == 1: + logging.info("Avvio Programma " + SR_PROG_NAME) + + +# lettura file configurazione +print ( ' idxMacchina = %s' % ( idxMacchina ) ) +print ( ' URLREBO = %s' % ( URLREBO ) ) +print ( ' LOGFILE = %s' % ( LOGFILE ) ) + +# lettura mac address +myMac = getMAC('eth0') +print ( ' MAC Address = %s' % ( myMac ) ) + +# configuro URL da inviare +url = URLREBO + idxMacchina + "&mac=" + myMac + +# modifica: cerco se ho inviato segnale altrimenti ritento invio... +while (numTry < 11): + logging.info("Tentativo invio URL: $numTry" ) + numTry = chiamaUrl(numTry) + time.sleep(3) + numTry = numTry + 1 + + +# registro che ho inviato! +logging.info("Inviato segnale di reboot!: " + url ) diff --git a/IOB-PI/vers3.x/sendRebootIOB b/IOB-PI/vers3.x/sendRebootIOB new file mode 100644 index 0000000..191bfff --- /dev/null +++ b/IOB-PI/vers3.x/sendRebootIOB @@ -0,0 +1,33 @@ +#!/bin/sh - +# +### BEGIN INIT INFO +# Provides: sendReboot +# Required-Start: $network $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Steamware's IOB reboot signal +# Description: Steamware's sendReboot segnalazione reboot dispositivo +### END INIT INFO + +#! /bin/sh +# /etc/init.d/sendReboot + + + +export HOME +case "$1" in + start) + cd /home/pi/steamware + echo "Starting sendReboot" + /usr/bin/python ./sendReboot.py 2>&1 & + echo "Verifica Rete e file IOB" + /usr/local/bin/setIobConf.sh + ;; + *) + echo "Usage: /etc/init.d/sendReboot {start}" + exit 1 + ;; +esac +exit 0 + diff --git a/IOB-PI/vers3.x/sendRebootIOB.service b/IOB-PI/vers3.x/sendRebootIOB.service new file mode 100644 index 0000000..48e3690 --- /dev/null +++ b/IOB-PI/vers3.x/sendRebootIOB.service @@ -0,0 +1,22 @@ +[Unit] +SourcePath=/etc/init.d/sendRebootIOB +Description=LSB: Steamware's IOB reboot signal +Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target +Wants=network-online.target +After=network.target network-online.target auditd.service +Conflicts=shutdown.target + +[Service] +Type=forking +Restart=no +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=yes +SysVStartPriority=2 +ExecStart=/etc/init.d/sendRebootIOB start +ExecStop=/etc/init.d/sendRebootIOB stop + +[Install] +WantedBy=multi-user.target diff --git a/IOB-PI/vers3.x/setIobConf.sh b/IOB-PI/vers3.x/setIobConf.sh new file mode 100644 index 0000000..30b4781 --- /dev/null +++ b/IOB-PI/vers3.x/setIobConf.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# verifico se sia rete donati o rete steamware o offline... +netStatus=`cat /sys/class/net/eth0/operstate` +iaddr=`ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1` + +cd /home/pi/steamware + +if [[ $netStatus != "up" ]] +then + echo "Siamo Offline, pagina demo!" +elif [[ $iaddr == "10.74.82"* ]] +then + cp IOB.cfg.steamware IOB.cfg -f + echo "Siamo in Steamware!" +elif [[ $iaddr == "192.168.51"* ]] +then + cp IOB.cfg.donati IOB.cfg -f + echo "Siamo a Passirano!" +else + echo "Siamo altrove, pagina demo!" +fi + +echo "$iaddr" + +chown pi:pi * \ No newline at end of file diff --git a/IOB-PI/vers3.x/testRedis.py b/IOB-PI/vers3.x/testRedis.py new file mode 100644 index 0000000..7c843c4 --- /dev/null +++ b/IOB-PI/vers3.x/testRedis.py @@ -0,0 +1,48 @@ +import redis +import time + +CodaR = redis.Redis(host='localhost', port=6379, db=0, password='24068Seriate') +queue_name='IOB' + +#----------------------------------- +# Gestione code REDIS +# per sostituzione 1:1 con coda in ram + +# Function to add an item to the queue (enqueue) +def enqueue(item): + CodaR.rpush(queue_name, item) + print(f"Enqueued: {item}") + +# Function to remove an item from the queue (dequeue) +def dequeue(): + item = CodaR.lpop(queue_name) + if item: + print(f"Dequeued: {item.decode('utf-8')}") + return item.decode('utf-8') + else: + print("Queue is empty") + +# Function to count queue actual lenght in Redis +def rqlen(): + clen = CodaR.llen(queue_name) + if clen: + print(f"Queue len: {clen}") + return clen + else: + print("Queue is empty") + return 0 + + +lung = rqlen() +print ("queue lenght: "+str(lung)) + +enqueue('prova1') +enqueue('prova2') +enqueue('prova3') + +time.sleep(5) + +lung = rqlen() +while lung > 0: + dequeue() + lung = rqlen() diff --git a/IOB-PI/vers3.x/unix.py b/IOB-PI/vers3.x/unix.py new file mode 100644 index 0000000..014267e --- /dev/null +++ b/IOB-PI/vers3.x/unix.py @@ -0,0 +1,31 @@ +import fcntl +import os +import logging + +#--------------------------------------------------------------- +# meccanismo di file lock per evitare multiple instances +# The function will try to lock the file specified , if it success, return True, else return False. +# The nice thing is that the lock will be dropped when the program terminates. +# >>>Use : +# if not lockFile(".lock.pod"): +# sys.exit(0) + +def lockFile ( lockfile ) : + + fd = os.open ( lockfile , os.O_CREAT | os.O_TRUNC | os.O_WRONLY ) + try: + # Request exclusive (EX) non-blocking (NB) advisory lock. + fcntl.lockf ( fd , fcntl.LOCK_EX | fcntl.LOCK_NB ) + except IOError: + return False + + return True + +if not lockFile ( ".lockfile" ) : + print('\n noi non siamo soli ...\n') + logging.error( "LOCK: Piu istanze aperte") + #sys.exit ( 0 ) + +#- print '\n running alone ...\n' + + diff --git a/IOB-PI/vers3.x/unix.pyc b/IOB-PI/vers3.x/unix.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f528212e734a67eb0c5153f80c50aace6d1f362a GIT binary patch literal 669 zcma)3%Wl&^6g_urw~d>yU+>A9OYr`N%@ph^{s}cOyT^nX-Q@*l0+qlI zZU`U)Q~_=XCPx+G-H{Yng{UHzqsEV#q&qxT{o$3*iJ_y5*oJI|Szv(`;rbsCJ`6B$ z*${&pf$xN?1K0?w9bA(KyWa2lGMzS$5!wzeVzeh9A{%3JX7@2k9bcYy9f_mW#)fX& z$j0t67@rS|(c9@Qo)#zh(C+#CX)(@^KQSk;m^ZfesMhm~g>OC{4?mob&K__+@c8|B z)V8|y-G^mur01KqTbVk3Kip4Iwe&YyR4M1-oq5Kn|3$B5f1~=w%5wd+Y-NAjsLO0~ zb$|Gf5BIp$I9(9WDG&$Lqez$z$JyO{^OU1FX|!T%5~IqsPK>Tql4V(Jo^aL4c#(Wm z+e8^#Hs54YZe(j^>U0<0F@Tp=>*Z24%i@tsxRP{AA8!BO5?-!#wXNkV_cmTam-vf2 I`(29YFVCEWI{*Lx literal 0 HcmV?d00001 diff --git a/IOB-PI/vers3.x/update-RPI-IOB.sh b/IOB-PI/vers3.x/update-RPI-IOB.sh new file mode 100644 index 0000000..d521931 --- /dev/null +++ b/IOB-PI/vers3.x/update-RPI-IOB.sh @@ -0,0 +1,54 @@ +#|/bin/bash + +#installa il necessario per RPI-3-IOB partendo dal contenuto della folder /home/pi/steamware + +#step 1: creo file di log nuovi +rm /var/log/log*.txt +rm /var/log/MapoIOB* +rm /home/pi/steamware/log*.txt + +touch /var/log/logReboot.txt +touch /var/log/logTemp.txt +touch /var/log/MapoIOB.log + +ln -sf /var/log/logReboot.txt /home/pi/steamware/logReboot.txt +ln -sf /var/log/logTemp.txt /home/pi/steamware/logTemp.txt +ln -sf /var/log/MapoIOB.log /home/pi/steamware/logfile.txt + +chown pi:pi /home/pi -R +chmod 666 /var/log/log*.txt +chmod 666 /var/log/MapoIOB.log + +#step 2: copio files in /usr/local/bin +cd /home/pi/steamware +chmod +x *.sh +cp *.sh /usr/local/bin/ + +#step 3: copio files x logrotate... +cd /home/pi/steamware +cp MapoIOB_logrot /etc/logrotate.d/ + +# step 4: copio target systemd in avvio... +cp -f sendRebootIOB /etc/init.d/sendRebootIOB +cp -f sendRebootIOB.service /etc/systemd/system/sendRebootIOB.service +#echo "" +#echo "-----------------------------------------------" +#echo "Completare registrazione servizio avvio: digitare i seguenti comandi" +#echo "systemctl enable sendRebootIOB" +#echo "systemctl daemon-reload" +#echo "systemctl status sendRebootIOB" +#echo "-----------------------------------------------" +#echo "" + +# step 5: copio target MapoIOB in avvio... +cp -f MapoIOB /etc/init.d/MapoIOB +cp -f MapoIOB.service /etc/systemd/system/MapoIOB.service + + +#echo "" +#echo "" +#echo "-----------------------------------------------" +#echo "Infine creare voce crontab che salvi temperatura CPU/GPU ogni 20 minuti..." +#echo "crontab -e" +#echo "*/20 * * * * /usr/local/bin/saveTemp.sh" +#echo "-----------------------------------------------" diff --git a/IOB-PI/vers3.x/win.py b/IOB-PI/vers3.x/win.py new file mode 100644 index 0000000..f679f60 --- /dev/null +++ b/IOB-PI/vers3.x/win.py @@ -0,0 +1,32 @@ +import win32api +print " Running on WINDOWS\n" +import os +#--------------------------------------------------------------- +# meccanismo di file lock per evitare multiple instances +# The function will try to lock the file specified , if it success, return True, else return False. +# The nice thing is that the lock will be dropped when the program terminates. +# >>>Use : +# if not lockFile(".lock.pod"): +# sys.exit(0) + +def lockFile ( lockfile ) : + try: + fd = os.open ( lockfile , os.O_CREAT | os.O_TRUNC | os.O_WRONLY ) + except: + logga("Errore nel file WIN.PY per FD") + try: + # Request exclusive (EX) non-blocking (NB) advisory lock. + #fcntl.lockf ( fd , fcntl.LOCK_EX | fcntl.LOCK_NB ) + print " Dummy Method! Completa Lockfile\n" + except IOError: + return False + + return True +try: + if not lockFile ( ".lockfile" ) : + print '\n noi non siamo soli ...\n' + logga ( "LOCK: Piu istanze aperte") + sys.exit ( 0 ) +except: + logga("if not lockfile NON RIUSCITO in file WIN.PY") + sys.exit(1)