Resetting the USB Bus under linux

Posted by Benjamin Close on September 15, 2008 under UniSA | 3 Comments to Read

Today Snappy, the little photo box we have taking photos of the new Bruce Lab, broke again. Hence I quickly came up with a way of resetting the USB device under linux based on libusb. Sadly whilst I can confirm this does reset the device gphoto2 still doesn’t like our little Canon Ixus 400 and we still get timeouts after about 12 hours of taking photos – 1 photo every 2 minutes. Below is the hack of a program I used.

To compile use: gcc -o outputname resetusb.c -lusb

#include <stdio.h>
#include <usb.h>

int main(void)
{
      struct usb_bus *busses;
      usb_init();
      usb_find_busses();
      usb_find_devices();
      busses = usb_get_busses();
      struct usb_bus *bus;
      int c, i, a;
      /* ... */
      for (bus = busses; bus; bus = bus->next) {
        struct usb_device *dev;
        int val;
        usb_dev_handle *junk;
        for (dev = bus->devices; dev; dev = dev->next) {
          char buf[1024];
          junk = usb_open ( dev );
          usb_get_string_simple(junk,2,buf,1023);
          if ( junk == NULL ){
            printf("Can't open %p (%s)\n", dev, buf );
          } else {
            val = usb_reset(junk);
            printf( "reset %p %d (%s)\n", dev, val, buf );
          }
          usb_close(junk);
        }
      }
}

Annarchy down again :(

Posted by admin on September 10, 2008 under FreeDesktop | Be the First to Comment

Yet again Annarchy suffered some evil failure requiring a hard reboot. The box really needs more memory. Keith has indicated there is budget so I guess when there’s some spare time we should buy and install it. 16GB more would make it very happy. Most the issues come down to disk io. When the ram gets low the box starts thrashing and sadly the disks just can’t keep up with the load.

To combat this I’ve built a failsafe script will stop services when the load gets too high – restarts them when the load drops again, just waiting on another Wrangler to confirm it’s ok before it goes live.

Spam it just doesn’t stop

Posted by admin on under FreeDesktop | Be the First to Comment

Today I finally found time to run throught the countless amounts of spam in the fd.o mailing lists. It amazes me just how quickly it builds up. Without listadmin moderating it would be a nightmare!

My First Wordpress Blog Entry

Posted by admin on under Other | Be the First to Comment

Hi Folks, after a long time using a home brew blog of wiki pages, I finally decided to upgrade to some decent blog software. There’s lots of reasons behind this but the main reason is because I prefer to use blog software rather than develop it. So stay tuned there should be lots of entries about everything in the near future.