Friday, 4 November 2011

USB Disconnection Problems


  1. I've been having Bluetooth problems on my Mac mini (mid 2007) since I tried using it with a Bluetooth keyboard and mouse; the symptoms were random disconnections and, some time after, either a few seconds or minutes, reconnections.
    Lots of people seemed to be having this problem, but nobody really seemed to get to the bottom of it. Some people on the internets suggested this might be overheating, and suggested smcFanControl which is a nice little app, but didn't really help in my case.
    Eventually I gave up, assuming it was a hardware flaw, and purchased a USB Mighty Mouse and keyboard; this worked fine, but recently my Mighty Mouse gummed up for good (and I broke it cleaning it, duh!), and, after the release of Lion with it's iOS scrolling and gestures etc., I purchased a Bluetooth Magic Mouse, and lo, the problem came back; starts pretty soon after start-up, even when the temperature is only in the high 40s (°C).
    I’d also noticed that, without any Bluetooth devices, the Growl hardware notification system frequently reported USB disconnects and near-instant reconnects; effecting all USB devices and even wireless networking. It didn’t really cause me any problems, and I kind of assumed it was normal, under-the-hood stuff (like when plugging in an iPhone or Camera always caused read errors on my external USB drive!).
    However, I’ve just tried tinkering with the Bluetooth-PDA-Sync thing, as A Velerez mentions in the comments of this post, except in my case, I just switched Bluetooth-PDA-Sync off, and it seems to have fixed my Bluetooth disconnection problems (yay!). The random Growl hardware disconnection notifications have gone away too.
    Could this be something to do with having once used a Palm device to sync over Bluetooth? Is everyone else experiencing the problem, without finding that the fan control fixes it, a former or current Palm user? Is the Bluetooth-PDA-Sync even a Palm thing, or a generic OS feature?
    Anyway, assuming you don’t need it, switching Bluetooth-PDA-Sync off seems to fix this problem, assuming you’re not frying your hardware too…
    Mac OS X Lion 10.7.2 (11C74)
    Mac Mini Mid 2007
    2 GHz Intel Core 2 Duo

Sunday, 28 November 2010

1-wire using owfs

For my MSc, I wanted to monitor and log temperature and humidity in various parts of my house; one of my lecturers suggested iButtons from Maxim.

On the Maxim site various C and Java APIs are offered, but I've been unable to get these working on the Mac, trying rxtx libusb etc. all in vain. Works in Windows (of course) because they supply a driver which makes the USB-Serial adaptor (DS9490R) act like a COM port. No such driver for Mac.

Eventually I came across owfs (http://owfs.org/), which is a 1-wire file-system plug-in for Fuse. I managed to get it working in Ubuntu Linux (under Parallels), and there seems to have been a fair bit of work done on a Mac port of this, but it's not quite out-of-the-box yet.

After a lot of messing around and Googling, he're how I got it working on MacOS X Snow Leopard 10.6.5; I hope this step-by-step guide saves someone some time...


Installing owfs
tar -zxvf owfs-2.8p3.tar.gz 
cd owfs-2.8p3/
  • Configure the build, disabling stuff that doesn't work (zero and owphp give compile errors, owtcl install error - sorry if you want to use zeroconf, php or tcl!)

./configure --enable-usb --enable-owfs --disable-zero --disable-owphp --disable-owtcl
  • Now hack around with the build config:
(Some of these tips originally from Peter Radcliffe at http://owfs.org/index.php?page=macintosh modified to work for me!)
    • Fix libtool config:
mv libtool libtool.orig
awk '/^# ### END LIBTOOL CONFIG/, /^# Generated from ltmain.m4sh/ {next} \
     {print}' \
   < libtool.orig > libtool

    • Replace VOID_RETURN with NULL (missing include with --disable-zero?):
perl -pi -e 's/VOID_RETURN/NULL/' module/owlib/src/c/ow_avahi_browse.c
    • Edit config.status change libuse to libfuse_ino64 (else get Input/output error when listing owfs filesystem:
perl -pi -e 's/-lusb/-lusb_ino64/' config.status
    • Now Make and Install:
make
sudo make install

Software ends up in /opt/owfs


Using owfs

Now it's time to mount up; put in your USB adaptor and...

mkdir /Volumes/1wire
(make mount point)

/opt/owfs/bin/owfs -u /Volumes/1wire
(mount 1-wire bus)

Now you have access to all the devices, get in there and cat about:

$ cd /Volumes/1wire/
$ ls

21.7ACE26000000 alarm settings statistics system
81.FB9F2D000000 bus.0 simultaneous structure uncached
$ cd 21.7ACE26000000
$ ls
about alarm_state histogram overtemp temperature
address alarm_trigger id pages type
alarm_dow alias locator r_address undertemp
alarm_hour clock log r_id
alarm_minute crc8 memory r_locator
alarm_second family mission set_alarm
$ cat temperature
$ cat temperature 
          19$ 

Now one can start messing around with scripts to harvest the data, and start 'missions' etc. This guy looks like he knows what he's doing: http://owfs.org/index.php?page=garden - RRDTool is available from MacPorts.