Monthly Archive for June, 2007

XML is supposed to be easy to parse, right?

Apparently not if you are using PHP.

Seeing that PHP is a web language, it only makes sense that it should have some functions for parsing XML documents.  Well, as it turns out, the closest thing that it has is XMLReader.  It sounds good, right?  Too bad there is little-to-no documentation on it because it is so new.  Furthermore, it was unnecessarily complicated for my purposes.  I just needed it to read an XML feed from Weather.com.  After a little bit of experimentation, I was able to to get it to do some stuff.  However, it just wasn’t doing what I needed it to do.  So, I ended up writing my own implementation for an XML reader that was specific to the Weather.com feed.  It grabs the current conditions and the forecast and stores it into a neat little array that is formatted into a nice looking table on the main page (I’ll try to get a screenshot up later).  I ended up using icons from the Weather widget for an awesome widget program called Screenlets.  So, now, the weather box is working fine.  That makes me happier.  Although I nearly drove myself insane trying to get the XML parser to work.  I ended up just using a bunch of explode() calls, although I probably could have done a better job with Regex.  Also, I was able to get the email to load asynchronously, so the load time of the page is much faster now.

What PHP really needs is a function that will take XML data and turn it into a multi-branched array.  It shouldn’t be that hard to do.  Maybe I’ll write one myself one day.

libgmail is amazing.

There are a few APIs out there for grabbing your email from a Gmail account.  I decided to try out libgmail, an API written in Python.  I am simply astounded at the number of different functions available.  It supports managing the contacts list, different folders and labels, threads, messages in those threads, and tons of other things.  Of course, I only need it to provide data for an interface similar to iGoogle’s Gmail widget/gadget/some-other-synonym.  On the downside, it is a bit slow, and most of that occurs from the login process.  So, instead of having the list of mail refresh every few minutes, I have a little counter at the bottom right of the screen that will refresh every 3 minutes using AJAX.  This method works fairly well.  LightTPD doesn’t want to play nicely with Python either, so I have to use a PHP script wrapper that calls shell_exec(“python getemail.py”); in order to get my email.  A little hackish, yes.  But it does the job without slowing things down too much.
I also have finished the PHP template.  I’m so used to designing them now, it only took me around 5 minutes.  So far, so good.

Preliminary Layout Design

Here’s an actual screenshot of the layout so far (click for a larger view):

Layout

I’m keeping to my concept design pretty well, surprisingly enough. I tried running this in a fullscreen Firefox window on the monitor and it looks great (I don’t have a touchscreen yet, so I’ve just been using some random monitor that has been lying around). The logo needs to be nudged to the left just a bit, though. My CSS is pretty heavy; over 50 lines of code already. However, the computer seems to have no problem loading the pages. Once I have finished perfecting the basic layout, I’ll whip up a PHP template to take care of interface consistency problems.

PHP seems to have good support for both XML parsing (for the weather applet) and INI parsing (for keeping track of the radio stations). On that note, I’ve got an INI system floating about in my head. It works something like this:

All of the stations are stored in stations.ini. The format will be something like:

[station1]
name = “Station 1″
stream = “http://station1.tld/stream.mp3″
site = “http://station1.tld/”
playcount = 5

[station2]
name = “Station 2″
stream = “http://station2.tld/stream.mp3″
site = “http://station2.tld/”
playcount = 19

Et cetera.

[station1], [station2], etc. will all be fixed names. Everything else can be changed, of course.
When a song is selected, the name, stream, and site keys will all be copied to nowplaying.ini. When the sound system is paused, mpg321 (the backend MP3 player) will be killed and nowplaying.ini will be moved to paused.ini. When the system is unpaused, the reverse will happen.

Obviously, I’ve got to figure out some way to support non-MP3 streams.

Progress: Good.
Sanity: Good (for now).

Insert Witty Title Here

I forgot to mention that I can say that I have put my flesh and blood into the creation of this computer; I sliced my finger on a piece of metal when installing the backplate.

