January 15, 2007

Mobile Action 8730P USB Cable And Linux

More than an year ago, I had to use GPRS as a mean of Internet connectivity while travelling. It turned out the only option to connect my Siemens C75 phone to the notebook was a special USB cable. I double checked the Linux support, and bought the MA-8730P made by Mobile Action. It is based on pl2303 USB<->serial converter chip which is well supported in Linux.

Little I knew that the "P" version (meaning it can charge a phone directly from the USB while it is connected) had a little quirk: to start operating, a small unique sequence must be sent to the converter. Under Windows it is done by a bloaty "Phone Manager" supplied by Mobile Action. Under Linux, the device was recognized by the system but any connection attempts to the USB modem failed.

Some guys have captured this secret sequence under Windows and hacked together a tiny program which enables the cable operation. Since it will undoubtefully
be useful for those unfortunate souls who want to use the MobileAction USB cables under Linux, I'm posting it here (1k). Apparently it also works for the MA-8720P cable.

To compile, run
$ gcc -Wall -o chargerma chargerma.c
To use it, first connect the cable. You should see something like this in your dmesg output:
usb 4-1: new full speed USB device using uhci_hcd and address 3
usb 4-1: configuration #1 chosen from 1 choice
pl2303 4-1:1.0: pl2303 converter detected
usb 4-1: pl2303 converter now attached to ttyUSB0
usb 4-1: New USB device found, idVendor=067b, idProduct=2303
usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 4-1: Product: USB-Serial Controller
usb 4-1: Manufacturer: Prolific Technology Inc.
Now run (as root)
# ./chargerma /dev/ttyUSB0
Note that you have to run it every time after a cable disconnect to restore the modem functionality. I guess by making use of some udev/hotplug rules this program could be run automatically on each cable connect, but my hotplug-fu is not that strong yet.
Below is the full program text for the reference.

#include  <stdio.h>
#include <termio.h>
#include <unistd.h>
#include <fcntl.h>

int main(int argc, char* argv[])
{
int fd;
int status, result;
char *buf = "\x55\x55\x55\x55\x04\x01\r\x0";
struct termios options;

if (argc == 1) {
printf("usage: chargerma /dev/ttyUSB0\n");
return 0;
}

fd = open(argv[1], O_RDWR | O_NDELAY);
if (fd == -1) {
perror("open_port: Unable to open port\n");
return -1;
}

// Init the port
ioctl(fd, TIOCMGET, &status);
status |= TIOCM_RTS;
status &= ~TIOCM_DTR;
result = ioctl(fd, TIOCMSET, &status);
tcgetattr(fd, &options);
cfsetispeed(&options, B9600);
cfsetospeed(&options, B9600);
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;

// Send the secret sequence
result = write(fd, buf, 8);
if (result < 0)
fputs("write failed!\n", stderr);
tcsetattr(fd, TCSAFLUSH, &options);
close(fd);
return 0;
}


UPDATE: Some quick googling showed that exactly the same technique works also for the MA-8230P and MA-8910P USB cables. I would guess it'll work for all "P" variations of the Mobile Action cables (MA-8020P, 8250P, 8260P, 8270P, 8280P, 8290P, 8830P, 8310P, 8320P) in Linux. You're welcome to test it out!

4 comments:

Anonymous said...

great work! It worked for my sony ericsson z600

Anonymous said...

Glad it worked for you. Though I'm not the one who came up with it - I'm just spreading the knowledge here.

Call me "djoelfy" said...

How to use it under ubuntu server (i use 8.10)? Thks

Figgie said...

Doesn't running it as root as described in the post work for you?