Thursday, February 21, 2008

Screen as Serial Terminal

At work we use minicom on our Linux workstations to connect to the serial port of our development hardware. It works fine, but it's very text oriented. It also loses everything in the window if you re-size it. I've sometimes wondered if there are better alternatives, and today someone on one of our internal forums gave me a nice list. Sadly I couldn't find any of the suggestions for our old Red Hat 8 development boxes, except screen.

I've used screen before and it's great. I had no idea it could do serial communication too. Here's the command I used for our environment:


screen /dev/ttyS0 115200,cs8,-ixon,-ixon,istrip

I also have this .screenrc file that someone gave me years ago:


# kill startup message
startup_message off

# define a bigger scrollback, default is 100 lines
defscrollback 1024

# remap CTRL-A to CTRL-]
escape ^]]

# status bar
hardstatus on
hardstatus alwayslastline "%{rk}%H %{gk}%c %{yk}%M%d %{wk}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{wk}%?%+Lw%?"

That gives you better key bindings and a nice colorful stats line at the bottom of the windows.

Advantages over minicom are, you can resize the window and you don't lose anything, you have screen's cool detached mode functionality, and there are a million other little nifty things that screen can do that you might find useful (man screen some rainy afternoon). You might be used to screen keybindings already too. A downside is, with minicom you can run it in an xterm with a scroll bar and use your wheelie mouse to scroll the buffer. That's handy. I can't get screen to do that.

UPDATE: You can scroll with your wheel mouse if you run screen in a recent version of gnome-terminal. See the comments on this entry.

UPDATE 2: There's another way to scroll screen output with your mouse that works exactly like minicom. See comment number 4 below.

Let me just say at this point that I should have already learned from emacs that when dealing with a UNIX program that has been in use since before I first touched a computer, never say that it can't do something, because it totally can.

Print Free Graph Paper

This is just too cool. You can print your own graph paper. Not just any graph paper, you can choose from these types:

  • Cartesian Graph Paper
  • Engineering Graph Paper
  • Polar Graph Paper
  • Isometric Graph Paper
  • Logarithmic Graph Paper
  • Hexagonal Graph Paper
  • Probability Graph Paper
  • Smith Chart Graph Paper

You can customize paper size, units of measure, and grid-size within each of those, and I had never even heard of Probability Graph Paper! How cool is probability graph paper? Seeing a Smith Chart brought back some great memories from college. I almost printed one out just to hang on my wall. Very cool stuff.

Wednesday, February 13, 2008

Throw Some Cold Water On That

If you need some good old pragmatic engineering cynicism to counter all the Steveys, Joels, and Pauls of the software blogosphere, go read the discipline and punish blog for a bit. Pretty insightful in a lot of places, and a good counterpoint to a lot of what those crazy programmer/bloggers are saying.

Monday, February 11, 2008

No, I must be a noob

I spoke too soon in favor of Stevey's latest. I'm looking at all my C++ code now in a totally different light, and questioning everything...does that really need to be an enum there, or just an int? I was going to turn that C-function into a static function of this class, should I bother now? Do I need that error handler class like I was thinking Friday, or should I just stick a couple functions in this file? Are namespaces useless metadata too? Gee thanks, Steve! I mean, what do you want, for us to all write quick and dirty spaghetti code? After all, the experts who maintain it should be able to figure it out. Why don't we just write machine code, it's closer to the computation, without any verbose and useless metadata, right? Can we get a little moderation here?

If you can't tell, I'm torn. I like what Steve had to say, but I hate it. I must be a noob still.

I'm At Least a Teenager, Right?

I think I'm beyond the noob stage Steve describes. I can definitely recall writing some comments like he describes a few years ago. I don't do it now. Usually. I admit that I did for that hairy calibration code just a couple months ago, for the algorithm that was handed down by the analog EE that I was supposed to just trust with blind faith. I couldn't do it. I had to understand how it worked. I read up on flyback regulators and peppered that code with so much metadata (now that I know that's what it's called) that comments and types were spilling out at every seam. So I have to disagree with Steve's conclusion a little here. He rightly points out that using the narrative style of commenting and other kinds of metadata are ways for us to learn about what we are doing, that it's a way to solidify our thought processes. His conclusion seems to be that this is a bad thing overall and that we should strive to avoid it. Personally, I hope I'm always working on stuff that is challenging enough to require some metadata discussion with myself to get it right. I wouldn't feel like I was learning anything anymore if I didn't, and that's no fun.

