Archive for the ‘Software’ Category

PSoC USB SuiteUSB .NET (CyUSB) Asynchronous Wrapper

Saturday, December 8th, 2007

This is the first of a few pieces of software I’ve written for my Senior Design project here at WMU. We created a device using a Cypress PSoC, and I wrote the user interface for the project in C#. I will be releasing a number of components from this project as open source.

If you’ve used the Cypress SuiteUSB .NET library, you’ll notice that they say asynchronously sending and receiving data to and from the device is the difficult way to access the device. Of course, one thing that contributes to the difficulty of using their interface is that its nothing like any other .NET asynchronous operations. If you have used .NET asynchronous sockets or file writing… well, you probably realize that the way Cypress decided to implement their library is definitely NOT .NET oriented, and in general is rather annoying for .NET programmers to use.

Well, it annoyed the heck out of me too, so I wrote a nice wrapper for it. Now, asynchronous sending and receiving is trivial. :)

This will allow you to wrap the EndPoints exposed by any CyUSBDevice, so that you can call .NET-style Begin/End asynchronous calls that use IO completion ports to work nicely and quickly. I do not have any benchmarks for it at this time, but I’d bet that it works faster than Cypress’s library.. of course, I could be wrong.

Does NOT support Isochronous transfers. Probably does not support ControlEndPoints either.

A set of demo code is provided.

Usage

It’s pretty trivial to use this class. Create an instance of it, then use it like any other BeginXXX/EndXXX pair in .NET. For example:

CyUSBAsyncWrapper usbComm;

// create the wrapper
private void Init(CyUSBDevice usbDevice){
	usbComm = new CyUSBAsyncWrapper(usbDevice.BulkOutEndPt);
}

// call this to begin transferring the data
private void SendData(byte [] data) {
	usbComm.BeginTransfer(data, data.Length, new AsyncCallback(EndTransfer), data);
}

// called on another thread when the transfer is complete
void EndTransfer(IAsyncResult result) {
	usbComm.EndTransfer(result);
}

Licensed under a BSD-style license. Let me know if you find any bugs.

Download: Link

Make BitTorrent/P2P less annoying at home using Linux, Iptables, and QoS

Saturday, November 17th, 2007

At home, I’ve been using a Linux router for as long as I can remember… since, a rather long time ago, I didn’t have money for a router but I happened to have an extra computer that I had been playing with Linux on it. So, I developed an ipchains script (which I eventually converted to iptables) to do NAT on it, and its worked pretty well ever since then. I honestly don’t remember where I derived the script from, however.

When I was in the dorms and afterwards in an apartment with others, we had used my Linux router, since it was pretty simple and theres a ton of things you can do with a Linux server. However, something we noticed (which wasn’t specific to this router) is that whenever someone was using BitTorrent or some other P2P app (you know, to download Linux distros and CC-licensed stuff), it would totally kill our internet access unless the person made their upload rate ridiculously low.. which is fine, unless a visitor stops by, plugs in, and forgets to turn their torrents down.

So, sometime last year I decided that there was probably a good way to filter different types of traffic so they don’t get excessive. Turns out, you can combine iptables and the QoS functionality of the kernel to do just that.

(more…)

MBR Love Note Responses

Tuesday, November 13th, 2007

I have to say, I didn’t quite expect the wide variety of responses to my “MBR Love Note“. And… it was on the front page of Digg and BoingBoing, among other places. Which, has driven a ton of random traffic to the site. :) :) :)

I’m not going to bother posting the Digg comments, a lot of them were so far off base and yet wildly amusing.

Cory Dotorow classified it as a “Scary MBR-nuking program.. “.. I don’t know if I would go that far, thats a bit of an exaggeration.

Brandon said “it was a [real, non-script kiddie] hack”.. thanks. :)
Gameboy genius filmed installation and booting of the love note and put it on YouTube… you can see it at his blog.

CustomPC wrote that “an expert assembly code programmer writes an app to make your computer greet you with a note when you switch it on”. Expert, eh? Really, its not all that hard…

As an aside, it really is quite trivial to uninstall the program. Look at the comments section for a hint if you really don’t have any idea. Though, you probably shouldn’t install it if you don’t have an idea. I don’t feel like dealing with thousands of people screwing their computer up. It probably (most likely) won’t destroy your computer by any stretch of the imagination..

My roommate Jon provided the text, which I believe he did get from ThinkGeek.

Oh, and yes, I did know the answers to the quiz when I made it. The only one I wasn’t 100% sure about on #3, but I was right when I looked it up. And the quiz is mostly for fun, but anyone who has messed with MBR’s and such should be able to get them right. And I would say a great deal of people *should* be able to get #1 right.

Inspired by XKCD: MBR Love Note

Sunday, November 11th, 2007

I am a huge fan of the webcomic, XKCD, which is a very geeky and amusing comic for those of you who haven’t read it. On Friday, the following comic was posted:

And this of course reminded me of when I first started programming — I started with assembly language in 2000 with an 80286 I got out of the trash. I quickly became interested in low-level system programming, and created a number of MBR-based programs and other random programs in assembly. I haven’t programmed in assembly in a couple years, but this was pretty simple once I started going. :)

In any case, the comic has inspired me to write a Windows-based program that can write a “love note” to the MBR and display it when the computer starts. And of course, just for fun it shows the “Missing operating system” message as well. Shown is a screenshot:

Roses are red… missing operating system.

(more…)