Sunday, September 26, 2010

Net

While I was bored a few days ago I thought I'd have a look at how terminal based GUI applications work, as I was wanting to see the nitty gritty of it I decided that it would be more educational to work directly with ANSI codes.

The project I ended up with was writing a terminal based version of the game Netwalk, probably best known from Simon Tatham's Portable Puzzle Collection. This was inspired by playing around with the box drawing characters, making a grid and thinking, "hey, that looks like Net!"

Thus, I have created a fairly simple version of the game, the source is on my GitHub page. If you want to try playing it then you can download it from there and compile it with g++. Alternatively if you have an account on codd (the Warwick compsoc server) then you can run it directly from /home/zed0/programming/net/netgame .

The game seems to run without issue through PuTTY, on the condition that you are using UTF-8. The only other configuration I've tried it with is Cygwin, which compiles and runs fine, however, assuming you're using the default Cygwin terminal, you'll need to change the font to one which has the box drawing characters.

As this was made in the space of a few hours there are quite a lot of improvements to be made.
My current todo list includes:
Adjusting the drawing methods so that it only updates the bits of the screen it needs to.
Adding wrapping as the game is fairly trivial without it.
Writing a better map generation algorithm.

On that last point I haven't really got many ideas. Writing an algorithm to generate a tree which takes up the entire map is fairly trivial, however I have no idea how to ensure that the map has a unique solution which would be desirable. If any mathsy people know how to do this then please comment.

Feel free to suggest other features or report bugs. Multiplayer has been suggested, which I may, at some point, try to implement.

Saturday, June 05, 2010

WPA Enterprise networks on rooted Android 1.6

So I spent a while in DCS (Department of Computer Science) today trying to get my phone to connect to the network.

For some reason on the Cyanogen ROM I'm using at the moment (I don't know about the official 1.6 build) wireless certificates were failing to install properly. They appear to install fine, however the drop down for certificates still shows no entries when one tries to connect to a network.

The easiest solution (at least for users with root access) to this appears to be to transfer the certificates to ones SD card and then edit the file /data/misc/wifi/wpa_supplicant.conf to add a new network.
Assuming one is connecting to the wifi in DCS this looks something like this:

network={
ssid="dcs_wl"
key_mgmt=WPA-EAP
group=CCMP TKIP
eap=TLS
identity="csuxxx"
ca_cert="/sdcard/root.der"
private_key="/sdcard/csuxxx.p12"
private_key_passwd="blah123BLAH"
priority=11
}

If one tries to connect beforehand then there will already be an entry for dcs_wl that can be edited.

Voila, it now connects automatically.

From what Chris Sinjakli has said, he found connecting to the network significantly easier so it may well be that more recent ROMs don't have this problem.

Sunday, May 23, 2010

Easter Lego

During the Easter holidays I found myself rather bored at points, thus, given the amount of Lego in my room, I did the only logical thing:


My mecha, complete with ominous shadow.

As usual sorry about the quality of the pictures, I'm terrible at keeping my hand steady for them.






Close up of the gun thing.


Close up of the claw thing.



Close up of the cockpit.


The only picture to come out not incredibly blurred.

I'm not sure what I was expecting when I started making this, it looks rather more like it's from Bioshock than intended. I also didn't expect it to be this yellow, but then realised I didn't have enough dark grey pieces.

I have actually made quite a few Lego models over the last couple of years, I'll probably blog about them too before too long.

Wednesday, April 21, 2010

Minamicon Pictures