I replaced the 2.4.33.3 kernel with a 2.6 series kernel (2.6.21.5). After three attempts, I finally got everything right. I decided to go with a 2.6 kernel because it supports preemption and allows me to change the timings as well. It helped clear up a problem where XMMS was skipping while trying to play audio. Also, I have support for I2C thanks to the Fintek F71805 chip, which monitors my hardware. So, I’ll probably stick some hardware information somewhere in the interface (possibly in the “System” tab).

I’ve got the latest versions of PHP and LightTPD installed now. I had to hack LightTPD a bit to allow root to run it, but I am actually able to use PHP to start playing a radio station. PHP calls exec(play.sh). In turn, play.sh calls mpg321 `cat stream`, where stream is the name of the file containing the MP3 stream. There seems to be no problem with skipping even with intensive processes running in the background, although after a while, the station starts to make periodic popping sounds. I’ll have to look into that.

I also found that I could clock the processor down to 400MHz without major performance repercussions, which is pretty amazing. Even with half the clock speed, things run very smoothly. At this lower speed, the CPU only runs at about 15°C. I’m not sure how happy I am with the hard drive, though; it seems to heat up the case quite a bit and is louder than I expected that it would be. Even with that, the system is extremely quiet. I might replace the fans in the future, but I can barely hear them right now.

Things that I have left to do: set up the autologin system, build the interface(!!!), and securify everything. After that, it will be usable. Although, once I buy the touchscreen, I’m going to have to recompile the kernel with support for it.

45.9 Seconds

No, I didn’t make another computer in that span of time. However, that is how long Sophos takes to boot up from a press of the power button. The BIOS screen is about 5 seconds long, which isn’t bad. The new kernel that I installed (all modules removed) seems to load fairly quickly as well. I’m also using Fluxbox now instead of XFCE because it loads immediately. However, the init structure needs to be redefined a bit in order to speed things up. I think I’m going to switch to a 2.6 kernel instead as well, because I seem to have a bit of a problem with multitasking on this machine. Overall, however, I’m pleased with the results. I might even clock the CPU down a little from its stock 800MHz in order to reduce the speeds of the fan by decreasing the temperature.

15 Minutes, 0 Instructions

That’s what it took to get the parts up and running (I eventually spent more time being careful with the wiring process in order to maximize ventilation). There’s really no other way to describe the joy of putting a computer together other than through pictures.


The parts came in two boxes. The left one was shipped from Tennessee and the one on the right was shipped from California. I’ve also got my computer kit on the table as well. Don’t mind the rust.


The box for the case.


Packing peanuts! Somehow I managed to keep most of them in the box. The hard drive is there on top.


The hard drive, the motherboard, and the RAM.


The motherboard and some extra parts that it came with.


The case.


:D


The bottom circuit board is the power adapter and the top one is for the front panel ports.


Another view.


A few parts that came with the case.


This part grabber is great for both screws that have been lost inside of a case (this happened several times to me) and for starting screws that are located in hard-to-reach spots.


The motherboard after it has been mounted in the case. I accidentally forgot to put the back plate in, so I had to remove the motherboard and install it again.


I quickly connected everything up to make sure that the parts were working. Later on, I improved the quality of my wiring.


I moved the computer to another room with an extra monitor. Here is the computer, hooked up to all the components except a CD-ROM drive.


There was only one large molex power connector, which needed to go to the hard drive. So, instead of buying a converter, I hooked up a CD-ROM drive by using the power from another box. Yes, the computers in the background were the ones that I used for my cluster. I only needed the CD-ROM drive to install Linux. I may buy a DVD drive later on, but it will have to be a slim drive in order to fit into the case.


Success! (I know that the case needs to be cleaned a bit.)


:D

I had a few issues. First of all, the Arch Linux installation CD decided that it didn’t want to play nice with my computer, so I decided to install Slackware instead. While compiling PHP, I noticed that the computer started to heat up like crazy. Then, I realized that the case fan was blocked. After fixing that problem (everything in case just fits), the computer cooled down again.

Next, I’m going to reconfigure the kernel and remove all the unnecessary items in order to reduce the load time. I’m also thinking of using Fluxbox instead of XFCE because it loads extremely quickly. My goal is to get the total load time down to around 30 seconds. There’s so much to do still.

The wait is exhausting.

