Archive

Archive for the ‘General’ Category

Wordpress category feeds

February 27th, 2010 GilesBathgate No comments

Today my colleague Ciaran showed me how I could create a category feed, so that I could keep posts related to OverlapStrap seperate from my other posts, and save having to post to two blogs, whilst still having the reprap related posts appear in the Reprap aggregation pipe. So with any luck this post won’t appear in the pipe, and actually serves as a test.

Categories: General Tags:

How to write an operating system (Part 2)

November 25th, 2009 GilesBathgate No comments

You may have read my previous post about writing a Hello World operating system. Although I did post this on April 1st it wasn’t actually a prank, and it does actually work.

I decided to improve the code. With the following replacement for main.c we can print “Hello World!” on the screen in a more developer friendly way.

char * vidmem = (char*)0xB8000;
int pos = 0;

void putc(char ch){
	vidmem[pos++] = ch;
	vidmem[pos++] = 0x7;
}

void puts(char* s){
	int c;
	for(c = 0; s[c] != '\0'; c++)
		putc(s[c]);
}

int main(){
	puts("Hello World!");
}

Now this is all very good, but suppose you need to check that some number in your os is some value that you expected, we are going to have to write a function to convert the number into an ascii representation before displaying it on the screen, we can’t use the itoa() function of the standard c library, because we didn’t compile it into our OS. We need to instead roll our own itoa function.

int strsize(char* str){
	int i;
	for(i = 0;str[i]!='\0';i++);
	return i;
}
char* strrev(char* str){
	char* tmp;
	int i = strsize(str) - 1;
	int j = 0;
	while(i>=0){
	    tmp[j] = str[i];
	    i--;
	    j++;
	}
	tmp[j] = '\0';

	return tmp;
}

char* toDigit(int n){
	char digits[10] = "0123456789";
	char* str;

	int i = 0;
	while(n/10){
		str[i] = digits[n%10];
		i++;
		n/=10;
	}
	str[i] = digits[n%10];
	i++;
	str[i] = '\0';

	return strrev(str);
}

This initial attempt might have worked, however its riddled with errors, which I have since learned about. For example returning a pointer to a stack variable, is probably not a good idea!
When I originally wrote this I hadn’t seen the Kerrigan an Ritchie implementation thier implementation is much better has more features, and less bugs. After re-writing the code my final version of main.c was as follows
Read more…

Categories: General Tags:

SC101T Linux Cluster

October 16th, 2009 GilesBathgate No comments

I recently aquired a Netgear SC101T Network storage device. After discovering that the device is not a NAS and instead was a SAN device I was at first a little disappointed. Furthermore the device uses a proprietry file system and a proprietry protocol called zSAN to access the device. Well fortunately someone has developed an SC101-NBD linux userspace driver that translates the proprietry zSAN protocol into linux nbd (Network Block Device) protocol. After downloading and compiling the driver at first nothing worked, and I found the reason to be that the driver was developed for the SC101 not the SC101T. After a bit of hunting around I found that someone had posted the following fix in on the driver support group forum.

The fix is pretty simple. In psan.c the functions ‘psan_query_disk’ and ‘psan_query_root’ pass an info’ value of ‘1′ into the ‘psan_get_t’ struct. Doing so seems to cause the ’select’ to fail in the ‘wait_for_packet’ function. Changing the value passed into ‘info’ to ‘0′ seems to allow the device, disks and partitions to be discovered fine – I’m now currently watching my linux box mkfs.ext3 /dev/nbd0

I followed the instructions and re-compiled the driver, this time it worked. Issuing a

sudo ut listall

Gave the following output

===============================================================================
VERSION : 1.1.3 ROOT IP ADDR : 192.168.2.5
TOTAL(MB): 610480 # PARTITIONS : 1
FREE (MB): 64
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PARTITION LABEL IP ADDR SIZE (MB)
F1A2F2EA-7C87-11DE-ACB7-0013A9D715B7 linux1 192.168.2.6 610407
===============================================================================
VERSION : 1.1.3 ROOT IP ADDR : 192.168.2.3
TOTAL(MB): 610480 # PARTITIONS : 1
FREE (MB): 133594
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PARTITION LABEL IP ADDR SIZE (MB)
2B4F7D24-67FE-11DE-8CC5-0013A9D715B7 linux0 192.168.2.4 476877
===============================================================================

This lists the partitions on the device that had been previously created using the Windows™ software. A partition can be attached by issuing

sudo ut attach F1A2F2EA-7C87-11DE-ACB7-0013A9D715B7 /dev/nbd0

