Communicating with SPCI
Background Story/Flavor Text
So I’m working on getting this ammeter to interface with Linux system for the lab, and it turns out that this thing supports the Standard Commands for Programmable Instruments (SCPI). A few hours, Google searches, and Perl scripts after I started, I’d done what I would call a reasonable job of communicating with this device and pulling data from it.
So what is SPCI, and how does it work?
Connecting the Interface
SPCI is just a standard set of commands, not a defined interface. But it turns out that when you’re communicating with electronics SPCI is often used over serial connections like GPIB or RS-232. In my case, I was forced to use RS-232 because of hardware limitations.
Now, you can just read and write directly with the device handle. In my case using RS-232, I ended up discovering that
/dev/ttyS0
was right for me.
Commands
The entire set of commands is found in this documentation from the IVI foundation site. The commands are organized in a directory like structure. If I want to execute the command to ask how many errors messages are sitting in the buffer, for example, I’ll execute this:
:SYST:ERR:COUNT?
What this effectively seems to do is…
- Go to the “root” directory [:]
- Look in the SYST(em) folder [SYST]
- Look in the ERR(or) folder [:ERR]
- Execute the COUNT command [COUNT]
- Note that this is a query; i.e. returned data is expected [?]
Each command has as:
:SYSTEM:ERROR:COUNT? :System:Err:Count? Syst:ERROR:COUNT?
Note that you can vary capitalization without consequence, you can choose to ignore that prefixed colon, and you can even mix around when you use long and short forms.
Example
I used SCPI to communicate with a Keithley 6485 Picoammeter. I doubt seriously that many people reading this will ever need to repeat this task, but it’s all I have to present some examples.
To turn off the zero check on the picoammeter and take the current reading, we could execute these commands:
Syst:ZCh 0 Read?
Note that I could have used “OFF” in place of “0″; either is a legitimate boolean value for “false”. Meanwhile, a script running in the background that looks something like this:
#!/bin/bash cat /dev/ttyS0 >> datafile
Will magically receive a line of data from the machine that we can interpret with a simple Perl script.
Google Voice fails again
What the message really said:
I choose to pronounce the poem “A leaf falls, loneliness”, but that’s not really right, and uh, I think you’d be hard pressed to find someone who could, uh, pronounce it effectively, who’s still alive.
What Google Voice thought it said:
Hi juice pronounce the palm of leave Falls luminous, but that’s not really right and I think you’d be hard pressed to find some of yourgroup. I’m good pronounce it effectively. You still alive.
Learning to play guitar
I’ve been lightly working on learning to play my guitar for the past few weeks. This is something I tried several times since I picked up the instrument a few years ago, but I was never able to commit myself for more than a few days, until now. I’m lucky because I have Mark, my roommate, teaching me in a way I can understand pretty well. I can play four or five chords now, and I’m understanding some basic music theory. A lot of this theory is interesting enough that I might start posting about it when I’m more familiar with it.
In other news, I feel like I’ve gotten nothing accomplished lately. I have these things lingering around that I need to get to, including:
- Packaging Xinha (I already make a working RPM, I just need someone to help me clean it up before I submit it)
- Finish my summer research paper
- Put together a 30 – 60 minute Perl presentation
- Go to the Botanical Gardens
- Make some tea?
Huh. Now that I spell it out, that doesn’t seem like too much. I do have two exams tomorrow, though. Maybe I should get on that right about now.
Let me share the rest of my week with you (because I’m bored and don’t feel like studying!):
- Tonight (Tuesday): Study
- Wednesday: Probability test in the morning, Mechanics in the evening, Lab, Fedora Docs meeting
- Thursday: Yoga, read some more of Krik, Krak! for English, Creative Inquiry dinner, try to make it by Sosolik’s lab. Maybe the machine shop has Samantha’s part finished by now.
- Friday: Normal classes in the morning, see if Michelle wants to come watch LOTR/Star Wars with Mark and I (or just me, if Mark leaves). Also… a society of physics students meeting/social/party, I hear?
- Saturday: I hear something about a birthday party, but we’ll see if I make it. Otherwise, relax.
- Sunday: Do all the work I didn’t do Friday and Saturday, go to DnD, and…
- Actually, I don’t think I can plan this far ahead. Never mind.
- Perhaps it would be more useful to think in the short term. For example:
- My tea is ready!
Why do my titles rarely apply to most of my blog post content? Oh well.
How to: Making Windows Work Like It Should
Two days ago, I was trying to help my friend make his WinXP laptop connect to Clemson’s WPA2 Enterprise network. It knows how to do it (it’s done it many times before), but at that instant the computer just didn’t feel like cooperating. We tried several solutions, including rebooting (twice!) and re-entering all of the wireless settings. No success.

