Remove Halo.pl! #2

Merged
merged 34 commits into from Oct 24, 2014
Commits
Jump to file or symbol
Failed to load files and symbols.
+349 −57
Diff settings

Always

Just for now

View
@@ -1,2 +1,3 @@
colors.txt
node_modules/*
+npm-debug.log
View
@@ -3,7 +3,7 @@ node_js:
- "0.10.30"
before_install:
script:
- - "which node"
+ - "npm test"
env:
- NODE_ENV=test
View
112 README.md
@@ -4,7 +4,7 @@ A socket.io 1.0 client that connects to a [colorpicker-server](http://github.com
Its main purpose is to write rgb color data to a colors.txt file for [halo](https://github.com/lordnibbler/halo) to read.
## Getting Started
-You'll need a [colorpicker-server](http://github.com/lordnibbler/colorpicker-server) instance running before this client is useful:
+You'll need a [colorpicker-server](http://github.com/lordnibbler/colorpicker-server) instance running before this client is useful. You can deploy this server to a free host like Heroku or Nodejitsu, or test locally.
```sh
# set up the GUI and server
@@ -22,3 +22,113 @@ npm start
You should see a `connected to socket at http://127.0.0.1:1337` message.
Browse to <http://localhost:1337> to use the GUI.
+
+## Configuring a Beaglebone Black with Angstrom Distro
+You'll need to do three things:
+
+1. upgrade Node.js
+2. configure `systemctl` to set up reliable network connectivity at boot
+3. configure `systemctl` to start `colorpicker-beaglebone` Node service at boot
+
+### 1. Upgrade Node.js
+I refer you to the [wonderful instructions at speakinbytes.com](http://speakinbytes.com/2013/12/update-beaglebone-black-angstrom-node-js-version/). I recommend the current stable version of node, currently 0.10.32. You'll need at LEAST 0.10.0.
+
+### 2. Network Connectivity
+My findings have been that `connman` is very unreliable, so I fell back to using `/etc/network/interfaces`. To disable connman:
+
+```sh
+systemctl disable connman.service
+
+# double check
+systemctl status connman.service
+```
+
+Edit `/etc/network/interfaces` with your editor of choice. For ethernet/hardwired internet connectivity the only logic you need here is the loopback and the `eth0` configuration, but there's also some example wifi, USB, and bluetooth configs here:
+
+```sh
+# /etc/network/interfaces
+# configuration file for ifup(8), ifdown(8)
+
+# The loopback interface
+auto lo
+iface lo inet loopback
+
+# Wireless interfaces
+ iface wlan0 inet dhcp
+ wireless_mode managed
+ wireless_essid any
+ wpa-driver wext
+ wpa-conf /etc/wpa_supplicant.conf
+
+ iface atml0 inet dhcp
+
+# Wired or wireless interfaces
+auto eth0
+iface eth0 inet dhcp
+
+# Ethernet/RNDIS gadget (g_ether)
+# ... or on host side, usbnet and random hwaddr
+iface usb0 inet static
+ address 192.168.7.2
+ netmask 255.255.255.0
+ network 192.168.7.0
+ gateway 192.168.7.1
+
+# Bluetooth networking
+iface bnep0 inet dhcp
+```
+
+If you want additional help setting up WiFi, [this article](http://octopusprotos.com/?p=37) is handy.
+
+After setting up your interfaces, configure a `systemctl` service to start ethernet connectivity at boot, touch a new file located at `/etc/systemd/system/net.service`:
+
+```sh
+# /etc/systemd/system/net.service
+[Unit]
+Description=Network interfaces
+Wants=network.target
+Before=network.target
+BindsTo=sys-subsystem-net-devices-eth0.device
+After=sys-subsystem-net-devices-eth0.device
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/bin/sh -c "sleep 5; ifup eth0"
+ExecStop=/bin/sh -c "ifdown eth0"
+
+[Install]
+WantedBy=multi-user.target
+```
+
+Then enable the service!
+
+```sh
+systemctl enable net.service
+
+# double check
+systemctl status net.service
+```
+
+You can check your connectivity using `ifconfig`.
+
+3. Starting `colorpicker-beaglebone` at boot
+
+To start this Beaglebone colorpicker client at boot, you can follow a similar approach to the network connectivity service. I have provided an example in the `/angstrom` directory of this repository.
+
+First, touch a new file at `/lib/systemd/system/colorpickerbeaglebone.service` (ensure your paths are correct, these are an example):
+
+```sh
+# /lib/systemd/system/colorpickerbeaglebone.service
+[Unit]
+Description=colorpicker-beaglebone automatic start
+
+[Service]
+WorkingDirectory=/home/root/colorpicker-beaglebone/angstrom
+ExecStart=/home/root/colorpicker-beaglebone/angstrom/colorpickerbeaglebone.sh
+
+[Install]
+WantedBy=multi-user.target
+```
+
+You can copy the contents of `/angstrom/colorpickerbeaglebone.sh` from this repo if you intend to use UART + Arduino to power the LEDs.
@@ -0,0 +1,9 @@
+[Unit]
+Description=Wifi Startup Retry
+
+[Service]
+WorkingDirectory=/home/root/colorpicker-beaglebone/wifiboot
+ExecStart=/home/root/colorpicker-beaglebone/wifiboot/wifiboot.sh
+
+[Install]
+WantedBy=multi-user.target
@@ -0,0 +1,12 @@
+#!/bin/sh -
+sleep 10
+
+# enable the UART1 in the device tree
+echo BB-UART1 > /sys/devices/bone_capemgr.9/slots
+
+# Set proper UART settings with STTY
+stty -F /dev/ttyO1 speed 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
+
+# start the node client application
+cd /home/root/colorpicker-beaglebone/
+NODE_ENV=production npm start
File renamed without changes.
View
@@ -0,0 +1,121 @@
+#!/usr/bin/perl
+
+# use Device::SerialPort;
+use Time::HiRes qw(usleep time);
+use POSIX ":sys_wait_h";
+#use LWP::Simple qw (get);
+
+# @FIXME missing this dir in github!
+$cmddir = "/home/root/halo_git/commands/";
+
+our $NUM_LIGHTS = 5;
+my $SYSTEM_ON = 0;
+my $LIVE_PREVIEW = 1;
+
+@oldRgb;
+for($j = 0;$j < $NUM_LIGHTS; $j++){
+ push(@{$oldRgb[$j]},(0,0,0,0));
+}
+
+# system("echo 20 > /sys/kernel/debug/omap_mux/uart1_rxd");
+# system("echo 0 > /sys/kernel/debug/omap_mux/uart1_txd");
+system("echo BB-UART1 > /sys/devices/bone_capemgr.9/slots");
+system("stty -F /dev/ttyO1 speed 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts");
+
+$|=1;
+
+# Opens file whose filename is given by EXPR (> /dev/tty01), and associates it with FILEHANDLE (SERIAL)
+open(SERIAL, "> /dev/ttyO1");
+
+sysopen(PREVIEW_DATA, "/home/root/colorpicker-beaglebone/colors.txt", O_RONLY)
+ or die "can't read pipe: $!";
+
+{
+ my $previous_default = select(STDOUT); # save previous default
+ select(SERIAL);
+ $|++; # autoflush STDERR, to be sure
+ select($previous_default); # restore previous default
+}
+
+# set all black
+for(my $address = 0; $address < $NUM_LIGHTS; $address ++){
+ &sendColor($address,0,0,0,0);
+}
+
+sub sendColor {
+ my($address,$r,$g,$b,$v)= @_;
+ $address = $address + 1;
+ print SERIAL "4,$address,$r,$g,$b,$v;";
+}
+
+sub turnOffAll {
+ while(waitpid(-1,WNOHANG ) >= 0) {}
+ for(my $address = 0; $address < $NUM_LIGHTS; $address ++){
+ &sendColor($address,0,0,0,0);
+ @{$oldRgb[$address]} = (0,0,0,0);
+ }
+}
+
+
+
+$start_time = time();
+
+sub grabLiveData{
+ # print @preview_data;
+
+ $rin = '';
+ vec($rin, fileno(PREVIEW_DATA), 1) = 1;
+ $nfound = select($rin, undef, undef, 0); # just check
+ if ($nfound) {
+ @processed_data = ();
+ while($color = <PREVIEW_DATA>){
+ #print $color;
+ #print "Glen\n";
+ if($color =~ /.*END_LINE.*/){
+ # print "END_FILE FOUND\n";
+ last;
+ }
+ if($color =~ /([0-9]+)\,([0-9]+)\,([0-9]+)\,([0-9]+)/){
+ # print "$1, $2, $3, $4 found\n";
+ my @rgb = ($1,$2,$3,0);
+ push(@processed_data,[@rgb]);
+ }
+ }
+
+ # close PREVIEW_DATA or die "bad netstat: $! $?";
+ $previewLength = @processed_data;
+ if( $previewLength > 0){
+ my $end_time = time();
+ printf("%d %.6f\n", $previewLength,$end_time - $start_time);
+ $start_time = time();
+ # print "$previewLength data chunks\n";
+ $start =0;
+ if($previewLength > $NUM_LIGHTS){
+ $start = $previewLength - $NUM_LIGHTS;
+ }else{
+ $start = 0;
+ }
+ # print "i is $i, total size is $previewLength";
+ $address = 0;
+ for($i = $start;$i< $previewLength; $i ++){
+ my @rgb = @{$processed_data[$i]};
+ # print @rgb;
+ # printf("address %d R= %d G=%d B=%d\n",$address,$rgb[0],$rgb[1],$rgb[2],$rgb[3]);
+ &sendColor($address,$rgb[0],$rgb[1],$rgb[2],$rgb[3]);
+ $address ++;
+ }
+ if($previewLength < $NUM_LIGHTS){
+ while($address < $NUM_LIGHTS){
+ &sendColor($address,0,0,0,0);
+ $address ++;
+ }
+ }
+ }
+ }
+}
+
+while(1){
+ if($LIVE_PREVIEW == 1){
+ &grabLiveData();
+ }
+}
File renamed without changes.
File renamed without changes.
View
@@ -1,10 +1,10 @@
{
"name": "colorpicker-beaglebone",
- "version": "1.0.6",
+ "version": "1.1.0",
"description": "A beaglebone Node.js client to listen to colorpicker, and pipe current color data into a writeStream.",
"scripts": {
"start": "coffee index.coffee",
- "test": "npm test"
+ "test": "mocha"
},
"repository": {
"type": "git",
@@ -16,13 +16,18 @@
"url": "https://github.com/Lordnibbler/colorpicker-beaglebone/issues"
},
"dependencies": {
- "log": "~1.4.0",
"coffee-script": "~1.7",
- "socket.io": "~1.0.6",
- "socket.io-client": "~1.0.6"
+ "log": "~1.4.0",
+ "socket.io": "~1.1.0",
+ "socket.io-client": "~1.1.0"
},
"engines": {
- "node": "0.10.x",
+ "node": "0.10.32",
"npm": "1.3.x"
+ },
+ "devDependencies": {
+ "chai": "^1.9.1",
+ "mocha": "^1.21.4",
+ "sinon": "^1.10.3"
}
}
Oops, something went wrong.