Archive for the ‘ General ’ Category

Just a general update…

It’s been quite a while since I’ve posted  anything, I’ve been very busy lately but since I’m out sick now for a few days, I have a bit of time to update…

If you have tried to play Fallout 3 using an Asus branded NVidia card, and it crashes stating “Fallout 3 has stopped working” every time you try to load a new game, check and see if you have Asus Gamer OSD installed, if you do, get rid of it. Something the overlay does interferes with the game  and causes this to happen…

I have been doing some more work on the lighting for the man cave so I have some Python code that will pull the Average color (not the most predominant, yet, wont be hard, but I am lazy) so here it is, please keep in mind its not nice, fast or clean… for high res images it takes a few seconds to do its thing…

#!/usr/bin/env python
 
#
# PIL Image Module Handbook - http://www.pythonware.com/library/pil/handbook/image.htm
#
 
from PIL import Image
from optparse import OptionParser
 
def processImageAverage(imageFile):
    image = Image.open(imageFile)     #open the image for processing
    pixels = list(image.getdata())    #break the image down into a list of pixels, each pixel contains a list of red,green,blue
 
    totalpx = 0 #set some default values to start counting...
    redpx = 0
    greenpx = 0
    bluepx = 0
 
    for pixel in pixels:    #loop through the lists and build the values.
        totalpx += 1
        redpx += pixel[0]
        greenpx += pixel[1]
        bluepx += pixel[2]
 
    redavg = redpx / totalpx   #generate the averages
    greenavg = greenpx / totalpx
    blueavg = bluepx / totalpx
 
    print "\nTotal Pixels:\t", totalpx     #and write them out.
    print "Red Average:\t", redavg
    print "Green Average:\t", greenavg
    print "Blue Average:\t", blueavg
    print "HEX Color:\t#%x%x%x" % (redavg, greenavg, blueavg)
 
def main():
    parser = OptionParser("Usage: %prog source")
 
    (options, arguments) = parser.parse_args()
    if len(arguments) != 1:
        parser.error("Please specify a single input file.")
 
    processImageAverage(arguments[0])
 
if __name__ == "__main__":
    main()

I have a new job now, I’m no longer a software validation engineer (tester), I’m now an IT Support Engineer (IT Techie…) which is kinda nice….

Well… that is for now…

€1366.07 down…

