Saturday 18 December 2010

Skype 5 beta OSX sucks

If you're tempted by the idea of the new Skype 5 Beta for OSX - then forget it (well maybe apart from if you're interested in Group Calling). The new UI is a bad joke - Skype seems have lost its way. It is a huge ugly GUI that won't go away and very confused functionality. Fire the new GUI team leader!

I'm back to 2.8 as long as I can then if there's no change I'll be seeking a new Voip agent - Empathy Cocoa port anyone? Blink is a nice SIP client or Sip-communicator is pretty reasonable these days and it's cross platform.

However one should not forget that there are some new features...The main one being Group video calling, plus there extended search, and a new control bar which isn't so bad.

[updated 20jan11: A bit more upbeat - whilst the GUI sucks there are some good feature additions]

Sunday 28 November 2010

Time Machine backup...not

The other day I went to my Time Machine backup to try get a slightly older copy of a file that I'd been working on recently. But there was only a fairly ancient copy sitting there - and I KNEW I'd updated it since that date?!  My Time Machine backups seemed to be backing up just fine but only it wasn't..... Real handy?!

I Googled it and found a bunch of people had run into the same issue.

There are a bunch of files and directories that are normally excluded from backups - which are contained within the following plist files (You can see them just using a text editor or Quickview or edit them using e.g. Property List Editor) - check the 'ExcludeByPath' keys:
/Library/Preferences/com.apple.TimeMachine.plist
/System/Library/CoreServices/backupd.bundle/Contents/Resources/StdExclusions.plist

Note: That in the com.apple.TimeMachine.plist there are a bunch of items that get added by certain Applications; Xcode adds the directories named 'build' (and maybe others) to the list exclusions, and Google's Chrome adds it's 'cache' directories to the exclusion list. There's probably others out there as it is achieved using a standard API call.

