Getting Started
From KegbotWiki
Quick and crude notes on getting started. These are no substitute for proper documentation. Notable caveats:
- instructions assume you are using debian/ubuntu
- code needs to be checked out from source control
- code is not installed system-wide (you need to use $PYTHONPATH in a few places)
Contents |
Install dependencies
The following apt goodies are a good start:
sudo apt-get install \ python-django \ python-django-registration \ python-mysqldb \ python-pysqlite2 \ python-serial \ sqlite3
As of 7/09, you also need mercurial (rather than svn) to check out the code:
sudo apt-get install mercurial
TODO(mikey): fix setuptools TODO(mikey): determine best practice here, apt/ez_setup/etc
You also need to install the protobuf package: [1]
cd protobuf-2.1.0/ ./configure && make && sudo make install
Note from user: This program is inside of pykeg/external You must edit some of the python files to add pykeg.external. to the imports from protobufrpc.synchronous TODO(mikey): see about getting debs for this
Check out code
Check out the code, per checkout instructions:
mkdir -p ~/sandbox/ cd ~/sandbox/ hg clone https://kegbot.googlecode.com/hg/ kegbot
The rest of this doc assumes you have setup as shown above, in ~/sandbox/kegbot.
Run unittests
Run the unittests and see if anything fails. This will test that django, sqlite3, etc, are all working properly.
cd ~/sandbox/kegbot/pykeg export PYTHONPATH=$(dirname `pwd`) make test
Note Hanzov69: Playing along at home, the unit test failed. I ended up making a slight change in the Makefile from "django-admin.py" to just "django-admin", YMMV, I'm using the latest Karmic Koala release with django 1.1
Set up the DB
Edit your pykeg/settings.py to taste.
cd ~/sandbox/kegbot/pykeg export PYTHONPATH=$(dirname `pwd`) make setup
This will add tables to the database and create a superuser.
Note 2 Hanzov69: In order to get this to work, I needed to run (no quotes) "./bin/kegbot_admin.py migrate"
Test your kegboard
cd ~/sandbox/kegbot/pykeg export PYTHONPATH=$(dirname `pwd`) ./bin/kegboard-monitor.py --help [...] ./bin/kegboard-monitor --kegboard_device=/dev/ttyUSB0 --kegboard_speed=115200 2009-06-30 00:10:56,321 INFO (main) Setting up serial port... 2009-06-30 00:10:56,339 INFO (main) Starting reader loop... 2009-06-30 00:10:59,066 INFO (reader-kegboard) Framing broken, fixing 2009-06-30 00:10:59,068 INFO (reader-kegboard) Found start of frame, framing fixed. <METER_STATUS meter_name=flow0 meter_reading=0> <METER_STATUS meter_name=flow1 meter_reading=0> <OUTPUT_STATUS output_reading=0 output_name=output0> <OUTPUT_STATUS output_reading=0 output_name=output1> <TEMPERATURE_READING sensor_name=thermo0 sensor_reading=4293968296> <TEMPERATURE_READING sensor_name=thermo1 sensor_reading=4293968296> <HELLO protocol_version=239> [...]
Run it!
In one terminal, start the kegbot core:
cd ~/sandbox/kegbot/pykeg export PYTHONPATH=$(dirname `pwd`) ./bin/kb_core 2009-06-29 23:52:39,222 INFO (kegnet) Starting up. 2009-06-29 23:52:39,230 INFO (main) Starting all service threads. 2009-06-29 23:52:39,231 INFO (main) starting thread "eventhub-thread" 2009-06-29 23:52:39,232 INFO (main) starting thread "service-thread" 2009-06-29 23:52:39,233 INFO (main) starting thread "alarmmanager-thread" 2009-06-29 23:52:39,235 INFO (main) starting thread "watchdog-thread" 2009-06-29 23:52:39,236 INFO (main) starting thread "net-thread" 2009-06-29 23:52:39,237 INFO (net-thread) network thread started 2009-06-29 23:52:39,248 INFO (main) starting thread "flowmonitor-thread" 2009-06-29 23:52:39,249 INFO (main) All threads started.
In another terminal, run the kegboard daemon:
cd ~/sandbox/kegbot/pykeg export PYTHONPATH=$(dirname `pwd`) ./bin/kegboard_daemon.py --kegboard_device=/dev/ttyUSB0 --kegboard_speed=115200 2009-06-30 00:11:51,337 INFO (main) Starting all service threads. 2009-06-30 00:11:51,344 INFO (main) starting thread "network" 2009-06-30 00:11:51,345 INFO (network) Registering device. 2009-06-30 00:11:51,345 INFO (main) starting thread "kegboard-manager" 2009-06-30 00:11:51,348 INFO (kegboard-manager) Starting main loop. 2009-06-30 00:11:51,349 INFO (main) starting thread "device-io" 2009-06-30 00:11:51,349 INFO (device-io) Setting up serial port... 2009-06-30 00:11:51,350 INFO (main) All threads started. 2009-06-30 00:11:51,350 INFO (main) Running generic main loop (going to sleep). 2009-06-30 00:11:51,359 INFO (device-io) Starting reader loop... 2009-06-30 00:11:51,356 INFO (network) Running asyncore loop. 2009-06-30 00:11:54,085 INFO (reader-mykegboard) Framing broken, fixing 2009-06-30 00:11:54,086 INFO (reader-mykegboard) Found start of frame, framing fixed.
Connect the digital pins labeled #2 and #12 together. This will cause a slow pulse train on the first flowmeter input. The kegbot core should notice the activity and start logging information.
Disconnect the pins. The kegbot core should timeout and record this flow as a drink.
Kegweb
TODO(mikey): document me. mostly settings stuff.
You can start the server by executing the following:
cd ~/sandbox/kegbot/pykeg ./bin/kegbot_admin.py runserver 0.0.0.0:8000
Test it by loading your kegbot server address on port 8000 Kegweb appears to be incomplete / nonfunctional as of this time
TODOs
- auth is completely missing from the current tree
- prepackaged source downloads (eliminate need for svn)
- fix setup.py (see previous)
- proper deps in setup.py for python stuff
- better docs, if it wasn't obvious