So I have been doing some serious work on my mancave during my two weeks off, so far I have all of the walls battened, the new door fitted, and two of the walls wired for mains sockets. I have even been picking up some additional parts that we are not quite ready yet, such as a roll of CAT6 cable, CAT6 wall outlets with faceplate’s, 17 double gang switched sockets and much much more… all in all its coming along nicely. No photo’s taken as of yet though, I really should have taken some at the start and all the way through as it would have been quite a good evolution slide show, but alas its too late now… we did run into a few issues though, the garage is still crammed full of stuff and there is not much room to move around in it so that has been slowing us down a lot, however there is nowhere else to put it so it has to be this way for now I’m afraid :(

Another issue we’ve encountered was that the cavity blocks haven’t aged all that well and are quite hard, like flint even, so masonry nails havent been working out too well on that, so as a more expensive, and time consuming work-around, we have been using nail-anchors and manually drilling for each baton… not the most fun thing in the world, but at least its progress…

As a side note, from working out in the cold weather all week I seem to have gotten another cold :(

I Hate Webdesign

Did I mention lately that I hate webdesign? no? let me explain…

While I am quite proficient at writing backend systems in PHP and mySQL, or even taking an existing design and twising it around, chopping it up and changing things, I have no artistic taste when it comes to actually designing things. I have taken on a job for a client, and I now feel that I am out of my depth, it doesnt help that I have absolutely no specification what so ever, none, nada, ziltch… but even still, I should be able to come up with something suitable, but I cant, its just not coming to me… It’s not a particularly complex website, its basicly an online brochure for a catering company so I have settled on using the website baker CMS for doing all of the backend management, it doesnt really need anything more complex than that to do what it needs to do, however this means that 90% of the work to be done on this site is purely design, look and feel… and I hate it.

So far, my design consists of a solid, light coffee color background, some red (to slightly pinkish) text, and a white box with a border… really… is this the best I can do?

To the Man Cave!

UPDATED: Syntax Highlighting for code blocks.

Purpose: A man cave is loosely a male-only space to retreat to, watch sports matches, or play video games. According to psychiatrist and author Scott Haltzman, it is important for a man to have a place to call his own, referring to a male area to retreat to. Some psychologists claim that a man cave can provide refuge from stressful surroundings and be beneficial to marriage.

Via: Wikipedia

So I have committed myself to building one of these, at present, I have a 15′ x 15′ garage space, ready for the taking. I plan on turning the space into a male friendly (read: full of beer) area with a home cinema setup, a bar and some cool and interesting technology. To date, I already have the Projector & Screen, some basic fittings, some decent insulation for the roof, 2x Wireless access points with which I will be building a P-T-P link, and lots of ideas…

One of the things that I want to do is to install an all LED lighting system composed of high output RGB LED’s – My idea for this is to use an I2C bus linking all of the LED modules with the info and the power over CAT5; as such, I have begun development. I bought some small 3W RGB LED’s from Deal Extreme for developing my proof of concept modules. My PoC so far is comprised of an Seeeduino Mega as the LED controller and unfortunately as I havent made as much progress with my BifferBoard as of yet, I’m currently using a Bus Pirate (v2go) for controlling the I2C bus, the protocol Im using is quite simple, you send the write address of the unit, a # character and then the hexadecimal RGB values, as such the full pallet of colors is available and can be looked up online or from the majority of graphics programs… There are a few points to consider for what you want to use as the LED Controller, if I beef up my C skills, I do intend on moving away from the Arduino plaform and migrating to a smaller lower specced Atmel or PIC uC – resulting in lower costs… the controller so far has a few features…

  • The Default (Startup) Color is programmable from the I2C bus so if there is a power failure etc… the lights will return automatically to a known state.
  • The controller is bus configurable to be Common Cathode OR Common Anode
  • There is more to add here as I complete them, such as disco mode or fade mode, or pre-defined sequences…

I have taken a photo of the test setup I have at present and will provide the sourcode below, I have also been working on a Processing application to play with the idea of doing something similar to the Phillips Ambilight tv where depending on the image on my screen, the lights in the mancave will be a particular color, while I will also post the code for this, its not commented, or pretty, or even working at this point so your on your own with it… I will update as time goes on… anyways, enough jibber jabber, time for some actuall images and real code…

General (Outdated)  Flowchart for the controller:

Picture of the test setup…

And as promised, here is the source for the Arduino:

/* 
 
Arduino I2C RGB LED Controller
 
EEPROM Map:
  0x00  configuration block
  0x01  red pwm value
  0x02  green pwm value
  0x03  blue pwm value
 
*/
 
#include
#include 
 
//PIN Definitions
#define addr0      2
#define addr1      3
#define addr2      4
#define addr3      5
#define redPin     7
#define greenPin   8
#define bluePin    9
 
//Global Variables
byte redPWM = 0;
byte greenPWM = 0;
byte bluePWM = 0;
byte configBlock = 0;
byte i2cAddress = 0;
byte i2cData[4] = {0, 0, 0, 0};
boolean processQueue = false;
 
void setup() {
 
  //Set PIN I/O's
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(addr0, INPUT);
  pinMode(addr1, INPUT);
  pinMode(addr2, INPUT);
  pinMode(addr3, INPUT);
 
  //Enable internal pullups
  digitalWrite(addr0, 1);
  digitalWrite(addr1, 1);
  digitalWrite(addr2, 1);
  digitalWrite(addr3, 1);
 
  //Set I2C Address...
  //i2cAddress = (digitalRead(addr0) | digitalRead(addr1) | digitalRead(addr2) | digitalRead(addr3));
  i2cAddress = 7;
 
  //Register an event to fire when we receive I2C data then join the bus...
  Wire.onReceive(grabData);
  Wire.begin(i2cAddress);
 
  //Grab previous settings from EEPROM...
  configBlock = EEPROM.read(0);
  redPWM = EEPROM.read(1);
  greenPWM = EEPROM.read(2);
  bluePWM = EEPROM.read(3);
 
  //Set the PWM outputs for the LED(s)
  setPWM();
 
  //I think we're ready to enter the main loop now...
 
}
 
void grabData(int data) {
  int i = 0;
  while(Wire.available()) {
     i2cData[i] = Wire.receive();
     i++;
  }
  processQueue = true;
}
 
void setPWM() {
    if(configBlock == 'A') {
    analogWrite(redPin, 255 - redPWM);
    analogWrite(greenPin, 255 - greenPWM);
    analogWrite(bluePin, 255 - bluePWM);
  } else {
    analogWrite(redPin, redPWM);
    analogWrite(greenPin, greenPWM);
    analogWrite(bluePin, bluePWM);
  }
}
 
void updateEEPROM() {
  EEPROM.write(0, configBlock);
  EEPROM.write(1, redPWM);
  EEPROM.write(2, bluePWM);
  EEPROM.write(3, greenPWM);
}
 
void loop() {
  //Check to see if we have something to do...
  while(processQueue == false) {
    //Do nothing... but do it quickly!
    delay(1);
  }
 
  switch(i2cData[0]) {
    case '#':
      //we have a color
      redPWM = i2cData[1];
      greenPWM = i2cData[2];
      bluePWM = i2cData[3];
      setPWM();
      break;
    case 'D':
      //We're setting the default startup color...
      redPWM = i2cData[1];
      greenPWM = i2cData[2];
      bluePWM = i2cData[3];
      updateEEPROM();
      setPWM();
      break;
    case 'C':
      //we're changing the LED type
      if(i2cData[1] == 'A') {
        configBlock = 'A';
      } else {
        configBlock = 'C';
      }
      updateEEPROM();
      break;
    default:
      //do nothing...
      break;
  }
 
  processQueue = false;
}

And here is the source for Processing:

import processing.serial.*;
 
PImage myImage;
Serial myPort;
 
float[] redpx;
float[] greenpx;
float[] bluepx;
 
float redtotal;
float greentotal;
float bluetotal;
 
int imgWidth;
int imgHeight;
 
void setup() {
    //println(Serial.list());
    myPort = new Serial(this, "COM13", 115200);
 
    myImage = loadImage("red.jpg");
    myImage.loadPixels();
 
    redpx = new float[myImage.pixels.length];
    greenpx = new float[myImage.pixels.length];
    bluepx = new float[myImage.pixels.length];
 
    for(int i=0; i> 16 & 0xFF;
        greenpx[i] = myImage.pixels[i] >> 8 & 0xFF;
        bluepx[i] = myImage.pixels[i] & 0xFF;
    }
 
    for(int r=0; r < redpx.length; r++) {
        redtotal += redpx[r];
    }
    redtotal = redtotal / redpx.length;
 
    for(int g=0; g < greenpx.length; g++) {
        greentotal += greenpx[g];
    }
    greentotal = greentotal / greenpx.length;
 
    for(int b=0; b < bluepx.length; b++) {
        bluetotal += bluepx[b];
    }
    bluetotal = bluetotal / bluepx.length;
 
    int serialData[] = { 91, 32, 48, 120, 48, 69, 32, 48, 120, 50, 51, 32, floor(redtotal), 32, floor(greentotal), 32, floor(bluetotal), 32, 93, 13};      //used for i2c control through a bus pirate
    //int serialData[] = { 'R', floor(redtotal), 'G', floor(greentotal), 'B', floor(bluetotal), 'C', 'A', 'U' };      //used for serial control through rs232
 
    for(int j=0; j 0) {
       String inBuffer = myPort.readString();
       if(inBuffer != null) {
        println(inBuffer);
       }
    }
 
    myImage.updatePixels();
}

It made me LOL

Just spotted this video online and found it quite funny…

Teamspeak 3 server on Ubuntu

Well, Teamspeak have finally released their new server platform for a public BETA test, although supposedly in this state the code is not meant to be stable, it appears to be working quite well on my Ubuntu server here at home. This is what I done to get it up and running – as a service from init.d no less. Before doing any of the following steps, please be aware that this IS BETA code and WILL contain bugs that may introduce security issues. The first step is to create a user that the Teamspeak executable can run as, this user should have a complex password for security reasons. This user will also not require a shell account.

sudo adduser teamspeak

Fill in the questions presented by the adduser application.

sudo usermod -s /bin/false teamspeak

The above command will change the users shell to be /bin/false ie. no shell. Now it is time to go and get Teamspeak… visit http://www.goteamspeak.com and find the correct package for the architecture you wish to use ie. Teamspeak_3.0.0-Beta5-32bit…

wget http://ftp.4players.de/pub/hosted/ts3/releases/beta-5/teamspeak3-server_linux-x86-3.0.0-beta5.tar.gz tar -zxvf teamspeak3-server_linux-x86-3.0.0-beta5.tar.gz

Now its time to move the new TS3 directory to its new home…

sudo mv ./teamspeak3-server_linux-x86-3.0.0-beta5 /opt/TS3 sudo chown -R teamspeak /opt/TS3

The above will place TS3 in /opt/TS3 and give ownership of the contents to the user teamspeak. It is now possible to run Teamspeak, however as veteran Teamspeak users will know, the first time you run the Teamspeak server you are presented with a username/password combo that cannot be recovered without resetting the server. In TS3 you will also be presented with a `token` (all of this is described in the Teamspeak documentation). So for the first run, the following command will allow you to gather these details, they should be noted carefully for future reference.

sudo start-stop-daemon –chuid teamspeak –chdir /opt/TS3 –start –exec /opt/TS3/ts3server_linux_x86

From this, you should see the serveradmin user and password. You can now ^C that and be returned to the normal shell, if you cat /opt/TS3/logs/* you will be presented with the token you require to obtain server-admin status on the new server. The last part is to create a script for /etc/init.d/ to launch Teamspeak each time the system is booted to the correct runlevel. /etc/init.d/skeleton provides a suitable framework for this, here is the script I am using, just about… NOTE: WordPress does not want to format this correctly for me, as such, here is a link to the file in a tar archive. If you follow these instructions and are running a 32bit server, the following file will work out of the box. /etc/init.d/teamspeak This file must then be made executable with

sudo chmod +x /etc/init.d/teamspeak

And finally, the init file must be symlinked to each of the runlevel start dirs using the following…

sudo ln -s ../init.d/teamspeak /etc/rc0.d/K21teamspeak sudo ln -s ../init.d/teamspeak /etc/rc1.d/K21teamspeak sudo ln -s ../init.d/teamspeak /etc/rc2.d/S21teamspeak sudo ln -s ../init.d/teamspeak /etc/rc3.d/S21teamspeak sudo ln -s ../init.d/teamspeak /etc/rc4.d/S21teamspeak sudo ln -s ../init.d/teamspeak /etc/rc5.d/S21teamspeak sudo ln -s ../init.d/teamspeak /etc/rc6.d/K21teamspeak

Viola, you should now have a working Teamspeak 3 server.

BOOTNOTE:

For my initial install, and for the basis of the majority of this, I used this as a reference. Items listed in bold with ** are most likely not the correct file names for the command, I am not close to my server or an available shell to pull the correct parameters at present, but I will update ASAP. As an additional side note, my first impressions of TS3 are very good… It has tons of new features, looks good and the voice quality is very good indeed. My only concern is however the permissions system is very bulky, difficult to understand, and unless you are reasonably familiar with administering a Teamspeak server already, the documentation is not as straight forward as people believe. Still, however, a great job. Well done Teamspeak 3 development team!

UPDATE: Fixed formatting issue, kinda… provided link to pastebin.

UPDATE: Fixed information regarding server executable. Added /etc/init.d/teamspeak file, available for download here, removed pastebin link.

#! /bin/sh
### BEGIN INIT INFO
# Provides:          teamspeak
# Required-Start:    networking
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: TeamSpeak Server Daemon
# Description:       Starts/Stops/Restarts the TeamSpeak Server Daemon
### END INIT INFO

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="TeamSpeak Server"
NAME=teamspeak
USER=teamspeak
DIR=/opt/tss2_rc2
DAEMON=$DIR/server_linux
#PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

d_start() {
        start-stop-daemon --start --quiet \
                --chuid $USER \
                --chdir $DIR \
                --exec $DAEMON \
                > /dev/null \
                || echo -n " already running"
}

d_stop() {
        start-stop-daemon --stop --quiet \
                --chuid $USER \
                --chdir $DIR \
                --exec $DAEMON \
                || echo -n " not running"
}

case "$1" in
  start)
        echo -n "Starting $DESC: $NAME"
        d_start
        echo "."
        ;;
  stop)
        echo -n "Stopping $DESC: $NAME"
        d_stop
        echo "."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        d_stop
        sleep 15
        d_start
        echo "."
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac

exit 0

Welcome… I guess…

Hi There,

Just to keep y’all in the loop, this is going to be my blog of sorts, but for the most part its just going to be used to track my various how-to’s and to keep notes on stuff that I’ve done. Feel free to follow it or read it daily (if I can type that much…) and I hope if you do, you might learn something from it.

Enjoy!