You can also find, using mdfind the OSX's command line version of Spotlight, all files or directories that have had the appropriate metadata attribute set (using xattr command) for backup exclusion:
sudo mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'"
Out of interest you can list the metadata attributes on any file/dir:
mdls /path/to/that_curious_file
However in my case none of the above applied and it seems that under Sow Leopard there's some 'bug' that stops TM working properly if you haven't rebooted in a while (which I hadn't). So a simple reboot fixed it?! Not reassuring though.

There's a good list of things to check here and there.

Thursday 11 November 2010

Too many package managers

On every system someone seems to invent a new package management system which means you've gotta learn the nearly the same thing over and over again. Tedious... Here's some notes to myself about how you can do basic stuff in a few I use (OSX/MacPorts[port], Ubuntu/Debian[aptitude,apt], RedHat/RPM[rpm,yum]).

Install Package
OSX% port install ThatPeskyPackage
ubuntu% aptitude install ThatPeskyPackage
ubuntu% apt-get install ThatPeskyPackage
ubuntu% dpkg -i ThatPeskyPackage.deb
RedHat% yum install ThatPeskyPackage
RedHat% rpm -i ThatPeskyPackage.rpm

Remove Package
OSX% port uninstall ThatPeskyPackage [version]
ubuntu% aptitude remove ThatPeskyPackage
ubuntu% apt-get remove ThatPeskyPackage
RedHat% yum erase ThatPeskyPackage
RedHat% rpm -e ThatPeskyPackage.rpm

Package Info
OSX% port info ThatPeskyPackage
ubuntu% aptitude install ThatPeskyPackage
ubuntu% apt-get install ThatPeskyPackage
RedHat% yum info ThatPeskyPackage
RedHat% rpm -qi ThatPeskyPackage

Package Content: What files did it install?
OSX% port contents ThatPeskyPackage
ubuntu% dpkg -L ThatPeskyPackage
RedHat% rpm -ql ThatPeskyPackage

What package does this file belong to?
OSX% port provides /usr/some/place/weird/whatisthis
ubuntu% dpkg -S /usr/some/place/weird/whatisthis
RedHat% rpm -qf /usr/some/place/weird/whatisthis

Which packages have I got installed?
OSX% port installed
ubuntu% dpkg --get-selections
RedHat% rpm -qa
RedHat% yum list

Tuesday 9 November 2010

What Linux release am I running?

For every Linux distribution/distro there seems to be a different way to work out which release version/name/codename you're running. Here's a the ways I've found, on the command line, to find out:

Ubuntu
lsb_release -a
cat /etc/lsb-release
cat /etc/debian_version
Note: For Ubuntu /etc/debian_version seems to contain the Debian base from which this version of Ubuntu originates.

Debian
cat /etc/debian_version
cat /etc/lsb-release
lsb_release -a
Note: The latter two are not always available on pure Debian systems.

Redhat/CentOS/Fedora
cat /etc/redhat-release

Gentoo
cat /etc/gentoo-release

Building and using a Linux initramfs

If your kernel needs to do 'stuff' during boot up or load modules that aren't compiled into it then an initramfs provides a way (initramfs supersedes the old initrd approach). Basically it is a file (cpio and gzipped) that contains a directory hierarchy containing all the necessary items to provide for loading of modules etc.

To enable the use of the initramfs you'll need to enable the relevant kernel option (e.g. General Setup --> Initial RAM filesystem and RAM disk (initramfs/initrd) support) and them supply the appropriate boot arguments to your boot loader (e.g. append initrd=my-initrd .....). At the very beginning of boot up you should see [on the console] the initrd being loaded (Loading initrd................), then further down it executes the ./init script within the initrd.

To build an initramfs from a suitably populated directory:
find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../my-initrd
To check the contents of an initramfs:
gunzip -c my-initrd | cpio -t
To extract the contents of an initramfs into the current directory (you might want to create a temporary directory to unpack it into mkdir initrd.d ; cd initrd.d):
gunzip -c ../my-initrd | cpio -i -d -H newc --no-absolute-filenames

If you've been trying to use an initramfs and you're getting this error on boot up:
Failed to execute /init
Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
Then maybe your ramfs image doesn't contain init, or it's not executable, or you're trying to use a shell within init that incompatible with your kernel's architecture (e.g. trying to use an amd64 arch shell with an i686 kernel).

There's a good Gentoo guide on building them.

On Ubuntu/debian there's a command to build an initrd called mkinitramfs. When running mkinitramfs whilst you can use an alternative config directory, it can only obtain kernel modules from /lib/modules/<kernel_version>. So you can run it using chroot, though its only a shell script so it can of course be tweaked....

Friday 29 October 2010

Firefox sync is useless for bookmarks - doesn't sync subfolders

I've been [blindly] using Mozilla's Firefox Sync (aka Weave) plugin (v1.5) thinking it was such a great thing (apart from the lengthy freezes whilst it was 'syncing')...Only to realise that it does NOT sync my Bookmark's subfolders/subdirectories (folders below the main directory) - which makes it effectively useless! Unless your bookmarks are flat then it's total a waste of time.

What a dumb plugin??! I expect more from Mozilla. Go click here for my bug report and click on 'I have this problem too'.

Anyone got any better suggestions....

Wednesday 6 October 2010

Enabling X/X11 tunnelling/forwarding on OSX

It seems that X11 forwarding is not enabled as default on OSX so if you connect to machine using ssh and then try to run an X command (e.g. /usr/X11R6/xterm) it fails with: "unable to open display"

To enable X11 forwarding on your_osx_host machine edit /etc/sshd_config e.g.
sudo vi /etc/sshd_config
And add the following line:
X11Forwarding yes
Then restart the sshd service:
sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd 
or
sudo service ssh restart

Then from your remote machine logout and log back in and you should be able to use forwarded X11 apps - you may need to enable [trusted] X11 forwarding on your client as well e.g:
ssh -XY your_osx_host

Friday 6 August 2010

How to convert .ipcc file to .bundle

So you've got an .ipcc file and you want to unpack the .bundle directory - well it's just a zip file (like a few other things e.g. .jar files). So just run unzip:
$ unzip random.ipcc
You can find a list of them from http://phobos.apple.com/version - go to that page and sift through the XML till you find the one you need and copy the link and paste it into your browser to download it (or use wget or curl to get it).

Wednesday 28 July 2010

Where OSX are kernel modules located?

The OSX uses loadable kernel (like BSD and Linux) modules (or kexts) - each one is stored in its own directory (e.g. Dont Steal Mac OS X.kext ) and these are mostly stored in a couple of directories:
/Library/Extensions
/System/Library/Extensions/
Though some others are stored in some other directories (e.g.  /Library/StartupItems/). You can list the currently loaded kernel modules using the kextstat command.

There also some info more info another post of mine on tracking down problem kernel modules in osx.

Friday 16 July 2010

Ubuntu 10.04 USB Mouse keyboard problems - fixed

After the problems I had after 9.10 upgrade I held off on upgrading to Ubuntu's latest 10.04 (Lucid something-or-other), with kernel 2.6.32-21. Sadly it was another disaster - after upgrade neither my mouse nor keyboard worked beyond the Grub screen.

I looked into it; initially I thought it was an X thing with their new nouveau Nvidia driver but it wasn't that. I then noticed that the devices weren't actually being seen by the system on the USB bus - i.e. when I ran lsusb I only saw a couple of USB hubs (no mouse or keyboard listed) where normally I saw about 6 USB devices - yes they were plugged in and were recognised fine by an older kernel (9.10). I messed about with usbhid kernel module to no avail. I then tried 10.04 live CD and it worked ok with exact same USB setup?! I dumped the output from dmesg and then compared it with dmesg from my machine running the installed version on the exact same kernel version. It seemed that my installed version was failing to recognise the actual PCI USB host controllers on bootup - WTF?! It seems that the ehci-hcd module was not finding the USB hardware.... Smells like a kernel bug.

Finally I tried altering various boot args for the kernel in /boot/grub/menu.lst which didn't work initially, but then I hit upon the right one: pci=noacpi. It now works though my fans seem to be going full speed at all times...

[updated: 21aug10] Unfortunately after the kernel latest update (2.6.32-24) it seems to be totally broken and my fix doesn't work so I've had to revert to using 2.6.32-21 - If you run any DKMS modules (e.g. nvidia) you'll need to have the kernel header files installed that kernel.

Another BIG waste of time....I really am having my doubts about Ubuntu.

Thursday 1 July 2010

Don't bother: iOS4 on iphone 3G

Yeah the move to iOS4 has not been good:
1) The install process sucked; The 'backup' stage of the upgrade took forever - so instead I ended up using the 'restore' function from iTunes (once I'd got iOS4 downloaded in iTune 9.2). It still took HOURS.
2) The number new features on the 3G is hardly worth it (Folders, Spell checker, Threaded mail,...)
3) It seems less stable and slower than iOS 3.2.x - have to reboot it more
4) A number of my apps crash ALOT like MobileRSS, OffMaps - not handy. (though I guess they probably need to be updated...)
5) Quite a few Apps aren't iOS4 ready - e.g. Skype

