Jython: Love and Hate

Posted by Eric Stein - February 7, 2011 CE @ 06:26:02 UTC
From my experiences using Jython to work with the DyIO, I learned a fair bit about what it's like to work with Jython today. I ran into issues with older versions of Jython not supporting generator functions (yield syntax) so I upgraded to the latest (as of today), 2.5.2rc3.

The 'batteries' that I've become accustomed to with CPython - the standard implementation - mostly exist, but are subtly different here and there. I won't go into details, as I don't have a bone to pick. The issues I see here are that there are areas of the Python language/runtime that are not very precisely specified, and as such, will be implemented differently by other implementors. This results in modules written against CPython will often fail in strange ways on Jython.

In my work, I solved some of these issues by adding the CPython site-packages and python-support directories to sys.path, but that's not perfect, and could even result in errors in code built for the Jython platform initially. I would like to see a world where pure python applications will run on either without issues, but that's not the world we have today.

I originally intended to run my whole project on Jython as a learning experience and to evaluate its performance, but I ended up writing a simple TCP/JSON API (my preferred serialization library didn't run well on Jython, so I had to use JSON) to abstract away the parts of my project that required Jython into a separate daemon; I didn't want to run everything under Jython anymore as it was causing periodic headaches. Incidentally, for my application, it's useful to have that separation so as to not require local hardware.

In short, Jython saved me a lot of trouble and is a new and useful wrench in my toolbox, but I'm a bit disappointed in the level of CPython compatibility that it has.
Last Edited February 7, 2011 CE @ 06:29:53 UTC
To the comments...

DyIO + Jython = <3

Posted by Eric Stein - February 6, 2011 CE @ 03:57:33 UTC
I've been working on and off (mostly off) on a project of mine for home monitoring called Ramirez. I need temperature and switch sensing ability. I'd tried a few things here and there with Arduino, etc, but that always meant writing my own communications protocol over the serial bus and I never got the enthusiasm up to get anywhere with it. The project I'm building needs the data to get to a full scale computer, not an embedded board, so I needed something that would let me do that easily.

I heard a few weeks ago from my friends at Neuron Robotics that their digital/analog I/O breakout kit called the DyIO was finally available! I remember a good ways back when they were designing this while we were still in school. It always seemed like a great idea, and I jumped on the chance to buy one. Before getting it Kevin gave me a few tips - including that it was possible to get it going with python code using Jython.

I started hacking on getting it to work with Jython tonight. I had a few issues trying to translate the Java examples to Python. However, Kevin was able to both fix a small bug I found in the Neuron Robotics Development Kit and help me get a small proof of concept running.

Proof of Concept


I haven't got the correct thermistors in from DigiKey yet, so I'm starting out with a simple digital in. In this example, I have plugged a switch into channel 0 on the DyIO module (pins are S and -) and connected the module to my Ubuntu laptop using USB.
eastein@numenor:~/dev/ramirez/mcore/plug$ cat jdyio.py
#!/usr/bin/env jython

import sys, time

sys.path.append('/home/eastein/nr-sdk/nrsdk-0.3.7.a-jar-with-dependencies.jar')

from com.neuronrobotics.sdk.dyio import DyIO
from com.neuronrobotics.sdk.dyio.peripherals import DigitalInputChannel
from com.neuronrobotics.sdk.serial import SerialConnection

if __name__ == '__main__' :
        dyio = DyIO(SerialConnection("/dev/ttyACM0"))
        dyio.connect()
        dig = DigitalInputChannel(dyio.getChannel(0))

        while True :
                print dig.isHigh()
                time.sleep(.25)
eastein@numenor:~/dev/ramirez/mcore/plug$ ./jdyio.py
RXTX Warning:  Removing stale lock file. /var/lock/LCK..ttyACM0
0
0
0
1
1
0
1
1
1
1
1
1
1
1
1
eastein@numenor:~/dev/ramirez/mcore/plug$

Where To?


Now that I've got a quick connection to the DyIO proofed, I'll be working more on the sensor history and eventing systems within Ramirez. Soon: madness such as text alerts when my fridge temperature goes out of normal parameters for too long or my front door opens when I'm not home.
Last Edited February 6, 2011 CE @ 04:00:59 UTC
To the comments...

Music Streaming with MiniDLNA and foobar2000

Posted by Eric Stein - January 30, 2011 CE @ 21:54:21 UTC
I recently build a new machine for gaming, running Windows 7. Since I'll be dual booting it, I am looking to install as little as possible onto the Windows partition. To this end, I sought a way to stream the music backups I store on my home server to any machine in the apartment.

There are a few routes: sharing files, or streaming servers. Sharing files is a bit clumsy as some devices like set-top boxes support streaming better. Of all the streaming protocols, DLNA seems to be the top contender these days: most home A/V systems seem to support it, and all popular OSes seem to have support either built in or in some of the popular music software. I believe iTunes uses it natively.

MiniDLNA

I looked up a few lists of DLNA streaming servers and found that there are quite a few servers out there. I chose from DLNA media servers, by looking over the webpages for the products. To be honest I just chose the one that seemed less commercial, and it worked out. Installation of MiniDLNA was quick and easy on my Gentoo machine: all I had to do was edit the config file to point it at the directory where my music is stored and ensure the settings were for read-only use.

foobar2000 + UPnP/DLNA Renderer, Server, Control Point

For the last few years I'd heard that foobar2000 was one of the best minimal music players for Windows, so it's what I went for first. I found a helpful plugin by bubblegum called UPnP/DLNA Renderer, Server, Control PoinUPnP/DLNA Renderer, Server, Control Point that does the trick: I use the UPnP browser to select music and stream it.

But Wait, There's More!

Not quite yet, but there is promise in the ability to do the same from RhythmBox on Linux. I'll be trying that out to stream when not at home, and eventually in my Linux dual boot on this machine.
To the comments...

My New Years Resolution: No New Years Resolutions

Posted by Eric Stein - January 2, 2011 CE @ 01:30:55 UTC
I'm not making any new years resolutions this year, not with any particular ends in mind. I read this post about what makes lasting change a few hours ago and it rings true with me.

I'm going to try to get out of my head when I'm not being happy and whenever I find myself finding excuses to just do the same thing as always, look at what would actually make a difference instead.

Carpe annum!
To the comments...

Inbox Zero

Posted by Eric Stein - December 29, 2010 CE @ 20:36:44 UTC
When you've got a pile of email coming in all the time, some of which can be immediately acted on and some can't, you may find yourself with a feeling of paralysis when you look at your inbox with 17 unread messages from a week ago and 4,724 from the last few years (read). If you feel it, keep reading.

Reclaim Your Inbox

There's a recent trend among Dyn employees, particularly in support, to try something called "Inbox Zero." Today I'd heard it enough times that I had to find out what it was. I asked Alan and he sent me this hour long video that I started watching in the background while scraping through my mail in the morning hours.

Strangely, today became the biggest day in getting lots of email demanding my attention and action I've had in months, all while I was learning about Inbox Zero. The idea is to have nothing in your inbox. This is surprisingly easy to achieve.

I got a few additional tips from Alan.

It only took about an hour to sort through my mail and get it filed in such a way that I can now log into my email and see only things that I haven't seen and I need to act on. It's calming and I'm more productive.
Last Edited February 7, 2011 CE @ 06:40:07 UTC
To the comments...

Twitter Stole Your Diary

Posted by Eric Stein - December 19, 2010 CE @ 05:17:11 UTC
If you're an avid user of Twitter, like me, you may have noticed that you don't write a journal anymore. Twitter has replaced your diary; you may find yourself viewing your life through the lens of twitter. There: now if you're going to disagree with me really loudly, you've probably gotten it out of the way already.

So?

There's a problem with this, a problem you may not realize. Unless you're Tucker Max, you may actually have moments and thoughts that you don't want to shout to the world, or even your friends. The problem isn't privacy, though. The problem is that once you start using Twitter to chronicle your life, you might just not write about private things. Your journal isn't a confessor and a moment of reflection anymore; you've forgotten you used to write in it.

But..

You don't use Twitter, you say? This really applies to any social networking platform. If it still doesn't apply, this post isn't about you. This post is about the people who forgot their journal.
To the comments...

I'm Psyched for this 0.1.5 Release, Guys

Posted by Eric Stein - December 14, 2010 CE @ 19:46:54 UTC
I've been actually doing my TODOs a lot more reliably lately. This means that my Psyched instance on my phone ends up with a ton of things filling up the interface that are already checked off. I got tired of this; now Psyched has a feature for hiding completed tasks. It's also got a few other minor UI improvements.

Check out the Psyched page for the release!
Last Edited December 17, 2010 CE @ 05:56:28 UTC
To the comments...

When Life Gives You Lemons...

Posted by Eric Stein - December 12, 2010 CE @ 23:21:14 UTC
I'm currently in Atherton, CA at my friend Katy's place for a bit. Katy and Casey had a joint birthday party; party construction was under way. Since they just moved into this new (quite awesome) house, they hadn't quite figured out what to do with the lemon tree yet. It produces a wide variety of insane lemons (some of them are small, some of them are huge. Some of them look like a wizard turned an evil person into a lemon.

So, I made hard lemonade. First, pick lemons. Next, put lemons (sans peel and seeds) into food processor. Process until in a nice slurry. Strain through a wire mesh to get "homestyle" lemon juice of the freshest kind.

After that it gets quite simple; blend the ingredients as follows together, serve cold with ice.

Serve and enjoy!
To the comments...

Psyched 0.1.4 Released

Posted by Eric Stein - November 23, 2010 CE @ 05:27:33 UTC

History of Psyched

I've been maintaining my calendar application for over 2 years now. The first release was in January 2008. I use in on my Nokia N900 daily, and on my Linux laptop at work. I plan on soon getting it added to the testing apt repositories for the N900 (freemoe). Right now it's not easy to invoke on Maemo, and requires installing libraries from the N810.

Today's Release

Today's release is nothing special: it just allows entering times and durations a bit more freeform, not requiring colons. This makes it easier to enter on a phone especially. There is a difference that exists here: before, any duration that didn't contain a colon character would be considered a decimal number of minutes; now, the colon is assumed to be entered, and anything to the left of the right-hand 2 digits is hours, not hundreds of minutes.

To download the release, check out the Psyched page.
To the comments...

Ramirez, Ping my Cellphone!

Posted by Eric Stein - July 27, 2010 CE @ 17:06:20 UTC
So, here's the idea: something that's sort of munin, sort of nagios, and doesn't monitor computers. Instead, Ramirez monitors you. He'll sit in your UNIX machine, doing his damndest to figure out what you're doing and when.

The eventual goal is to be able to take various state feeds (is your phone on the LAN, is the shower on, is the toilet being flushed, is the fridge open, tempearture outside, temperature inside, when did you last tweet, is the A/C on, is the apartment door open) and infer things about you. Having a direct mobile interface is important as well.

Potential Ramirez applications:
The list goes on. So far I've got 1 svn repository, 1 sensor, 2 commits, and 9000 ideas...
Last Edited October 9, 2011 CE @ 04:34:10 UTC
To the comments...
Valid XHTML, CSS, RSS | 1ms | Copyright 2004-2024 Eric Stein