### BEGIN INIT INFO
# Provides: bbctl
-# Required-Start: $remote_fs $syslog
-# Required-Stop: $remote_fs $syslog
+# Required-Start: $local_fs $network
+# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Buildbotics Controller Web service
DAEMON_DIR=$(dirname $DAEMON)
PIDFILE=/var/run/$DAEMON_NAME.pid
-
. /lib/lsb/init-functions
do_start () {
log_daemon_msg "Starting system $DAEMON_NAME daemon"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile \
- --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON \
- --chdir $DAEMON_DIR -- $DAEMON_OPTS
+ --user $DAEMON_USER --chuid $DAEMON_USER --chdir $DAEMON_DIR \
+ --startas /bin/bash -- \
+ -c "exec $DAEMON $DAEMON_OPTS > /var/log/$DAEMON_NAME.log 2>&1"
log_end_msg $?
}
HTTP_ADDR = '0.0.0.0'
import os
+import sys
+import signal
from tornado import web, ioloop, escape
from sockjs.tornado import SockJSRouter, SockJSConnection
import json
import multiprocessing
import time
import select
+import atexit
+import lcd
import inevent
from inevent.Constants import *
}
-with open('http/config-template.json', 'r') as f:
+with open('http/config-template.json', 'r', encoding = 'utf-8') as f:
config_template = json.load(f)
output_queue = multiprocessing.Queue()
+def on_exit(sig, func = None):
+ print('exit handler triggered')
+ sys.exit(1)
+
+
def encode_cmd(index, value, spec):
if spec['type'] == 'enum': value = spec['values'].index(value)
elif spec['type'] == 'bool': value = 1 if value else 0
eventProcessor = inevent.InEvent(types = "js kbd".split())
eventHandler = JogHandler(config)
+screen = lcd.LCD(1, 0x27)
+
+
+def splash():
+ screen.clear()
+ screen.display(0, 'Buildbotics', lcd.JUSTIFY_CENTER)
+ screen.display(1, 'Controller', lcd.JUSTIFY_CENTER)
+ screen.display(3, '*Ready*', lcd.JUSTIFY_CENTER)
+
+
+def goodbye():
+ screen.clear()
+ screen.display(1, 'Goodbye', lcd.JUSTIFY_CENTER)
if __name__ == "__main__":
+ signal.signal(signal.SIGTERM, on_exit)
+
import logging
logging.getLogger().setLevel(logging.DEBUG)
ioloop.PeriodicCallback(checkQueue, 100).start()
ioloop.PeriodicCallback(checkEvents, 100).start()
+ splash()
+ atexit.register(goodbye)
+
# Start the web server
app = web.Application(router.urls + handlers)
app.listen(HTTP_PORT, address = HTTP_ADDR)
-#!/usr/bin/env python
+#!/usr/bin/env python3
import smbus
import time
def goto(self, x, y):
if x < 0 or self.width <= x or y < 0 or self.height <= y: return
- self.write(LCD_SET_DDRAM_ADDR | (0, 64, 20, 84)[y] + x)
+ self.write(LCD_SET_DDRAM_ADDR | (0, 64, 20, 84)[y] + int(x))
def text(self, msg):
#sed -i 's/^\(.*ttyAMA0.*\)$/# \1/' /etc/inittab
sed -i 's/console=ttyAMA0,115200 //' /boot/cmdline.txt
+# Disable extra gettys
+sed -i 's/^\([23456]:.*\/sbin\/getty\)/#\1/' /etc/inittab
+
# Enable I2C
sed -i 's/#dtparam=i2c/dtparam=i2c/' /boot/config.txt
echo i2c-bcm2708 >> /etc/modules
echo i2c-dev >> /etc/modules
+# Install bbctrl w/ init.d script
+cp bbctrl.init.d /etc/init.d/bbctrl
+chmod +x /etc/init.d/bbctrl
+update-rc.d bbctrl defaults
+
# TODO setup input and serial device permissions in udev
-# TODO install bbctrl w/ init.d script
reboot
--- /dev/null
+#!/usr/bin/env python3
+
+import lcd
+
+if __name__ == "__main__":
+ screen = lcd.LCD(1, 0x27)
+
+ screen.clear()
+ screen.display(0, 'Buildbotics', lcd.JUSTIFY_CENTER)
+ screen.display(1, 'Controller', lcd.JUSTIFY_CENTER)
+ screen.display(3, 'Booting...', lcd.JUSTIFY_CENTER)