Assuming "Error #9" is a standard Unix error, it's EBADF, or "Bad file number". That probably means the device isn't being opened properly. Are you checking for possible errors after opening the device? Can you get your program down to a few lines that demonstrate the problem, and post that here?