Tim Hatch

Weblog | Photos | Projects | Panoramas | About

ps -ef, option f not recognized 25 Mar, 2010

If you find that on OS X (Leopard/Snow Leopard) you cannot run ps -ef, the culprit is that the environment variable COMMAND_MODE is set to legacy instead of unix2003.


$ COMMAND_MODE=legacy ps -ef
ps: illegal option -- f
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
          [-u]
          [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
       ps [-L]
$ COMMAND_MODE=unix2003 ps -ef
  UID   PID  PPID   C     STIME TTY           TIME CMD
    0     1     0   0   0:00.63 ??         0:00.87 /sbin/launchd
...

Nick at $JOB found this was the case in iTerm, so a quick add to your .bash_profile will make this right again. For more info, see man 5 compat.

Easy serial terminal on OS-X 25 Mar, 2010

I work with embedded devices at $JOB a lot, and spend a good chunk connected to their serial ports to get a console. I’ve been using minicom and ckermit with some success (they provide file-transfer capability, which is great for reflashing) but most of the time I just need a console.

I found out, while playing with firmware upgrades on my Bus Pirate that there’s an even easier way:

screen /dev/tty.usbserial 115200

Credit goes to David and Brett on that one. Use Ctrl-A, Ctrl-\, y to exit.

Interesting Electronics, Part 1 20 Mar, 2010

I’m quite interested in electronics, so whenever I get some hardware that’s out of warranty and misbehaving, I pop the cover and look at what’s inside. I’ve discovered lots of interesting techniques this way, and figured I should start sharing them instead of just keeping folders like “Interesting PCBs.”

To start this off, here’s a stepper motor controller available from DIY CNC in the UK.

Normally on a stepper motor controller, you have a “sense resistor” to check the current flowing through the coils. This resistor is supposed to be very small, typically under one ohm. The labyrinth-shaped circuit traces are actually acting as a resistor here, since the space was useful for putting silkscreen directions on anyway. I saw resistance on traces also mentioned at D.J. Delorie’s Spiral Challenge first, and located Trace Resistance second, which assuming about 17” of traces, could be about 13 mils for a resistance of ballpark 1.25 ohms. Compare this to the RepRap stepper controller which uses large surface mount resistors for the same function.

Equivalent of os.path.abspath in bash 08 Mar, 2010

I don’t know how many times I’ve written a script that takes a directory argument, but I want to store that as an absolute path because I’ll be changing directories a lot. I had tens of lines of code to tack on $PWD with lots of conditions, but last week it finally hit me:

fullpath="$(cd "$1"; pwd)"

It will also give you the path with ../ removed.