So this provides block device access to the partition, to use the partition obviously one has to put a file system on it. The difference with this SAN based device and say a local hard disk device, is that a local harddisk is only accessed by one machine at a time. Since I wanted to access the device from multiple machines something like ext2fs is not suitable. What is much more suitable is gfs2 which is actually designed for SAN storage devices. To install gfs2 on debian based distributions you can run

sudo apt-get install gfs2-tools

mkfs.gfs2 -j 5 -t storage:linux0 /dev/nbd0

To actually mount the device the lock manager also has to be configured.

<?xml version="1.0"?>
<cluster name="storage" config_version="1">
<clusternodes>
<clusternode name="korma" nodeid="1">
<fence>
<method name="human">
<device name="last_resort" ipaddr="korma"/>
</method>
</fence>
</clusternode>
<clusternode name="tikka" nodeid="2">
<fence>
<method name="human">
<device name="last_resort" ipaddr="tikka"/>
</method>
</fence>
</clusternode>
</clusternodes>
<fencedevices>
<fencedevice name="last_resort" agent="fence_manual"/>
</fencedevices>
</cluster>

Read more…

Categories: General Tags:

Propellerhead Record

July 22nd, 2009 GilesBathgate No comments

Head over to recordyou.com and you will be able to download and authorize Record RC4 until September 9 when they hit the official release day.

Categories: General Tags: ,

Creating Tiny Windows executables with TCC

April 7th, 2009 GilesBathgate 1 comment

I recently compiled a small executable program writtern in C with the Visual Studio C++ Express. The output was a 56K executable, which ok is pretty small, but actually in terms of programs its really large.

So I looked into compiling my program with the TinyCC compiler.

First I downloaded the compiler, however it quickly came apparent that the libraries and includes that come with the compiler were just a minimal set. What I needed was the includes from MinGW. Its only necceccery to download the Windows 32 API package.

My program needed to be linked with winsock2 so first i needed to run

tiny_impdef c:\windows\system32\ws2_32.dll

This will generate a ws2_32.def file. I was then able to simply compile the program with.


tcc program.c ws2_32.def

The output of which is an executable of 1K. I asume because the compiler itself is small, and the compiler compiles itself that it would produce rather small executables. I have yet to test compiling the same program using mingw and GCC -Os.

Categories: General Tags:

Another Cat

October 26th, 2008 GilesBathgate No comments

We got another cat! We decided to call this one Mikey.Mikey

Categories: General Tags:

Cat

October 24th, 2008 GilesBathgate No comments

We got a new cat, we have named her KatieA photo of our cat Katie

Categories: General Tags:

Conversation with my Dad about “T’Internet”

September 6th, 2008 GilesBathgate No comments

Dad: “How do I turn off your Internet.”
Giles: “Its a router, you just leave it connected.” (He has an ADSL modem)
Dad: “But how do I close the website down so that its not connected to that website, I don’t want to hog that website.”
Giles: “HTTP is stateless meaning that the website is no longer connected as soon as you have finished loading the page.”
Dad: “Well with some websites you have to log off, like Banks, and they have a lot of problems when too many people are logged in.”
Giles: “The problems that Banks have are very specific to their applications, which is why for example you can’t press the back button on Barclays, because banks try to have stateful sessions built on top of HTTP which is stateless, but the rest of the web works the way I just said.”
Dad: “oh”

Later on my “Technophobic” Dad beat us all at Wii Bowling.

Categories: General Tags:

Finding aspnet_regiis.exe

July 8th, 2008 GilesBathgate 1 comment

Yet again I am searching the net for aspnet_regiis. I tried various combinations including asp_iisreg and aspiis_reg, both of which return results in google. so it seems that I am not the only one who keeps forgetting how it is called. I decided to put it here for my own personal reference. This tool usually has to be run using the -i parameter if you install IIS after you installed Visual Studio and you want to do web service type things.

Categories: General Tags:

Sidechain Reverb

April 5th, 2008 GilesBathgate No comments

Sidechain compression is not the only effect you can create in Reason using the MClass compressor. Those smart people at propellerheads were insigtful enough to give the MClass compressor a Gain Reduction CV out. Which you can use to control any parameter you like.


Here I am using the compressor to pump an RV7000 Reverb Start by creating a Combinator to host the RV7000 this allows you control parameters that would not otherwise be controllable using CV’s. I’ve put the compressor in the combinator too just to keep things tidy. The Gain Reduction CV output is connected to the Rotarty 1 input on the Combinator. This allows Rotary 1 to be routed to the Dry/Wet parameter of the RV7000.

The overall effect of this setup isn’t that great, but the point is that you can use sidechaining to control any parameter in Reason.

Categories: General Tags: ,