Tuesday, February 09, 2010

Nady USB-1C doesn't get recognized

I couldn't figure out why my Nady USB-1C USB mic didn't get detected in Linux. It showed up in lsusb as 17a0:0001 as it should, but I got errors in dmesg. Turns out it was the passive USB extension I was using with it. Works fine with an active extension.

Tuesday, January 26, 2010

App Engine: AttributeError: 'module' object has no attribute 'Message'

Today I wasted over an hour trying to receive mail in App Engine. Every time I'd try to use it, I'd get errors like:

'module' object has no attribute 'Message'
Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 509, in __call__
handler.post(*groups)
File "/base/python_lib/versions/1/google/appengine/ext/webapp/mail_handlers.py", line 58, in post
self.receive(mail.InboundEmailMessage(self.request.body))
File "/base/python_lib/versions/1/google/appengine/api/mail.py", line 546, in __init__
mime_message = _parse_mime_message(mime_message)
File "/base/python_lib/versions/1/google/appengine/api/mail.py", line 227, in _parse_mime_message
if isinstance(mime_message, email.Message.Message):
AttributeError: 'module' object has no attribute 'Message'

Turns out I'd named my file "email.py", which is a builtin module for python. Rename it and it works fine.

Don't forget to delete the email.pyc, or your dev_appserver will complain about "ImportError: No module named email.message".

Monday, January 25, 2010

Firefox crashes when using facebook chat

Using firefox 3 for Linux, I was surprised to see it keep crashing when I chatted with a friend on facebook. It only happens when receiving messages with smileys :) and when the Chat... Options... "Play Sound for New Messages" option is enabled. So turn that off if you experience this bug.

Tuesday, January 19, 2010

Use vlc to find the title number for mplayer, or, Disney Sucks

Some studios (Disney is one of the worst) put stupid copy protection measures on their DVDs that make them difficult to play on anything but a DVD player. That's a great way to tick off your completely legitimate paying customers.

One of the common ones is to make something other than the first title the start of the movie, or worse, to put one or more corrupt copies of the start of the movie, then have the actual movie start on title 74 or something. This makes it hard to play the DVDs on Linux with mplayer.

To work around this on a Linux machine, use vlc to find the true start of the movie. File... Open Disc... DVD (menus) and start playing the movie. (Feel free to simply watch the movie at this point). Wait until you get to the first scene. Then in the Playback... Navigation dropdown you can find the title number. Let's say it's 37. Then you should be able to play the movie with mplayer dvd://37

Monday, January 11, 2010

Netflix sucks

Netflix is mostly doing the right things: today they sent me a very specific, very short survey about a movie I just watched. Good, don't waste my time! But they didn't even give me the option to type free text comments about the quality. It's actually something I was interested in and willing to give them some details on.

So I went to the account info page, and got the typical wild goose chase where companies don't want to admit that they won't let you email them. So now you've wasted my time when I was trying to help you out. That turned me from a happy, engaged customer into an annoyed one without an outlet. So it goes on the blog instead, and costs you other customers.

Friday, December 11, 2009

unable to enumerate usb device

Today on an Ubuntu Karmic Koala machine, we plugged in a Canon camera and got a bunch of "unable to enumerate usb device" messages when we looked at dmesg. Turns out it was a bad cable. So check that first if you get that message.

Wednesday, December 09, 2009

Disable mouse or touchpad in xorg

Update: Apparently figuring out how to disable x input devices like mice, keyboards and touch pads is hard to find on the search engines, so I'm updating the post to make it more findable. (This post was originally called "Ubuntu karmic: 3dconnexion Space Navigator and xorg", but I just helped a friend of mine disable his EEE PC's elantech touch pad, and realized that the solution is general purpose.)

My friend always uses an external mouse with his laptop, and accidentally brushes the touch pad when he's typing. So he wanted to find a way to shut off the touch pad.

In Ubuntu Karmic Koala (9.10), xorg now autodetects my 3dConnexion Space Navigator and uses its events for mouse X and Y, which is not what I want.

I just discovered xinput, though, which is extremely cool. Thanks Philip Langdale and Frederic Lepied for writing it!


root@lg1:~# xinput list
...
"3Dconnexion SpaceNavigator" id=9 [XExtensionPointer]
Type is MOUSE
Num_buttons is 5
Num_axes is 6
Mode is Relative
Motion_buffer is 256
Axis 0 :
Min_value is -1
Max_value is -1
Resolution is 1
Axis 1 :
Min_value is -1
Max_value is -1
Resolution is 1
Axis 2 :
Min_value is -1
Max_value is -1
Resolution is 1
Axis 3 :
Min_value is -1
Max_value is -1
Resolution is 1
Axis 4 :
Min_value is -1
Max_value is -1
Resolution is 1
Axis 5 :
Min_value is -1
Max_value is -1
Resolution is 1


root@lg1:~# xinput list-props "3Dconnexion SpaceNavigator"
Device '3Dconnexion SpaceNavigator':
Device Enabled (93): 1
Evdev Reopen Attempts (227): 10
Evdev Axis Inversion (228): 0, 0
Evdev Axis Calibration (229):
Evdev Axes Swap (230): 0
Evdev Middle Button Emulation (231): 2
Evdev Middle Button Timeout (232): 50
Evdev Wheel Emulation (233): 0
Evdev Wheel Emulation Axes (234): 0, 0, 4, 5
Evdev Wheel Emulation Inertia (235): 10
Evdev Wheel Emulation Timeout (236): 200
Evdev Wheel Emulation Button (237): 4
Evdev Drag Lock Buttons (238): 0

root@lg1:~# xinput get-feedbacks "3Dconnexion SpaceNavigator"
1 feedback class
PtrFeedbackClass id=0
accelNum is 2
accelDenom is 1
threshold is 4

root@lg1:~# xinput set-ptr-feedback "3Dconnexion SpaceNavigator" 4 8 1 # very sensitive X pointer
root@lg1:~# xinput set-ptr-feedback "3Dconnexion SpaceNavigator" 4 1 8 # much less sensitive.


The threshold parameter doesn't seem to do anything.

Ah, here's the magic to make it stop influencing the pointer:

root@lg1:~# xinput set-int-prop "3Dconnexion SpaceNavigator" 93 8 0 # property 93 from list-props


Also works as:

root@lg1:~# xinput set-int-prop "3Dconnexion SpaceNavigator" "Device Enabled" 8 0
root@lg1:~# xinput set-int-prop "3Dconnexion SpaceNavigator" "Device Enabled" 8 1 # reenable

Unfortunately, I don't see any way to re-zero if it drifts (often happens when they're cold or hot or brand new), or turn on the LED. Here's C code to do it, though:


#include <sys/ioctl.h>
#include <error.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <linux/input.h>

main(int argc, char **argv) {

int fd;
int retval;
struct input_event ev; /* the event */

if (argc != 3) {
printf("Usage: %s device 1|0\n", argv[0]);
exit(2);
}

if ((fd = open(argv[1], O_WRONLY)) < 0) {
perror("opening the file you specified");
exit(1);
}

ev.type = EV_LED;
ev.code = LED_MISC;
ev.value = (argv[2][0] == '1') ? 1:0;
write(fd, &ev, sizeof(struct input_event));
}