To be fair, he's really not railing against what I'm talking about though. He's more against those that are into modeling to an extreme for the sake of modeling. I totally agree with his sentiments there. This is an excellent read for any programmer. I know because I agreed with what he wrote so much :-) I love how he can take these thoughts that have been sort of half-way forming at the back of my mind and express them so clearly. Or at least he makes me feel like I was on the verge of making that same brilliant conclusion. It's very flattering.

Sunday, February 10, 2008

Friday, February 1, 2008

Puppy Linux

I've been making a point lately of perusing "The Official Site of the Embedded Development Community," since I consider myself an embedded developer, and well, apparently that's the "Official Site," um, for my, uh, "Community." It seems more like place for vendors and consultants to promote their business by writing promotional pieces thinly veiled as technical articles, but if it's Official who is a young upstart like me to judge. Anyway, that's really beside my point. The reason I'm writing is that there was one article that caught my eye this week about building your own Linux distribution. The main thing I got out of it was to learn of the existence of Puppy Linux.

After the glowing review the author of the article gave of its distribution building tools, I read up a little more on Puppy, and decided to give it a try. Let me just report to you, that it is sweet! I'm typing this on my 7 and a half year-old Thinkpad T20 laptop (yes it really came with Windows 2000) that has been collecting dust on my shelf for the past year or so, running Puppy Linux. It feels nearly as snappy as my desktop Core 2 Duo machine that has two processor cores running more than twice as fast as the 700 MHz speed demon in this baby has 16 times the 128 MB of RAM. The reason Puppy can make this old Stinkpad fly is that the whole OS download was about 90 MB, and when you boot the liveCD, it loads the whole thing into RAM and runs from there. There is no waiting for the hard drive or the CD drive to spin. Well, almost none. I think it could use a little bit more than my 128 MB or RAM to load everything off of the CD, but for the most part my machine is running fast, and eerily quiet. I like it.

To squeeze things into 90 MB they have replaced any app that you might be familiar with from Ubuntu with something else. No Gnome, OpenOffice, Firefox, Nautilus, or even a terminal emulator that you are used to. It's JWM, Gnumeric/Abiword, Seamonkey, ROX-Filer, and rxvt. It's Linux, but not one most Linux users see on a daily basis. Seamonkey, it seems, is good old Mozilla, with the email client and web browser all built into one. It even has the old clunky looking icons and dialogs from the Netscape/Mozilla days. The whole desktop gives me an old-school Linux feel. It's not like these new polished and graphically designed Linux desktops of today. That's pretty fitting for this laptop I'm running on actually. I think I installed Redhat 7.3 on it when I first bought it. Come to think of it, maybe it's not Puppy that looks old-school, but just this washed out, crusty old LCD. Seamonkey is ugly though, no monitor issues there. OK, enough of the time warp back to the summer of 2001. The apps are different, but capable. And did I mention they were fast?

Puppy has some seriously nice ease-of-use features, on top of being really fast. The desktop background has a few paragraphs explaining where you are at, how to get online, and where to go for help. Every directory has a little README.txt file that explains what it's for. I sure could have used that the first time I booted Caldera OpenLinux back in the 20th century! Flash is included (youtube worked!), and it reportedly plays encrypted DVDs and everything.

When I slipped in my PCMCIA wireless card (when was the last time you did that!) and clicked the "Connect" icon on the desktop it found the card and walked me through getting online. I noticed a few other wizard type tools had very verbose and helpful info right there in your face as part of the GUI. I don't mind reading and it made the unfamiliar tools very easy to get going with. I'm like documentation.

I've got more to explore. Puppy Linux is supposed to be really easy to tweak and build your own distribution with. You can make it boot form a USB drive instead of a CD. I'm thinking it would be pretty awesome to run it on the XO. I'll keep you posted.