Maybe 4.x will help but who knows when that's due......

[5nov10]: 4.1 definitely improves things (and the relevant apps have mostly been updated)

Thursday 22 April 2010

Fixing Apple iTunes sync AppleMobileSync crash

I just updated my Windows Vista machine and after rebooting I tried syncing my iPhone and iTunes 9.1 started complaining that AppleMobileSync.exe (and some Yahoo sync crap) was crashing WTF?!

I looked into it and when I attempted to run AppleMobileSync.exe from its working directory (C:\Program Files\Common Files\Apple\Mobile Device Support\SyncServices\Clients\com.apple.MobileSync) it complained that it couldn't find objc.dll - but a quick search found it here: "C:\Program Files\Common Files\Apple\Apple Application Support", so I added that dir to my path, then it complained that DeviceLink.dll was missing - I found that here: "C:\Program Files\Common Files\Apple\Mobile Device Support" so I added that dir to my path as well - It now worked! But to get it fixed for automatic syncing I had to go into System control panel -> Advanced system settings -> Environment variables - then select the System PATH and add the two above directories to the end of the PATH (separated by ';'). BTW I did try registering the objc.dll using regsvr32 but objc.dll doesn't contain the appropriate entry points for regsvr.

Not sure why it happened and it shouldn't really need path updates but it fixes it for now...

Wednesday 14 April 2010

Finally got my Karmic box working properly!

Ever since I upgraded to Karmic (9.10) my machine has performed like a dog - well as far as keyboard and mouse input went - the mouse would linger and the system would loose my keystrokes. I tried a bunch of things to no avail....

Then I was perusing the web - frustrated by my sluggish machine - I'd read about cpu frequency scaling and wondering if this might be an issue. Well it turned out to be the root of my problem! Though in general I think more modern CPU should operate fine with cpu scaling enabled but these old AMD Opteron CPU's don't seem to be up to it so I've disabled it and the machine behaves a lot better.

