I’ve been slacking off…

I really should get into the habit of updating this site more often, but a few things have been conspiring against me; mostly laziness and lack of motivation to be fair, but there have been some other real-life instances distracting me from my goal of world domination, err, I meant regular blogging.

I have been working on renovating my house to some extent, adding additional insulation to the rooms that need it whilst giving it a good clearing out… one skip rental and two trips to the dump have done quite a bit to help me along in this challenge, but there is still more to do… much, much more.

I got accepted into college and have completed my first semester of study! That is a fairly big time vampire alright, but it is very enjoyable. I’m currently studying computing, but will select a more specific area after my second semester… I’ll definitely be going for software development as the primary role in this.

I’ve been working on building up my brewery and brewing skills so that I can make lots and lots of delicious beers of all types and strengths, in fact my one and only new years (beers) resolution is to do at lease one brew a month, which at the end of the year if followed through will see me producing 60 gallons of beer. Good thing I’ve been buying in bulk and picked up a few more kegs!

Being ready for many eventualities is now also higher on my list of objectives as last year alone we had heavy snow that practically stopped the country, and quite serious flooding. Since I live alone I have become more aware that I will require food stores and basic necessities on hand should I be unable to move around too easily.

With a new year bringing along new challenges and opportunities, I intend to be ready for all of it and to take it on with a deep, hearty evil laugh!

A few changes…

Howdy folks, firstly, there has been a lot of 3rd party development going on in relation to the black ops RCON tool, but none of it was by me. In fact, I found the game so infuriatingly laggy that I canceled my server so I no longer have anything to test on, as a result I have lost interest in the project and have closed the github repo; however, I will post the code here so anyone who wants it can take it and use it, do what ever you like with it under the MIT license.

RCON Source Code available here.

I am also unemployed now :) IMHO it was a great move, as it will allow me to have a break from doing anything really for the first time since I started school when I was 4 or 5… it has also given me the push I needed to go back to college and train myself up .

I have been working on a few projects now too with my increase in available time, however I’m not going to say much about them at the moment in case I don’t finish em.

Delays & Licensing

I haven’t had too much time to work on the CoD:BO script much over the last few days as I have changed job as of Monday and am still trying to catch up, among other things, but I will definitely be doing some more work on it fairly shortly. The following is what I would like to get done over the next few weeks, in no particular order…

  • Add more functionality to it in order to provide access to kick/ban/modify rotation/etc…
  • Re-work current code into a class that can be included into custom applications (possibly as an installable extension) to make coding your own RCON solution much easier…
  • Do a full code review and implement correct error handling and status returns
  • Provide the ability for the functions to parse the returned data and have it only return the relevant stuff (makes it easier for people to accept the return values from the server)
  • Start a GitHub repository for the code base.
  • Figure out how to have a normal userland script interact with another script running as a daemon
  • Implement a script to show who’s online on the server at a given time (to be considered a demo)
  • Provide a “development area” for users to communicate easily and turn this into a real open source project (FOSS)

Things for the future include, again in no particular order…

  • Create a PHP based front end with the ability to store “pre-configurations” in mySQL and have them apply to the server at various times etc…
  • Full administration client with user level access…
  • Anything else awesome and fun that happens to take my interest.

I can’t decide on what license to release the code under. At the moment, technically it’s not licensed at all, it is released for public viewing, not for use or modification or derivative works… Of course, I have no intentions of going and suing anybody over it, but it is an important issue that I believe has to be resolved. Unfortunately I don’t really know enough about the BSD vs GPL vs GPLv2 vs GPLv3 vs ASF vs [Insert continuous string of licenses here] argument to make an informed decision at the moment, but I do know I want it to be released under a license that is recognized by the OSI and the FSF – If you do have experience or a strong opinion on the license that this should be released under, please do fire me an email using the contact form (linked at the top of the page) or shoot me a message in the comment section.

Updated Black Ops RCON

Hey folks, this is just a quick update to let you know I have still been working on this… as it stands I have implemented two functions which work, and one which doesn’t. Slowly but surely I will be adding more and more functionality… unfortunately I don’t have RCON access to an unranked server at the moment, would anyone like to oblige me on that? :)

I would also like to mention at this point, that I have not looked into causing errors on the RCON, ie invalid logins etc… so be warned, while most of this should work, I cannot and will not guarantee it. Also, it is written for Python 2.6, not 3.whatever… I will be getting a few more people on board to help with this soon and we will be cleaning it up, adding error handling etc…

Anyways, here is what you have all been waiting for….

#!/usr/bin/python
 