The Axe of Death, threatening to end the IBM Thinkpad if it didn't comply with our network-related requests.
Disgruntled, Mark (my friend) started to verbally assault the computer. Failing, he suggested a new approach: visually letting the computer know how frustrated I was. We opened up mspaint and I started to draw a laptop being hacked by a blood-stained battle axe. As I drew the woosh lines behind my axe – just so it was clear that the computer was about to be slaughtered – the innocent beige bubble popped up letting us know that, out of the blue, despite two minutes of sitting there after giving up trying to get an IP address, we had an excellent connection to tigernet (the wireless network).
We laughed. It was funny. What a coincidence, eh?
The next day (last night) the computer did it again. We opened the same bitmap we drew before… to no avail. This laptop knew what was going on. It knew it couldn’t actually be harmed by a bitmap image.
So I opened a command prompt and ran ‘format C:’. Before I could finish reading the warning line (Are you sure you want to do this? [y/n]), tigernet was connected.

The ultimate threat to the Windows machine, bringing an otherwise unruly computing device to its knees.
I have to commend Microsoft on the incredible user interaction they’ve instilled in their operating systems. Threatening to slaughter and then vaporize someone would probably make them do what you want, so I suppose this is replicating human interaction, right? Man, it’s a shame Fedora won’t respond to threats like that.
In other news, Mark installed Fedora after that incident last night. It connected instantly and hasn’t dropped the connection. No threatening bitmaps necessary.
In other news, my girlfriend tells me that her computer starting running much better in the past week as well. She also happened to be shopping for new netbooks online last weekend. Coincidence??
Google Voice Transcripts
Man, I hope Google Voice is still considered to be in Beta. An old friend called today (I’m not sure if it was directly to my number yet, or if it was via my Witticism Dropbox; I guess I’ll find out when I get back my physical phone). Part of what he actually said (quite clearly) was:
I was very proud of myself for figuring out your google voicemail
But Google Voice transcribed this:
Those are gonna suffer here at google voicemail
Which is much more sadistic and much more wrong. I suppose they’re still working on getting it right…
This isn’t an isolated incident; my voicemail transcriptions are 100% unreliable (which is not to say that they are 100% wrong, but wrong enough to be totally unreliable without checking the message manually). Example #2: I call my phone, looking for it around the house. I say:
Hmm… where are you, dumb phone? *sigh* I guess I’ll find you in a minute, bye.
Transcription:
Or you some phone I guess of on June the, but.
How to configure GDM? (or, Eye Candy = Performance)
Like many users’ personal machines, my computer doesn’t run at optimum capacity unless it has the right color scheme and eye candy. I spent the better half of the afternoon earlier decking out my Fluxbox setup with some fun new themes, xcompmgr, and some aterm-pimping.