The parts should be here in a day or two, but while I have been waiting for that, I have made a few sketches in my mind, on paper, and with the GIMP and Inkscape of what I want the user interface to look like.

Here is a very rough idea that has been floating around in my mind. It’s still extremely basic, but it more or less shows how I want things to look. For one thing, the rounded corners are of different radii right now, but I’ll fix that for the actual web version. My goal was to make the buttons big so that they could be easily used with a touch screen (I sort of violated that rule with the different categories and headlines in the News section). This is a layout for the homepage. Basically, it will collapse all of the other pages down into one interface. The email widget will function more or less like Google’s Gmail widget on iGoogle. Hopefully, I’ll be able to work a little shell script magic to get the Now Playing widget to display the current radio station and the elapsed time. The widget will contain the top 10 radio stations that the user has chosen. The Music page, however, can contain probably up to 50 or so, plus links to media libraries and stuff. I’m not sure what to do with the email page yet. I might just have it redirect to my Gmail account because I don’t feel like building a new interface. The Apps page will contain launchers for different applications (and will also launch the on-screen keyboard automatically for applications that will need it). Finally, the System page will contain system information, buttons for shutting down, and a few different settings to change.

I like the logo… :D

Sophos: A Revolution in Media

Okay, so it isn’t really a revolution in media, but it sounds good. The only thing about this project that will be different from all of the other media projects out there is the interface that I’m designing. I’m going to eventually be setting up a page at http://joeyjwc.x3fusion.com/sophos, which will contain information about the project.

As for the capitalization, Sophos will be the name of the computer. sophOS will be the name of the Arch-Linux-based distribution. The name itself comes from the Greek word σοφός (sofos), which means wise.

Hopefully, I’ll be ordering the parts this weekend if all goes well. The parts have been ordered!

Funds: Check!

I should be able to start buying parts next week. I’ve decided to go with a Seagate 80GB hard drive for $41 instead of the CF card setup. With a large hard drive like that, I can turn it into a small server, too. Many of the auctions that I was looking at for touchscreen monitors are now closed, so I may have to wait a bit until I can find something cheap again (in the meantime, I’ll just set it up with a spare monitor, mouse, and keyboard that I have). I’m also going to purchase a SilenX 80mm case fan to replace the one that comes by default. It’s only around 14dBA, but has great air flow at 1700 RPM. I intend to document the creation of this computer with a ton of pictures. All I need now is a name…

I think I’m approaching obsession.

Motherboard – JetWay J627F800-OC with a VIA C3 Processor – $84.99
It’s old, but it’ll do fine.

Memory – Kingston ValueRAM 256MB 184-pin DDR 266 SDRAM – $18.99
It was the cheapest stuff that I could find on NewEgg without dropping down to 128MB.

Storage – A-DATA Turbo 4GB CF Card – $41.99
I was going to use a quiet hard drive, but then I decided to try to build something with as few moving parts as possible. The clicking noise of well-used hard drives drives me insane.

Converter – SYBA IDE to Compact Flash Adapter – $14.99
The reviews for an adapter that would directly fit into the slot were pretty bad. However, this one doesn’t support DMA, so perhaps this other converter might be better if it came back in stock.

Case – iStarUSA S3 STORM Mini-ITX Tower with 80W Power Supply – $89.99
This is a really nice case. It is extremely compact, looks to have good cooling (I’ll probably replace the 80mm fan with a quieter one), and definitely looks very beautiful.

Total (minus shipping): $250.95

As for the touchscreen monitor, I have found several on eBay for as low as $60 with shipping.

The machine could boot extremely quickly with Slackware and a customized kernel. I could easily remove most of the init stuff that slows down system boot time. My ultimate goal would be to get it to start (from off to having the interface up and running) in about 15 seconds. I don’t know if I can reach that, though. I think that I would use a web-based interface. Perhaps I could make it compatible with iGoogle gadgets/widgets/whatever-they-call-them. The screen would be divided into several sections. At the top left-hand corner, there would be a section containing email. Ultimately, I would like to design a way for people to quickly respond (i.e. an on-screen keyboard would pop up or something). To the right of that could be a weather module or something. The bottom of the screen will be dedicated to the internet radio. It would only require a tap of the screen to select your favorite radio station.