'''
_______               ________      .___
\   _  \__  _  ______ \_____  \   __| _/
/  /_\  \ \/ \/ /    \  _(__  <  / __ |
\  \_/   \     /   |  \/       \/ /_/ |
 \_____  /\/\_/|___|  /______  /\____ |
       \/           \/       \/      \/
                    http://hackdev.com
 
Author:
    Steven from hackdev.com
 
File History:
    09/11/10:
        [+] Initial Inception. Proof of concept written entirely inline that
            allows for a single hard coded command to be sent to the server.
 
    10/11/10:
        [+] Creation of functions to handle the sending and receiving of commands.
        [+] Added the ability for users to change passwords in the configuration
            section of the script.
        [+] Broke commands, preambles etc... into variables for easier use & modification.
        [+] Added comments, previous code did not contain comments. ** Important **
    14/11/10:
        [+] Added command boGetPlayerList
        [+] Added command boSayToServer
        [+] Added command boSayToPlayer
        [+] Figured out that not everything has to be done in \x68\x65\x78
 
'''
 
import socket       #Used for creating the UDP sockets
 
#-----------------------------------------------------------------------------------
#   User Configurable Options
#-----------------------------------------------------------------------------------
 
boHost          = ""      #The server IP
boPort          = 3074                  #The server Port
boPassword      = ""              #The RCON Password
 
#-----------------------------------------------------------------------------------
#   End User Configurable Options
#-----------------------------------------------------------------------------------
 
svrAddress = (boHost, boPort)           #Used to create a tuple of host & port
 
#-----------------------------------------------------------------------------------
#   Command Definitions, sorry about the variables :(
#-----------------------------------------------------------------------------------
global cmdPreamble
cmdPreamble  = "\xff\xff\xff\xff\x00"                       #Preamble used to prefix the packet
global cmdSeporator
cmdSeporator = "\x20"                                       #Seporator used between password & command
global cmdPostamble
cmdPostamble = "\00"                                        #Ending of the packet, end of command
 
#-----------------------------------------------------------------------------------
#   Socket Generation
#-----------------------------------------------------------------------------------
udpSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 
#-----------------------------------------------------------------------------------
#   Function used to send commands to the server, function returns the
#   data returned from the query, unformatted...
#-----------------------------------------------------------------------------------
 
def boSendCommand(boCommand, boArgument=0, recvBufferSize=4096):
    if not boArgument:
        commandBuffer = cmdPreamble + boPassword + cmdSeporator + boCommand + cmdPostamble
    else:
        commandBuffer = cmdPreamble + boPassword + cmdSeporator + boCommand + cmdSeporator + boArgument + cmdPostamble
    boSentBytes = udpSock.sendto(commandBuffer, svrAddress)     #Send the data to the server
    if (boSentBytes < len(commandBuffer)):                      #Check the num of bytes sent
        print("An error was encountered while sending the command %s", boCommand)
    boRecvBuffer = udpSock.recv(recvBufferSize)                 #Receive the data returned
 
    if len(boRecvBuffer) > 0:                                   #Check to ensure there is something
        return boRecvBuffer                                     #Return the buffer
    else:
        return 0                                                #If theres nothing, return 0
 
def boGetPlayerList():
    playerlist = boSendCommand("teamstatus")
    if not playerlist:
        return 0
    else:
        return playerlist
 
def boSayToServer(message):
    if not message:
        return 0
    else:
        servermessage = boSendCommand("say", '"' + message + '"')
        if not servermessage:
            return 0
        else:
            return servermessage
 
def boSayToPlayer(message, playerID):
    if not message or not playerID:
        return 0
    else:
        playermessage = boSendCommand("tell", playerID + "\x20" + '"' + message + '"')
        if not playermessage:
            return 0
        else:
            return playermessage
 
print("Playerlist")
myPlayerList = boGetPlayerList()
print(myPlayerList)
 
print("Server Message")
myServerMessage = boSayToServer("Testing!")
print(myServerMessage)
 
print("Player Message")
myPlayerMessage = boSayToPlayer("Testing 123", "1")
print(myPlayerMessage)

New theme for a new server!

Howdy Folks,

I have been working hard here in the background getting rid of all of my hosting accounts and consolidating everything into one (relatively) easy to manage VPS or Virtual Private Server which I got for cheap from the guys (and presumably girls) at ThrustVPS who seem to be running  tight ship, I don’t have any stats on uptime or that so far; but everything has gone smoothly. And when they say instant setup, they mean it.

Thats enough of plugging someone else’s company for now… not that I have my own to run… yet. I have managed so far to implement a custom firewall that suits my needs quite nicely, my own email system, the general webserver / mySQL server etc… and all seems to be running very smoothly for such a cheap box, I do intend however to document all of the install processes I have gone through to get this far, and if your really nice, I might even share my custom backup script with y’all.

Anyways, I just said I would pop on and give a quick update before I get to bed for work.

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();
}