To fix it - firstly I installed the cpufrequtils:
sudo aptitude install cpufrequtils
Checked the current state of my machine (You can also do it using any of: cat /proc/cpuinfo, sudo dmidecode -t processor, lshw -C processor):
sudo aptitude install cpufreq-info
 My machine was in 'ondemand' mode - I changed it to 'performance' mode - for each of my two processors:
sudo cpufreq-set -c 0 -g performance
sudo cpufreq-set -c 1 -g performance
This is actually setting the following /sys entries: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

There a few more things you can do with the cpufreq utils.

Tuesday 23 March 2010

Linux networking secrets

The operation of Linux's networking functions has various not so well described aspects to it. Here's a few I've come across:
  • Kernel DST cache: The kernel caches congestion control related information (e.g. ssthresh, rtt, mtu, cwnd) about every TCP connection and stores it in the 'DST' (Destination) cache after each connection closes, though only for a limited time, reusing for connections to the same destination. To list/show/display the contents of the dst cache:
    ip -s route show table cache
    You just flush the DST caching using:
    ip route flush table cache
    Or you can disable the DST caching using:
    sysctl -w net.ipv4.tcp_no_metrics_save=1
  • Network interface queue size/length monitoring: Everyone goes on about tweaking the transmit queue (txqueuelen) size to get the best result out of your box but no-one tells you how to monitor/check/display/show the size of the queue actually being used. To check actual queue utilisation/use/occupancy - see the 'backlog' (in bytes and packets) as shown by tc (e.g. For eth0):
    tc -s -d qdisc ls dev eth0
  • Default Linux Queue: Amazingly enough the default queue on Linux (pfifo_fast) inspects the TOS (type of Service) bits in the IP header and does priority queuing based upon them - Not sure who - if anyone - is using that???! Anyway you can check to see the priority mappings (priomap) using the tc command above.
  • Detailed socket stats and info (congestion control algo, cwnd, window scale, rto etc) on open sockets (TCP,UDP,RAW,PACKET) on your machine you can use the socket stats app, ss  which uses an INET_DIAG netlink socket to obtain info directly from the running kernel: e.g.
    (args: t: timers, i: TCP internals, m: memory, e: extended, dport: filters on destination port):
    ss -time dport = :5001 
    Memory stats: from net/ipv4/inet_diag.c +140
    rmem = sk->sk_rmem_alloc; wmem = sk->sk_wmem_queued; fmem = sk->sk_forward_alloc; tmem = sk->sk_wmem_alloc;
  • Linux TCP stats: The tcp_probe module may be used to obtain cwnd and sequence numbers of packets in TCP flows.
  • TCP receive (or send) window size is based on sysctrl net.ipv4.tcp_rmem (or tcp_wmem) - the 3 values are min, default, and max. The actual window size relates to these numbers by tcp win = tcp_rmem-tcp_rmem/2^tcp_adv_win_scale - e.g. the system default of 87380 results in a TCP win of 65535. The max window is globally limited by net.core.rmem_max. For more details see linux-2.6/Documentation/networking/ip-sysctrl.txt and man tcp.
  • TCP/Generic Segment Offloading (TSO/GSO) information about your machine's network interface. TSO is quite common these days - it basically offloads the packetisation of TCP segments onto the network card (see my other post where it can lead to confusion). The ethtool command (which may need installing) also tells you about a whole host of features that your NIC may or may not support:
    ethtool -k eth0
  • Traffic Control (TC): I've touched on its use above but I've another post on setting filters with tc.
There's other places that have good info on Linux like: Linux foundation's Kernel networking, Linux network stack walk thru

[Updated:9jul15, 15jan15:DST cache, 1dec11]

Tuesday 16 March 2010

Dodgy mouse mappings

So you're trying to use (say) your middle mouse button to copy/paste and the darn thing isn't working.... Well there's a bunch of things that control this (see a some articles here, and uhere, khere). Basically if you want paste working with a particular mouse button then you need to make sure it is the second one (ie button two) in the list; So for a normal 3 button mouse the mouse maps (see below) should read: 1 2 3 .... But for ,say a Logitech Trackball, the mapping may want to look like this: 1 8 3 4 .... (as the small left button on these trackball's is actually numbered 8 - check using xinput query-state your_mouse_id).
  • List your input devices using:

    xinput list 
    List mappings using your mouse's 'id' (from xinput list):

    xinput get-button-map your_mouse_id
  • The X config file: /etc/X11/xorg.conf file at the InputDevice section
  • The xmodmap set-up - have you got a .Xmodmap or .modmaprc file lurking? Check your existing setting like this:
    xmodmap -pp
  • The HAL policy - see /etc/hal/fdi/policy/ - any special config there? (NB: HAL disappears from Ubuntu after Karmic 9.10)
  • The UDEV rules - see /etc/udev/rules.d/ and/or /lib/udev/rules.d/
