Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Thursday, February 14, 2008

gpsd bug in ITOS 2008

Huh.

I was trying to geotag a picture for the first time, but for some reason, the timestamp saved by gps-saver was exactly one day ahead, so no match was possible, of course. It turns out that ITOS 2008's gpsd, which gps-saver relies on, has a leap year bug until March this year. :-(

A fix is on the way, though, and the GPS unit itself is OK. Phew.

Meanwhile, I diddled the gps2photo source (part of gtag) to work around this bug (and another, involving undefined altitudes)... here you go. Just replace the one gtag installs in /usr/bin.

To run, I used

gtag -f gps.200802132236.1.log.gz -o tagged --credit "Alex Ibrado" --city Mandaluyong --state NCR --country Philippines --copyright "(c) 2008 Alex Ibrado" --keywords test *.jpg

and confirmed that these values were saved using

exiftool -a -u -g1 tagged/mypic.png

The GPS tags should also show up in any photo management software such as digiKam.

more > | full >>

Monday, February 4, 2008

Dynamic DNS and transparent proxies

I prefer having my DynDNS account updated by my Linux-based DSL-500T ADSL modem/router (flashed with Russian firmware) since it means the host updates occur every time a PPP session is established. Otherwise, I would have needed an inefficient cron job at my main box.

I haven't needed to access my PC remotely in the past few months, so I just recently noticed that my DynDNS host wasn't getting updated. At first, I thought there was something wrong with the router, but after my previous blog, I noticed that my host's registered IP address was that of (you guessed it, good for you!) Globe's transparent proxy.

It turns out my router's ddns call (hardcoded in the router's firmware-flashed XML) was using automatic IP resolution, i.e. DynDNS used whatever IP address the update command came from.

So, I downloaded the current XML configuration, made it more editable with HTML Tidy (tidy -xml), fixed the command to use -i ppp0 instead of -r, mashed the XML back into a single line with another one of my quick-and-dirty scripts (clutter), and reflashed it into the router. After it rebooted, my DynDNS account was being updated properly again. Phew.

ddns -u myuser:mypass -h myhost.at.dyndns -w -r -q -i ppp0

If any of you are having similar problems, check if your ISP has a transparent proxy. If you're lucky enough to be able to customize the commands your router runs, the above might be of some help.

Of course, if you're really lucky, your router doesn't have this problem in the first place. :-P

more > | full >>

Thursday, January 31, 2008

USB in ITOS 2008





Initially posting this via Maemo Blogger on osgiliath.

One of the most useful improvements in ITOS 2008 is the proper support for USB Host mode. Unlike previous versions where one had to jump through hoops to even get USB devices recognized, Host mode is now as simple as sending a value over to the appropriate /sys entry.

Here's a quick-and-dirty script which I simply call usb (compiled from various sources) that not only allows you to select between Host and On-The-Go (OTG) modes, it even allows for USB networking.

#!/bin/sh

MODE=$1
if [ "$MODE" == "net" ]; then
LOADED=`lsmod | grep g_ether | grep -v grep`
if [ "$LOADED" == "" ]; then
insmod /mnt/initfs/lib/modules/2.6.21-omap1/g_ether.ko
ifup usb0
fi
IP=`getip usb0 2>/dev/null`
echo "IP is $IP"

elif [ "$MODE" == "file" ]; then
ifdown usb0
rmmod g_ether

elif [ "$MODE" == "host" -o "$MODE" == "otg" ]; then
if [ "$MODE" == "otg" ]; then
echo peripheral > /sys/devices/platform/musb_hdrc/mode
fi
echo $MODE > /sys/devices/platform/musb_hdrc/mode
echo USB mode set to $MODE

else
echo "Specify 'host', 'otg', 'net', or 'file'"
IP=`getip usb0 2>/dev/null`
if [ "$IP" == "" ]; then
CUR=`cat /sys/devices/platform/musb_hdrc/mode`
echo "Current mode is $CUR."
else
echo "Current mode is net, IP $IP"
fi
fi
The helper script getip is just
#!/bin/sh

DEV=$1
if [ "$DEV" == "" ]; then
DEV=wlan0
fi
IP=`ifconfig $DEV |head -2 |tail -1 |awk '{print $2}' |cut -d: -f2`
echo -n $IP

Basically, you just call it as usb host or usb otg; or as usb net or usb file. I haven't fully tested these scripts, but they work for me. YMMV.

Here's a shot of an N800 xterm showing my 12GB Devant HD, and the 2GB SD from my camera in a card reader. The df command was typed from a USB keyboard connected to the same powered hub. I used a cheap CA408 AF/AF USB adaptor from CDR King to connect the hub.


more > | full >>

meanwhile, over at alexandr...