Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 10cf8968c75acd6e8392b82c7571b5fe066c73f9 Olli Jarva committed Nov 7, 2011

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,35 @@
+__ License __
+
+This bunch of files is licensed with GNU GPLv3. See LICENSE.txt for details.
+
+Some parts of it are not covered by GPL. Files and parts of files that are not include text claiming that.
+
+__ Credits __
+
+- Software is mainly put together by Henri Holopainen.
+- Physical installation was done by Olli Jarva and Hanno Nevanlinna
+- Bus/taxi screen layout was done by Iiro Isotalo and Timo Sulanne
+
+__ Background __
+
+In Futurice Ltd Helsinki office lobby we have taxi post with large button for ordering taxi to front door.
+That system was built and programmed before our annual party, so it's a quick hack. It's not production
+ready software.
+
+__ Quick HOWTO __
+
+Read all the code. It won't run without modifications. At least API keys and serial ports must be changed.
+
+1) Connect button to Arduino, upload button.pde from arduino subdirectory.
+2) Install kannel
+3) Install mobile broadband USB stick
+4) Edit kannel.conf and taxi-daemon.py
+5) Start taxi-daemon.py
+6) (Re)start kannel
+7) Install apache2 and php5 module for apache2
+8) Edit var/www/bus_display/script.js and index.html. At least API keys for weatherbug and HSL are missing. Add your own logo.
+9) Start chrome with parameter --no-web-security and open var/www/bus_display/
+10) Debug.
+
+Feel free to contact <olli.jarva@futurice.com> if you have some problems. I'll try to answer, but I
+can't make any promises on that matter.
@@ -0,0 +1,40 @@
+/*
+License:
+ This file is part of Futurice Taxi Button package.
+
+ Futurice Taxi Button is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 3 as published by
+ the Free Software Foundation.
+
+ Futurice Taxi Button is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Futurice Taxi Button. If not, see <http://www.gnu.org/licenses/>.
+
+Readme:
+ Upload this to your Arduino, assuming you connected button to analog 0. Otherwise,
+ remember to change sensorPin variable below.
+ For connecting button to Arduino, check out
+ http://www.arduino.cc/en/Tutorial/Button
+
+ Please note that in Arduino tutorial, button is connected to digital 2.
+*/
+
+int sensorPin = A0;
+int sensorValue = 0;
+
+void setup() {
+ Serial.begin(9600);
+}
+
+void loop() {
+ // read the value from the button:
+ sensorValue = analogRead(sensorPin);
+ if (sensorValue > 500) {
+ Serial.println(".");
+ }
+ delay(50);
+}
@@ -0,0 +1,49 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: taxi
+# Required-Start: $kannel
+# Should-Start: $local_fs $network
+# Should-Stop: $local_fs $network
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Taxi button python daemon
+# Description: Python daemon to read COM-port through USB and react to button pushes
+### END INIT INFO
+
+. /lib/lsb/init-functions
+
+TAXI=/usr/local/bin
+
+PATH=$TAXI:$PATH
+
+case "$1" in
+ start)
+ log_daemon_msg "Starting TAXI daemon"
+ taxi-daemon.py start
+ log_end_msg 0
+ ;;
+
+ stop)
+ log_daemon_msg "Stopping TAXI daemon"
+ taxi-daemon.py stop
+ log_end_msg 0
+ ;;
+
+ reload)
+ log_daemon_msg "Restarting TAXI daemon"
+ taxi-daemon.py restart
+ log_end_msg 0
+ exit 1
+ ;;
+
+ restart|force-reload)
+ $0 reload
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop|restart|force-reload}"
+ exit 1
+
+esac
+
+exit 0
@@ -0,0 +1,54 @@
+# What to do?
+# - change "my-number"
+# - change "password". Remember to change same password to "incoming.php"
+# - if necessary, change "get-url"
+# - disable PIN questioning from SIM card with mobile phone
+# - add call forwarding to switchboard or similar
+
+group = core
+admin-port = 13000
+smsbox-port = 13001
+admin-password = bar
+admin-deny-ip = "*.*.*.*"
+admin-allow-ip = ""
+log-level = 0
+log-file = "/var/log/kannel/kannel.log"
+box-allow-ip = "127.0.0.1"
+
+group = smsc
+smsc = at
+smsc-id = Huawei-E230-00
+port = 10000
+modemtype = huawei_e230_00
+device = /dev/ttyUSB0
+my-number = 0401231231
+sms-center = 0405202000
+connect-allow-ip = "127.0.0.1"
+sim-buffering = true
+keepalive = 2
+
+group = modems
+id = huawei_e230_00
+name = "Huawei E230"
+detect-string = "huawei"
+init-string = "AT+CNMI=2,1,2,2,0"
+message-storage = "SM"
+speed = 460800
+
+group = smsbox
+bearerbox-host = 127.0.0.1
+sendsms-port = 13013
+global-sender = 123123123123
+log-level = 3
+
+group = sendsms-user
+username = kanneluser
+password = asdfasdf
+concatenation= true
+max-messages = 10
+
+group = sms-service
+keyword =
+catch-all = true
+omit-empty = true
+get-url = "http://localhost/incoming.php?message=%a"
@@ -0,0 +1,134 @@
+#!/usr/bin/env python
+
+"""
+This file comes from http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
+made by Sander Marechal.
+"""
+
+import sys, os, time, atexit
+from signal import SIGTERM
+
+class Daemon:
+ """
+ A generic daemon class.
+
+ Usage: subclass the Daemon class and override the run() method
+ """
+ def __init__(self, pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'):
+ self.stdin = stdin
+ self.stdout = stdout
+ self.stderr = stderr
+ self.pidfile = pidfile
+
+ def daemonize(self):
+ """
+ do the UNIX double-fork magic, see Stevens' "Advanced
+ Programming in the UNIX Environment" for details (ISBN 0201563177)
+ http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
+ """
+ try:
+ pid = os.fork()
+ if pid > 0:
+ # exit first parent
+ sys.exit(0)
+ except OSError, e:
+ sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror))
+ sys.exit(1)
+
+ # decouple from parent environment
+ os.chdir("/")
+ os.setsid()
+ os.umask(0)
+
+ # do second fork
+ try:
+ pid = os.fork()
+ if pid > 0:
+ # exit from second parent
+ sys.exit(0)
+ except OSError, e:
+ sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror))
+ sys.exit(1)
+
+ # redirect standard file descriptors
+ sys.stdout.flush()
+ sys.stderr.flush()
+ si = file(self.stdin, 'r')
+ so = file(self.stdout, 'a+')
+ se = file(self.stderr, 'a+', 0)
+ os.dup2(si.fileno(), sys.stdin.fileno())
+ os.dup2(so.fileno(), sys.stdout.fileno())
+ os.dup2(se.fileno(), sys.stderr.fileno())
+
+ # write pidfile
+ atexit.register(self.delpid)
+ pid = str(os.getpid())
+ file(self.pidfile,'w+').write("%s\n" % pid)
+
+ def delpid(self):
+ os.remove(self.pidfile)
+
+ def start(self):
+ """
+ Start the daemon
+ """
+ # Check for a pidfile to see if the daemon already runs
+ try:
+ pf = file(self.pidfile,'r')
+ pid = int(pf.read().strip())
+ pf.close()
+ except IOError:
+ pid = None
+
+ if pid:
+ message = "pidfile %s already exist. Daemon already running?\n"
+ sys.stderr.write(message % self.pidfile)
+ sys.exit(1)
+
+ # Start the daemon
+ self.daemonize()
+ self.run()
+
+ def stop(self):
+ """
+ Stop the daemon
+ """
+ # Get the pid from the pidfile
+ try:
+ pf = file(self.pidfile,'r')
+ pid = int(pf.read().strip())
+ pf.close()
+ except IOError:
+ pid = None
+
+ if not pid:
+ message = "pidfile %s does not exist. Daemon not running?\n"
+ sys.stderr.write(message % self.pidfile)
+ return # not an error in a restart
+
+ # Try killing the daemon process
+ try:
+ while 1:
+ os.kill(pid, SIGTERM)
+ time.sleep(0.1)
+ except OSError, err:
+ err = str(err)
+ if err.find("No such process") > 0:
+ if os.path.exists(self.pidfile):
+ os.remove(self.pidfile)
+ else:
+ print str(err)
+ sys.exit(1)
+
+ def restart(self):
+ """
+ Restart the daemon
+ """
+ self.stop()
+ self.start()
+
+ def run(self):
+ """
+ You should override this method when you subclass Daemon. It will be called after the process has been
+ daemonized by start() or restart().
+ """
Oops, something went wrong.

0 comments on commit 10cf896

Please sign in to comment.