[updated:17jun10]

Tuesday 9 March 2010

Making Karmic more responsive...

As previously mentioned, I've run into problems with Karmic (9.10) on my Opteron 246 box. Here ae details of the possible fixes.
  • As mentioned here you can try: Tweaking the Linux kernel scheduler options:

    echo NEW_FAIR_SLEEPERS > /sys/kernel/debug/sched_features
  • Increase nice-ness of X server:

    sudo renice -10 `pidof X`
  • Use the real-time kernel: linux-image-rt
  • Try messing with the kernel swappiness factor - e.g. see here
Not sure which one is any use....will add more I find 'em.

[14apr2010]: I think I've finally found the fix!

Tuesday 23 February 2010

Bash/shell scripts aren't working on Ubuntu

I was just writing a shell script - it all worked fine on the command line so I put it in a file and ran it:
% sh myscript.sh
But it generated an error - specifically I was trying to use brace expansion (a Bash only feature) which it now didn't seem to like. What the heck?

It turns out that on Ubuntu they have switched to a faster-simpler default shell (/bin/dash) - which does actually help to improve boot times - but is no longer bash compliant (so no fancy features - just POSIX 1003.2 features only). So what's happening is that my script is being run by dash - despite it the fact it starts with the usual #!/bin/bash - which confused the hell out of me. Anyway watch out if you've got lazy old habits like assuming that sh is bash.

Friday 19 February 2010

unconnect() a UDP socket

So you've got a UDP socket and you've called connect() on it to make it send or listen to a particular IP address, but then you need to disconnect it again, without destroying it. Why would you want to do that?? Well on some OSes (ie Mac OSX, BSD) if you're connected to UDP socket on a machine you can only do that once with the same address (even when you're using the REUSEADDR stuff). So anyway you can disconnect() or unconnect() your socket by the doing the following:
int disconnect_udp_sock(int fd) {
 struct sockaddr_in sin;        

 memset((char *)&sin, 0, sizeof(sin));
 sin.sin_family = AF_UNSPEC;
 return (connect(fd, (struct sockaddr *)&sin, sizeof(sin)));
}
On some OSes you may get a dodgy return value but according to the connect() man page it's ok.

Monday 8 February 2010

Stop Windows [re]installing [dodgy] drivers

If you have the issue where an 'official' driver that comes down with Windows Update is basically broken then you need to disable the update mechanisms for that device. In Windows (Vista, and probably WinXP, Win7) you can stop Windows from updating drivers for specific hardware by using Windows' Local Group Policy Editor:
  • Start Device Manager by going to 'Start' button and typing devmgmt.msc and hitting return
    • Locate your dodgy device and click on Properties
    • Copy the 'Hardware ID' from Properties->Details->Hardware ids
    • Right click on device and select uninstall
  • Start Policy Editor by going to 'Start' button and typing gpedit.msc and hitting return
    • Edit the following key(s): Local Computer Policy->Computer Configuration->Administrative Templates->System->Device Installation->Device Installation Restrictions->Prevent installation of devices that match any of these IDs.
    • Paste in previously copied dodgy Hardware Ids. e.g:
      PCI\VEN_10DE&DEV_0042&SUBSYS_97511462&REV_A1
      PCI\VEN_10DE&DEV_0042&SUBSYS_97511462
      PCI\VEN_10DE&DEV_0042&CC_030000
      PCI\VEN_10DE&DEV_0042&CC_0300


  • Reboot