I went to Minami Con in Southampton last weekend which was a nice break before my term of horror.
Here are a few photos (sorry about the quality, I can't keep my hand steady while taking shots):


Nikki's great dark Zelda cosplay.


No idea what this is from, I just really liked the detail on the clothing.


One of my favourite cosplays of the entire con, a self designed witch.


I can't remember which series this is from but I recall being told it was some sort of space pope, whatever it's from the hat was fantastic.


I think this is from Utena, though having never seen it it's hard to say.


This is pretty self explanatory, if you don't know who KOS-MOS is then play Xenosaga.


Lastly a picture of Claire abusing P Chan.

If you want more pictures then there are quite a few here on Facebook.

Tuesday, April 13, 2010

Tethering on Debian

Rooting an android phone allows one to use several methods of tethering (using the phone's internet on another device) including USB, bluetooth and wifi.
I have only tried wifi tethering and USB tethering so far but I imagine I will get round to trying bluetooth sometime.

Wifi tethering is simple, if your phone is rooted then you can simply get android-wifi-tether , open the application and touch the icon in the centre of the screen, this will create a wireless access point which you can then connect to with your laptop. I had no problems at all with this using Debian lenny. There are various options for access control and encryption and it works fairly well. The main downside to this method is that it uses a horrific amount of power, meaning I usually need my phone plugged in anyway.

USB tethering is provided with CyanogenMod and many other popular roms and is in most respects better than wifi tethering if you have a USB cable. To start tethering just turn on USB tethering in Settings > Wireless controls > Internet tethering. Connect the laptop via USB cable and depending on what OS you are using it may just work or it may take some setup.
I haven't tried Windows XP but I believe that you can just install either the android SDK or a separate RNDIS driver, apparently later versions of windows come with this.
I have heard many people say that it just works with Ubuntu, however with Debian I couldn't find any packaged drivers but found that the RNDIS drivers from SynCE worked fine
Download http://downloads.sourceforge.net/synce/usb-rndis-lite-0.11.tar.gz
tar -xvzf usb-rndis-lite-0.11.tar.gz
cd usb-rndis-lite-0.11/
make
sudo ./clean.sh
sudo make install
I found that network-manager picked it up immediately, though if you don't use network-manager you may need to do:
ifup rndis0
I'm looking forward to trying this out for a longer duration on my 7 hour train trip back to Warwick on Wednesday.

Friday, April 09, 2010

Installing Debian on a G1 (HTC Dream)

I bought a G1 in November having heard good reviews of them from the few people I knew who owned one and pleasantly surprised at how easy it was to type on the keyboard, which was the main problem I had had with iPhones.

Anyway, I haven't really done much messing with it until the last couple of weeks when I discovered myself very bored while at home for the Easter break. Having heard it was possible a while ago I started off by rooting the phone and installing CyanogenMod (instructions here for those of you who want to try it), a replacement for the default Android installation, adding a features that haven't been pushed down the line by vendors yet and a few extras such as the ability to store apps on the SD card, USB tethering and various Unix commands.

Having rooted the phone I was curious as to what I could now do and found it mentioned that it was possible to install Debian in a chroot since it already supports ARM EABI. I partially followed this post by saurik but came across several issues and shortcuts due to using CyanogenMod.

Here are some brief instructions to get Debian working on CyanogenMod:

Making a Debian image
To avoid having to partition my SD card (I use it for various other things) I created a mountable image as follows (assuming you are running Debian on your computer too), to avoid confusion I also add an sdcard directory here that the sdcard will later be mounted in:
apt-get install debootstrap
dd if=/dev/zero of=debian.img seek=749999999 bs=1 count=1
mke2fs -F debian.img
mkdir debian
mount -o loop debian.img debian debootstrap --verbose --arch armel --foreign lenny debian http://ftp.de.debian.org/debian
mkdir debian/sdcard
umount debian
As CyanogenMod comes with the Linux filesystem drivers and busybox you don't need to worry about adding them which means a large portion of saurik's instructions can be skipped.

Mounting the Image
Mounting the loop device caused some problems but I eventually found that it was looking for the loop devices at /dev/block/loop* rather than /dev/loop* which was fixed by adding a few ifs to the start of the mounting script.
#!/system/bin/sh
if [ ! -e /dev/loop0 ]
then
ln /dev/block/loop0 /dev/loop0
fi
if [ ! -e /dev/loop1 ]
then
ln /dev/block/loop1 /dev/loop1
fi
if [ ! -e /dev/loop2 ]
then
ln /dev/block/loop2 /dev/loop2
fi
if [ ! -e /dev/loop3 ]
then
ln /dev/block/loop3 /dev/loop3
fi
if [ ! -e /dev/loop4 ]
then
ln /dev/block/loop4 /dev/loop4
fi
if [ ! -e /dev/loop5 ]
then
ln /dev/block/loop5 /dev/loop5
fi
if [ ! -e /dev/loop6 ]
then
ln /dev/block/loop6 /dev/loop6
fi
if [ ! -e /dev/loop7 ]
then
ln /dev/block/loop7 /dev/loop7
fi
mount -o loop,noatime -t ext2 /sdcard/debian/debian.img /data/local/debian/mnt
busybox mount -o bind /sdcard /data/local/debian/mnt/sdcard
export PATH=/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
export USER=root
busybox mount -t proc none /data/local/debian/mnt/proc
busybox mount -t sysfs sysfs /data/local/debian/mnt/sys
busybox mount -t devpts devpts /data/local/debian/mnt/dev/pts
if [ ! -e /data/local/debian/installed ]
then
busybox chroot /data/local/debian/mnt/ /debootstrap/debootstrap --second-stage
touch /data/local/debian/installed
fi
I saved this script as mountdeb.sh and the debian.img file in a folder called "debian" at the root of the SD card and mounted it on my G1 again.
I used a terminal emulator (search Market for Terminal Emulator by ZTA Technologies). First to enable things like tab completion and command history I changed the initial command (done through the menu in the Terminal) to:
su -c "busybox sh"
which nicely drops you in busybox as root instead of the poor implementation of sh that android comes with by default.

Running:
/sdcard/debian/mountdeb.sh
chroot /data/local/debian/mnt/ /bin/bash
drops you into bash in your shiny new Debian installation from which you can use apt-get to install whatever you feel like.

Automating the Installation
Since I didn't want to have to type the above into the phone every time I wanted to use Debian on my phone and I also much preferred being able to use ConnectBot to access it I automated starting it as follows:

First I installed the dropbear ssh server onto the Debian install:
apt-get install dropbear
This allowed me to either ssh to localhost from the phone or ssh in from my computer, which I was quite glad of after typing on the small keyboard for a while. Next to automate it.

Cyanogenmod provides facilities for auto running scripts using /etc/init.d/ however these all get run before android mounts /sdcard which means that we can't run our script at this point unless we mount /sdcard ourselves (which does work but it means that none of the applications on the phone will be able to access /sdcard (I think there may be a way to change this by messing around with permissions but I haven't tried it yet)).

Since init.d ran things to early I found an autorun application called Phone Prioritizer (available here (put the .apk in the attached zip on your SD card and open it with the package installer. Unfortunately you have to register on the XDA forums to get it), not on Market for some reason) which allows a script to be executed once the system has started up (Broadcast the BOOT_COMPLETED intent), it also had some options for running cron like scripts but I disabled these for the moment. To start the Debian chroot I edited /sdcard/phonePrioritizer/afterboot.txt (the file it checks after booting) to read:
busybox sh /sdcard/debian/mountdeb.sh
busybox chroot /data/local/debian/mnt/ /usr/sbin/dropbear
Rebooting the phone I found I could immediately ssh in using ConnectBot on the phone. Some simple certificate setup later and I didn't even need to type in a password from the phone to itself. :)

If anyone tries to follow these instructions let me know if you have any problems.