Fluxbox screenshot shamelessly stolen from a gnome-look.org contributer. The User Guide content (in my special XML), however, is completely original.
Question, though: what happened to GDM configuration gui? I seem to remember it back in like… Fedora 7 (Moonshine)? Maybe even F8? I went into /usr/share/backgrounds today and changed up leonidas.xml so I could at least get a different background image at the login screen, but I have no interest in going much further than that.
Was this an upstream thing, or a Fedora thing?
Don’t tell me! I’m sure lots of people have asked, and people who are more observant than me are tired of saying why it happened.
Unless you really want to tell me.
Because it bothers me. Although I think I do remember something about it undergoing a rewrite… but hasn’t it been a while? Is it being redone from scratch? idk.
I’m writing the User Guide, directed at people who don’t know Linux well enough to go edit leonidas.xml, and they’ll want to change up the eye candy. I know they will. I wish I had an answer for them…
PS: I added a screenshot of gdmsetup from Fedora 6, but then I opened Empathy from the dock and X though that would be a good reason to crash. Guess I should file a bug report on that; second time it’s happened today. Good thing WordPress autosaves drafts.
Seasons of Code
When I joined the Fedora Project last year, it was a pretty big deal to me. A college freshman, I’d used Linux for a few years and enjoyed it but never really contributed anything back upstream except for the occasional automated bug report.
A year later, I’m very glad I got involved in open source. But I know plenty of very smart people about my age – oftentimes people I think would be even better at this stuff than I am – who don’t join projects or contribute back upstream for no reason other than that it’s not easily accessible for them.
I’ve been sort of monitoring a student from my old high school as he works on his senior thesis. The project is improving security for Sesame. Some of the first questions he started asking his thesis mentor made it pretty clear that he wasn’t sure where to start or how contact project members. Moreover, I’m not entirely sure that he was clear on how open source development even progresses (c’est á dire, he had never been outside of the Cathedral).
I remembered my own thesis project which involved a new type of spam detection that I built as a plugin of sorts to SpamAssassin. I remembered how confused I was about open source projects too, and now I’m wondering: if someone makes a conscious effort to open up opportunities in the open source world to students, especially high schoolers and younger college students, could we make:
- A significant boost in the number of people interested in computers who manifest that hobby in the open source world (in other words, can we increase our contributer numbers?), or
- For those that don’t necessarily become contributers, can we at least get them to try Linux? Consequently, since that’s one of the strongest demographics in terms of driving the computing market (a statement I’m completely hypothesizing with no hard numbers), can we make a dent in the consumer world where more developers support OSS or, at the very least, Linux releases?
When I thought of this, the first thing that came to mind was Google’s Summer of Code. But this is a summer thing and it usually targets pretty complex tasks. It also costs money. What if there was a web community where hackers could post jobs of various difficulty or depth with the intent of having students pick them up? There would (probably) be no payment involved, but I have a feeling that lots of students who need projects for school or who are sort of curious but have no obvious point of entry to the open source community would be happy to pick up small tasks if they’re spoon fed to them (at least in the beginning). Course instructors/professors could even use these postings as projects for their classes which have a real effect in the world – that’s perhaps the best case scenario that I could think of.
Maybe.
Maybe not.
Just an idea.
OS X niceties in Linux: a second look
Being both a Linux and OS X user, I’m often left in one operating system wishing I had access to $convenient_feature in the other system. Two big OS X features that I miss in Fedora are Automator and Growl.
Yes, I know; a unified notification system has been implemented in GNOME (I think; I know it is in Ubuntu/Mint, but since I usually use Fedora and I usually use barebones Fluxbox, I can’t really say if it’s in Fedora yet). I’ll go ahead and complain, though, that it isn’t as extensive as Growl is. All I’ve seen it do is brightness and volume. I’ve read a tutorial on how to easily implement notifications in applications though, so perhaps it’ll just take a bit of time for applications to jump on the bandwagon.
The other feature, Automator, is something that, as far as I know, certainly is far off. There is a tool called GNU Xnee which has X11 macro recording capabilities, but the capacities are nowhere close to what’s available in OS X’s Automator, because it can’t harness specific application functions or easily pipe I/O. In my opinion, this is more than another centralization issue; the most popular OS X apps are from Apple, so they all have great Automator support… but non-Apple applications like Growl, Quicksilver, Fetch, and the Microsoft Office 2008 suite also have hooks in Automator, so I imagine Apple has made it easy to interface with.
Do I really need Automator in Linux? Not really, no. I have this much better thing called the command line. But as I rewrite the Fedora Desktop Guide (more on that later) I think more and more about new users who have little experience with scripting. There are GUI programming tools to teach concepts to newcomers, but I think something that actually has practical purpose would be more useful for a beginner who wants to harness the power of Linux. Besides, in the age of the graphical desktop, I think being able to pipe I/O between applications should be nearly as easy in a graphical fashion as it is on the command line… if slightly less powerful.
Enough ranting. Just finished a Perl script to run 300ish Monte Carlo simulations for me while I’m asleep. Time for bed.
PS: This post is a “second look” because I already discussed Automator-ish functionality in the comments of a previous post.
Quicktip: Ignoring the fingerprint reader for sudo
I thought that ease of use with fingerprint scanners was a great feature in Fedora 11. I enjoy having it on my desk to login, because it’s kinda cool and it lights up and such. I do use it to login from GDM and such.
I have to say, though, it kind of irritates me when I’m using a console and sudo prompts me for my fingerprint. I’m not saying that this is poor functionality, and if I was using a more secure password on my home computer than I might actually appreciate this. But if you’re like me and you don’t really care so much about security on a machine inside your house behind firewalls and such, then maybe you’re irritated as well. I thought I’d share a tiny and easy idea I had that nonetheless makes sudo more convenient for me in the CLI. In your .bashrc, just add an alias so that sudo is called with the -p flag:
alias sudo = 'sudo -p "Password: " '
The -p flag substitutes sudo’s default prompt (which I suppose is provided by fprintd) with one you specify (in this case, “Password: “). And there you have it! Another option if you don’t want to ditch the fingerprint scanner all together would be to simply give the alias a different name (like, say, sudopw).