Showing posts with label Mac OS X. Show all posts
Showing posts with label Mac OS X. Show all posts

Sunday, April 15, 2012

OpenBSD, NetBSD and libusb-1.0

There is OpenBSD support in libusb.git. Since NetBSD and OpenBSD should have quite similar USB codes, I think that it should work under NetBSD as well.
Therefore I tried the following dirty patch to enable libusb-1.0 experimental support for NetBSD using the OpenBSD backend.
Take note FreeBSD has its own libusb-1.0 implementation which should be more mature than the OpenBSD backends of libusb-1.0 which is very recent.
diff --git a/configure.ac b/configure.ac
index ebbc107..71aad37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,17 @@ case $host in
       AC_CHECK_HEADERS([poll.h])
       AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
       ;;
+*-netbsd*)
+       AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend])
+       AC_SUBST(OS_OPENBSD)
+       AC_MSG_RESULT([OpenBSD])
+       backend="openbsd"
+       threads="posix"
+       THREAD_CFLAGS="-pthread"
+       PC_LIBS_PRIVATE="-pthread"
+       AC_CHECK_HEADERS([poll.h])
+       AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
+       ;;
 *-mingw*)
       AC_MSG_RESULT([Windows])
       backend="windows"
And indeed it seems to work under NetBSD (tested with a NetBSD 5.1 VirtualBox VM under Mac OS X Lion)
localhost$ sudo ./listdevs
04d8:fa2e (bus 0, device 2)
I also tested libusb-pbatard's xusb example.
localhost$ sudo ./xusb -d 04d8:fa2e

Opening device...
speed: Unknown

Reading device descriptor:


Reading device descriptor:
           length: 18
     device class: 0
              S/N: 3
          VID:PID: 04D8:FA2E
        bcdDevice: 0001
  iMan:iProd:iSer: 1:2:3
         nb confs: 1

Reading configuration descriptors:
            nb interfaces: 1
             interface[0]: id = 0
interface[0].altsetting[0]: num endpoints = 2
  Class.SubClass.Protocol: 00.00.00
      endpoint[0].address: 01
          max packet size: 0020
         polling interval: 00
      endpoint[1].address: 81
          max packet size: 0020
         polling interval: 00
interface[0].altsetting[1]: num endpoints = 2
  Class.SubClass.Protocol: 00.00.00
      endpoint[0].address: 01
          max packet size: 0040
         polling interval: 00
      endpoint[1].address: 81
          max packet size: 0040
         polling interval: 00

Claiming interface 0...

Reading string descriptors:
  String (0x01): "Travis Robinson"
  String (0x02): "Benchmark Device"
  String (0x03): "LUSBW1"

Releasing interface 0...
Closing device...

Saturday, March 10, 2012

Mac Mini 2011 Impression

My 3-year old Acer Desktop (running Windows Vista, Windows 7, Ubuntu Linux and Arch Linux) died in the end of 2011 and I decided to try Mac OS X instead as my main home desktop. The cheapest option from Apple is Mac Mini 2011 and I chose to buy the cheapest option at S$788 ( http://www.apple.com/sg/macmini/ ).

The spec is fine for me, Intel Core i5 2.3GHz, 2GB DDR3 RAM, 500GB 5400rpm HDD, built-in Intel HD3000 graphics, 802.11n WiFi, Bluetooth, Gigabit Ethernet, Thunderbolt, Firewire 800, USB 2.0, HDMI, SDXC Card Slot. I use it with a 20 inch Compaq monitor (resolution 1600 x 900), an Acer keyboard and a Logitech wireless USB mouse. The 4 USB ports are not enough for me so I use a USB hub as well. A cheap web camera is also attached. I also use a 1TB external USB HDD (Western Digital Mybook Essential) as the backup disk using Time Machine.

The weakest link is the 2GB DDR3 RAM which I intend to upgrade soon. Mac OS X Lion is 64bit and it seems to require more ram than Windows 7 x64. USB 3.0 would be nice but we may have to wait for next-generation Intel chipset with USB 3.0 built-in.

I have no problems with the Mac Mini so far after 3 months of use other than than the occasional slow response which I hope to fix after upgrading the RAM.

Under Windows and Linux, I usually use Firefox as the main Internet browser with Chrome as the backup. But with this Mac Mini, I tend to use Safari more often.

I have no problem to build applications (e.g.: libusb, libftdi, OpenOCD, pyusb, etc) with Mac Homebrew since I am familiar with the terminal environment under Linux and Windows (Cygwin/MSys).

MPlayerX and VLC are the two main video player for me. iTune is also used occasionally.

I have Microsoft Office for Mac 2011 installed but I am not using it very often.

The App Store for Mac is quite convenient, however not many apps are available for Mac OS X compared to iOS ( I have an iPad 2).

Edit: upgraded to 8GB RAM (4GB x 2) and now it funs much more smooth. I also installed VirtualBox and then quite a few VMs (Windows and Linux) and they work fine. Good thing is that USB seems to work fine as well under VirtualBox.