In my case the dodgy driver in question is for an oldish NVidia card - Vista thinks it is an GeForce 6800 LE (whilst Linux thinks it's a Quadro NVS 280 SD - where it actually works ok) and the latest drivers (11 Jan 10) still result in total system crashes (machine just freezes - no 'screen of death') when I do mundane things like bringing a PDF document up in Adobe Acroreader or clicking on the 'office button' in Office 2007?!

    Friday 5 February 2010

    Handy iphone tips

    A few things I've discovered with my iphone:
    • Use Caps lock on the keyboard
      1. Make sure it's enabled it in prefs: Settings->General->keyboard
      2. To use when using typing - double tap the shift key and goes blue!
    • European variant letters (accents, umlaut etc) on keyboard
      • Tap and hold "e", "a", etc
    • Add .com or .co.uk when typing an web/email address:
      • Tap and hold on the '.' key
    • Go to top of any scrolled window/app:
      • Tap on the very top bar (with the time in it)
    • Kill any app (OS3+ only):
      1. Push and hold power button till "Slide to power off" shows
      2. Let go of power button
      3. Push and hold 'home' button for more than 5 secs and the app dies
    • Reset your iphone:
      • Push and hold both the power button and home button for more than 10 secs
    • Take a screen shot:
      • Push home button, then click power button

    Friday 29 January 2010

    Editing PDFs - insert images etc

    This is a bit of a dirty trick but you can use Foxit's PDF editor in evaluation mode to edit a PDF doc (i.e. add images) and then save it and use PDFedit to remove the evaluation messages - however I can't condone this trick...

    Thursday 28 January 2010

    Mingw and Visual Studio

    Mingw is a great environment for building stuff on Windows especially for apps that came from UNIX environments. It provides a gcc compiler for Windows that links directly against the Windows libraries (as opposed to Cygwin that uses an intermediate library to achieve compatibility).

    If you're working on projects that combine Mingw and Microsoft's Visual Studio environment (VS2008 etc) then here are a few things that are useful to know:
    • How to get Mingw/Msys to pick up or import VS environment (e.g. for include paths etc):
      • Add the line below (change version of VS if necessary) to C:\MinGW\msys.bat
        • Call "C:/Program Files/Microsoft Visual Studio 9.0/Common7/Tools/vsvars32.bat"
    • How to add other tools to the path for Mingw/Msys (e.g. Collabnet's svn):
      • Add the line below to /etc/profile (within msys) or C:\MinGW\etc\profile:
        • export PATH="/c/Program Files/CollabNet/Subversion Client:$PATH"

    Thursday 21 January 2010

    Messing with WxPython

    I've been playing with Wx Python on OSX and it's not bad for knocking things up. Trying to find out how to do certain things has taken a while - when you just can't find the right search term! Here's a couple of things that I'd been trying to do:
    • Mini sliders/widgets - On OSX Cocoa/Carbon there's some neat small sliders

      • You can enable them on OSX (only) by using this method (there is also a MINI size):
        SetWindowVariant(wx.WINDOW_VARIANT_SMALL).
    • Multiple display/screen or multi-monitor info - like how many displays and what resolution/size are they?

      • Find out info using the wxDisplay() class - e.g. wx.Display.GetCount() tells you how many displays are connected - as seen here.
    • WxPython on Snow Leopard - you need to enable 32-bit python - do it in either of these two ways:

      • defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
      • export VERSIONER_PYTHON_PREFER_32_BIT=yes

    Tuesday 12 January 2010

    Using Python for SD84 Servo/Robot controller

    I've been playing with an SD84 board which uses 4 x PIC18F2520 chips to provide control for up to 84 servos (and/or analogue/digital input/output). I wanted to use Python on OSX but there are others out there who have used C (see the sd84lib). I've updated this article enough that I thought I repost it with a newer date.

    The SD84 also uses a chip from FTDI which provides for the USB-serial interface. FTDI are a company based in Scotland that make a range of chips  e.g. FT232R used in Robot Electronic's SD84, and the Arduino.

    Firstly you need to get the FTDI VCP drivers for OSX 10.5 (there are also drivers for Windows and Linux) - I found that the FTDIUSBSerialDriver_v2_2_9.dmg worked better than the latest 2.2.10 version (though there are now newer ones which may well work ok). Initially I installed the 2.2.10 version but firstly the kernel module didn't load when I plugged in the SD84, nor would it load manually (complaining of "can't add kernel extension /System/Library/Extensions/FTDIUSBSerialDriver.kext (not a bundle)") - I tried some suggestions here to no avail. I fixed it by uninstalling that version and cleaning up according to here - also removing my old pl2303 drivers, as mentioned here:
    sudo rm -rf /System/Library/Extensions/FTDIUSBSerialDriver.kext \
    /System/Library/Extensions.kextcache \
    /System/Library/Caches/com.apple.kernelcaches/* \
    /Library/Receipts/FTDIUSBSerialDriver.* /Library/Receipts/osx-pl2303-10.4.* \
    /System/Library/Extensions/osx-pl2303.kext
    
    I then did a clean install of the 2.2.9 package and rebooted then the drivers just loaded when I plugged in the SD84 - you should see a message about FTDI drivers loading in dmesg, and you should also see the driver instantiate the appropriate device nodes - e.g. /dev/tty.usbserial-XXXX.

    There are also FTDI's D2XX drivers which are apparently supported by the Python pyusb module (not sure diff with this one) but I haven't tried them yet - though they potentially provide for better performance. It seems that these can also be used for JTAG based debugging.

    I then used Python pyserial module (installed on OSX from ports using sudo port install py-serial, or you can download pyserial package and then run: sudo python setup.py install in the unpacked directory) to control an SD84 - the basics are (which will work on Linux as well, and windows if you replace'/dev/tty.usbserial-A2001mJE' with 'COM3') :
    import serial
    sync='\xAA\xA0\x55'
    SET_SERVO='\x01'
    SET_MODE='\x04'
    GET_VERSION='\x0A'
    # Open Serial port to FTDI usb serial tty
    ser = serial.Serial('/dev/tty.usbserial-A2001mJE', baudrate=115200, byte
    size=8, parity='N', stopbits=2,timeout=1)
    # Send GET_VERSION command
    ser.write(sync+GET_VERSION+'\x02\x00')
    # Read the returned version and print
    ver=ser.read(2)
    print "VERSION:"+ver
    # set SERVO mode
    ser.write(sync+SET_MODE+'\x11\x01\x19')
    #Read return code (should be \x00 if all is well)
    ser.read(1)
    

    There's also other places with useful info here on OSX and serial setup.
    [written on 15/9/9 updated 23oct09, 12jan09]

    Friday 8 January 2010

    Accessing OSX install DVD from Linux/Ubuntu

    Have you ever tried sticking your Mac [Snow] Leopard/Tiger OSX installation DVD/CD disks into a Linux box and just found a measly little windows partition there with the BootCamp stuff on it, and wondered where all the Mac stuff was hiding? Yeah so have I.

    This is how to copy the disk using the dd command (you can do virtually the same thing on OSX - here's an article with some more info):
    dd if=/dev/sr0 of=/DVDcopy.iso
    For older versions of *NIX (which used to use '-if/-of'):
    dd -if=/dev/sr0 -of=/DVDcopy.iso 

    However whilst Ubuntu doesn't understand - it is all there just hiding... This handy site explained a way to get to it - directly on DVD. You can use your DVDcopy.iso in the same way. You'll probably need to install the tool (e.g. aptitude install kpartx). On your Linux box you do:
    #sudo kpartx -av /DVDcopy.iso
    add map loop0p1 (252:0): 0 60 linear /dev/loop0 4
    add map loop0p2 (252:1): 0 2020420 linear /dev/loop0 64
    add map loop0p3 (252:2): 0 13158216 linear /dev/loop0 2020488
    add map loop0p4 (252:3): 0 12 linear /dev/loop0 15178704
    

    Then use file to find out which partition contains the Mac stuff - run file on each one till you find one that says it's an Macintosh HFS e.g:
    sudo file -s /dev/mapper/loop0p3
    /dev/mapper/loop0p3: Macintosh HFS Extended version 4 data last....
    

    The mount it and you're away:
    sudo mount /dev/mapper/loop0p3 /my_mount
    

    You should now be able to see the contents of the Mac (HFS+) partition in the directory /my_mount

    Tuesday 5 January 2010

    Handy iPhone apps

    Happy New Year to all! Well I thought I'd list a few apps I've found to be handy on the iPhone - all free apart from two:
    • Fring - Gives you a consolidated VoIP solution (SIP, Skype, and others) with offline notifications (some might say it's too consolidated - maybe Fring are run by the Spooks?!)
    • MobileRSS - The best free Google Reader with good offline and un/subscribing support
    • Twitterific - A nice Twitter app for keeping an eye on all that chattering with support for un/subscribing and stuff
    • OffMaps ($) - A very handy (and very reasonably priced) maps app that uses OpenStreetmap/cloudmade data with good offline support
    • Discover - Useful app for storing random stuff on the iPhone (works over wifi and acts as web server)
    • Touchterm ($) - A useful and cheapish ssh client
    • RjDj - A cool app that generates 'music' using 'patches' - based upon Pure-Data
    • MrMr - An OSC app for whacky control applications