ftdi dongleid FT232/245R 
I used the library from FTDI (libftchipid - is only in binary and linked against old libc) to get the dongleid.

I had to "sudo chmod 666 /proc/bus/usb/001/021".

There is an opensource library (libftdi) from intra2net that lacks support of reading the dongleid.

After usb sniffing (LD_PRELOAD=/usr/lib/libusbsniff.so ~/ftdi/id/ChipID) and disassembling (ddd) parts of libftchipid (bitshift) i made a patch for libftdi.

libftdi-0.10/src:

--- ftdi.c.orig 2007-05-03 18:06:04.000000000 +0200
+++ ftdi.c 2007-10-18 16:05:50.000000000 +0200
@@ -1228,6 +1228,45 @@
}

/**
+ Read dongleid
+
+ \param ftdi pointer to ftdi_context
+
+ \retval 0: all fine
+ \retval -1: read failed
+*/
+int ftdi_read_dongleid(struct ftdi_context *ftdi, unsigned int *dongleid)
+{
+ unsigned char shift(unsigned char value)
+ {
+ return ((value & 1) << 1) |
+ ((value & 2) << 5) |
+ ((value & 4) >> 2) |
+ ((value & 8) << 4) |
+ ((value & 16) >> 1) |
+ ((value & 32) >> 1) |
+ ((value & 64) >> 4) |
+ ((value & 128) >> 2);
+ }
+
+ unsigned int a = 0, b = 0, result = -1;
+
+ if (usb_control_msg(ftdi->usb_dev, 0xC0, 0x90, 0, 0x43, (char *)&a, 2, ftdi->usb_read_timeout) == 2)
+ {
+ a = a << 8 | a >> 8;
+ if (usb_control_msg(ftdi->usb_dev, 0xC0, 0x90, 0, 0x44, (char *)&b, 2, ftdi->usb_read_timeout) == 2)
+ {
+ b = b << 8 | b >> 8;
+ a = (a << 16) | b;
+ a = shift(a) | shift(a>>8)<<8 | shift(a>>16)<<16 | shift(a>>24)<<24;
+ *dongleid = a ^ 0xa5f0f7d1;
+ result = 0;
+ }
+ }
+ return result;
+}
+
+/**
Write eeprom

\param ftdi pointer to ftdi_context


--- ftdi.h.orig 2007-10-18 15:47:57.000000000 +0200
+++ ftdi.h 2007-10-18 16:05:56.000000000 +0200
@@ -266,6 +266,7 @@
// "eeprom" needs to be valid 128 byte eeprom (generated by the eeprom generator)
// the checksum of the eeprom is valided
int ftdi_read_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
+ int ftdi_read_dongleid(struct ftdi_context *ftdi, unsigned int *dongleid);
int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
int ftdi_erase_eeprom(struct ftdi_context *ftdi);


ftdi_eeprom-0.2/ftdi_eeprom:

--- main.c.orig 2004-03-25 19:58:08.000000000 +0100
+++ main.c 2007-10-18 16:08:11.000000000 +0200
@@ -64,6 +64,8 @@
struct ftdi_context ftdi;
struct ftdi_eeprom eeprom;

+ unsigned int dongleid;
+
printf("\nFTDI eeprom generator v%s\n", VERSION);
printf ("(c) Intra2net AG <opensource@intra2net.com>\n");

@@ -150,6 +152,8 @@
} else {
printf("Warning: Not writing eeprom, you must supply a valid filename\n");
}
+ printf("FTDI read dongleid: %d\n", ftdi_read_dongleid(&ftdi, &dongleid));
+ printf("FTDI dongleid: %X\n", dongleid);

goto cleanup;
}


[ view entry ] ( 1034 views )   |  print article
usbmonitor libusb usbsniff 
Linux Kernel:

modprobe usbmon
mount -t debugfs none_debugs /sys/kernel/debug
cat /sys/kernel/debug/usbmon/<x>t (x=Gerätenummer 1,2,3,...)

libusb with radare/libusbsniff:
LD_PRELOAD=/usr/lib/libusbsniff.so ./my-usb-program


[ view entry ] ( 766 views )   |  print article
whiptail 
this one-liner has following benefits:

* restart if pressing ESC (while ! ... ; do true; done)

* store result in a variable not a file (whiptail ... 3>&1 1>&2 2>&3)
while ! choosen=$(whiptail --nocancel --noitem --radiolist "Please choose" \
10 19 3 1 1 2 0 3 0 3>&1 1>&2 2>&3); do true; done


[ view entry ] ( 852 views )   |  print article
Internetaccess via Huawei E220 UMTS/GPRS Modem 
Kernel < 2.6.20 needs a udev rule:

http://www.kanoistika.sk/bobovsky/archi ... eiAktBbo.c

/etc/udev/rules.d/82-huawei220.rules

ACTION=="add", SUBSYSTEM=="usb_device", \
ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", \
RUN+="/usr/sbin/huaweiAktBbo"

/etc/ppp/peers/huawei
ttyUSB0
460800
idle 7200
lock
crtscts
modem
noauth
#usepeerdns (sometimes i got no dns -> edit /etc/resolv.conf)
replacedefaultroute
defaultroute
noipdefault
noccp
nobsdcomp
novj
user "web"
password "web"
connect /etc/ppp/peers/huawei-chat
disconnect /etc/ppp/peers/disconnect-chat
ipcp-restart 8
ipcp-max-configure 30
ipcp-accept-local
ipcp-accept-remote
noipv6
noipx
mtu 1420
connect-delay 10000
noproxyarp
novjccomp
updetach
debug

/etc/ppp/peers/huawei-chat
exec chat                                   \
TIMEOUT 5 \
ECHO ON \
ABORT '\nBUSY\r' \
ABORT '\nERROR\r' \
ABORT '\nNO ANSWER\r' \
ABORT '\nNO CARRIER\r' \
ABORT '\nNO DIALTONE\r' \
ABORT '\nRINGING\r\n\r\nRINGING\r' \
'' \rATZ \
TIMEOUT 3 \
SAY "Press CTRL-C to close the connection at any stage!" \
SAY "\ndefining PDP context...\n" \
OK "AT+CPIN?" \
READY-AT+CPIN="XXXX"- \c \
OK AT+CPIN? \
READY \c \
OK "ATE1V1&D2&C1S0=0+IFC=2,2" \
OK AT+CGDCONT=1,\"IP\",\"fullspeed\" \
OK ATD*99***1# \
TIMEOUT 22 \
SAY "\nwaiting for connect...\n" \
CONNECT "" \
SAY "\nConnected." \
SAY "\nIf the following ppp negotiations fail,\n" \
SAY "try restarting the phone.\n"

/etc/ppp/peers/disconnect-chat
exec /usr/sbin/chat -V -s -S    \
ABORT "BUSY" \
ABORT "ERROR" \
ABORT "NO DIALTONE" \
SAY "\nSending break to the modem\n" \
"" "\K" \
"" "\K" \
"" "\K" \
"" "\d\d+++\d\dATH" \
SAY "\nPDP context detached\n"

/etc/network/interfaces
allow-hotplug huawei
iface huawei inet ppp
provider huawei

http://wwwu.uni-klu.ac.at/agebhard/HuaweiE220/
http://linux.frankenberger.at/Huawei_E220.html
http://oozie.fm.interia.pl/pro/huawei-e220/

Often DNS is not set during PPP connection. A workaround is

/etc/ppp/options:
ipcp-max-failure 30


[ view entry ] ( 906 views )   |  print article
udev - usb add / remove 
Because udev didn't know anything of idVendor or idProduct if you remove a device i use ENV{PRODUCT} to match for my unplugged device:


ACTION=="add", KERNEL=="event*", SUBSYSTEM=="input", \
SYSFS{idVendor}=="1234", SYSFS{idProduct}=="5678", \
SYMLINK+="input/myevent"

ACTION=="remove", SUBSYSTEM=="usb", \
ENV{PRODUCT}=="1234/5678/100", \
RUN+="/usr/bin/killall myprog"


[ view entry ] ( 857 views )   |  print article

<<First <Back | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Next> Last>>