From owner-freebsd-questions@FreeBSD.ORG Fri Dec 7 09:37:01 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9873B16A417; Fri, 7 Dec 2007 09:37:01 +0000 (UTC) (envelope-from nospam@mgedv.net) Received: from mail.mgedv.net (mail.mgedv.net [213.229.1.44]) by mx1.freebsd.org (Postfix) with ESMTP id AB36113C4CE; Fri, 7 Dec 2007 09:37:00 +0000 (UTC) (envelope-from nospam@mgedv.net) Received: from wzits045 (client.vpn.loop [192.168.177.20]) by mail.my.loop (mgedv) with ESMTP id 5B4A71C62C1; Fri, 7 Dec 2007 10:36:59 +0100 (CET) Message-ID: <001101c838b4$b7153bf0$14b1a8c0@bstandard.lan> From: "no@spam@mgedv.net" To: , , "Hans Petter Selasky" References: <006701c8380d$e12ecc50$14b1a8c0@bstandard.lan><200712061553.54412.hselasky@c2i.net><000601c8382b$0b9459c0$14b1a8c0@bstandard.lan> <200712062018.50262.hselasky@c2i.net> Date: Fri, 7 Dec 2007 10:36:58 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Cc: Subject: Re: huawei e220 hsdpa on freebsd 6.3-BETA2 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Dec 2007 09:37:01 -0000 > Your HSDPA modem presented itself like a mass storage device, probably > with > some autorun and virus like drivers intended for the Windows operating > system :-) unfortunately, this is the "intended" behaviour. this device has the ability to present itself as "mass storage" which will show up as a cd-rom device where the windows drivers are stored on. this is the way it works under windows: - plug it in first time - (auto)run the setup on the device for the win-driver - as soon as the driver is loaded, the cd device disappears and a modem is detected but when loading the ucom/ubsa stuff before umass, the device will not be recognised as /dev/cdX and show up as a communication device (ucom). of course there must be a way for getting the serial device working, because this is one of the most sold umts/hsdpa modems across eu and many people run it under linux as well (there are no drivers from the vendor provided except windows and mac). i'm pretty sure there is some "message" or anything else which will render this device switching to serial mode. there is some code, which i found (doesn't compile/run under freebsd) which "puts" this device in pure serial mode. maybe someone out there is able to tell me, how/if this can be done on freebsd as well? (btw, i'm not a c-guru) do you (or anybody else reading this) have an idea, how to get this device working and put it in serial mode "completely" ? regards... THIS IS THE C CODE WHICH WORKS (ANYHOW) ON LINUX: =========================================== 1st: huaweiAktBbo.c =========================================== /* HUAWEI E220 3G HSDPA modem - Aktivator modemu = aktivuje ttyUSB0 tty USB1 bobovsky 11.12.2006 dalej sa uz pouzije usbserial a usb-storage cc huaweiAktBbo.c -lusb (resp -I. -L.) armeb-linux-gcc huaweiAktBbo.c -L. -I. -lusb Copyright (C) 2006 bobovsky bobovsky@kanoistika.sk GPL This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License2. */ #include #include #include #include #include #include #include #if 0 #include #define LIBUSB_AUGMENT #include "libusb_augment.h" #endif struct usb_dev_handle *devh; void release_usb_device(int dummy) { int ret; ret = usb_release_interface(devh, 0); if (!ret) printf("failed to release interface: %d\n", ret); usb_close(devh); if (!ret) printf("failed to close interface: %d\n", ret); exit(1); } void list_devices() { struct usb_bus *bus; for (bus = usb_get_busses(); bus; bus = bus->next) { struct usb_device *dev; for (dev = bus->devices; dev; dev = dev->next) printf("0x%04x 0x%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); } } struct usb_device *find_device(int vendor, int product) { struct usb_bus *bus; for (bus = usb_get_busses(); bus; bus = bus->next) { struct usb_device *dev; for (dev = bus->devices; dev; dev = dev->next) { if (dev->descriptor.idVendor == vendor && dev->descriptor.idProduct == product) return dev; } } return NULL; } void print_bytes(char *bytes, int len) { int i; if (len > 0) { for (i=0; i= 0); */ // BBO typ 1 = DEVICE ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012); //printf("1 get descriptor returned %d, bytes: ", ret); //print_bytes(buf, ret); //printf("\n"); usleep(1*1000); // BBO typ 2 = CONFIGURATION ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000009); //printf("2 get descriptor returned %d, bytes: ", ret); //print_bytes(buf, ret); //printf("\n"); usleep(1*1000); // BBO typ 2 = CONFIGURATION ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000020); //printf("3 get descriptor returned %d, bytes: ", ret); //print_bytes(buf, ret); //printf("\n"); usleep(1*1000); /* ret = usb_release_interface(devh, 0); if (ret != 0) printf("failed to release interface before set_configuration: %d\n", ret); ret = usb_set_configuration(devh, 0x0000001); printf("4 set configuration returned %d\n", ret); ret = usb_claim_interface(devh, 0); if (ret != 0) printf("claim after set_configuration failed with error %d\n", ret); ret = usb_set_altinterface(devh, 0); printf("4 set alternate setting returned %d\n", ret); usleep(50*1000); ret = usb_set_altinterface(devh, 0); printf("5 set alternate setting returned %d\n", ret); usleep(62*1000); */ ret = usb_control_msg(devh, USB_TYPE_STANDARD + USB_RECIP_DEVICE, USB_REQ_SET_FEATURE, 00000001, 0, buf, 0, 1000); printf("4 set feature request returned %d\n", ret); /* ret = usb_release_interface(devh, 0); assert(ret == 0); */ ret = usb_close(devh); assert(ret == 0); printf("Prepnute-OK, Mas ttyUSB0 ttyUSB1 (cez usbserial vendor=0x12d1 product=0x1003)\n"); printf("pozri /proc/bus/usb/devices\n"); return 0; } =========================================== and the other c-code: (huaweiAktBbo_pt-BR.c) =========================================== /* HUAWEI E220 3G HSDPA modem - Utilitário para Ativação = ativa ttyUSB0 e ttyUSB1 bobovsky 11.12.2006 O próximo passo é usar usbserial e usb-storage para ppp(Discagem) e para usb mass-storage(Mídia de armazenamento USB) para compilar: cc huaweiAktBbo.c -lusb (resp -I. -L.) ou compilação cruzada: armeb-linux-gcc huaweiAktBbo.c -L. -I. -lusb Copyright (C) 2006 bobovsky bobovsky@kanoistika.sk GPL Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo sob os termos da GNU General Public License2. Tradução para o português (pt-BR) por Andrius Ribas andriusmao@gmail.com */ #include #include #include #include #include #include #include #if 0 #include #define LIBUSB_AUGMENT #include "libusb_augment.h" #endif struct usb_dev_handle *devh; void release_usb_device(int dummy) { int ret; ret = usb_release_interface(devh, 0); if (!ret) printf("Falha ao liberar interface: %d\n", ret); usb_close(devh); if (!ret) printf("Falha ao fechar interface: %d\n", ret); exit(1); } void list_devices() { struct usb_bus *bus; for (bus = usb_get_busses(); bus; bus = bus->next) { struct usb_device *dev; for (dev = bus->devices; dev; dev = dev->next) printf("0x%04x 0x%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); } } struct usb_device *find_device(int vendor, int product) { struct usb_bus *bus; for (bus = usb_get_busses(); bus; bus = bus->next) { struct usb_device *dev; for (dev = bus->devices; dev; dev = dev->next) { if (dev->descriptor.idVendor == vendor && dev->descriptor.idProduct == product) return dev; } } return NULL; } void print_bytes(char *bytes, int len) { int i; if (len > 0) { for (i=0; i= 0); */ // BBO typ 1 = DEVICE ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012); //printf("1 get descriptor returned %d, bytes: ", ret); //print_bytes(buf, ret); //printf("\n"); usleep(1*1000); // BBO typ 2 = CONFIGURATION ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000009); //printf("2 get descriptor returned %d, bytes: ", ret); //print_bytes(buf, ret); //printf("\n"); usleep(1*1000); // BBO typ 2 = CONFIGURATION ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000020); //printf("3 get descriptor returned %d, bytes: ", ret); //print_bytes(buf, ret); //printf("\n"); usleep(1*1000); /* ret = usb_release_interface(devh, 0); if (ret != 0) printf("failed to release interface before set_configuration: %d\n", ret); ret = usb_set_configuration(devh, 0x0000001); printf("4 set configuration returned %d\n", ret); ret = usb_claim_interface(devh, 0); if (ret != 0) printf("claim after set_configuration failed with error %d\n", ret); ret = usb_set_altinterface(devh, 0); printf("4 set alternate setting returned %d\n", ret); usleep(50*1000); ret = usb_set_altinterface(devh, 0); printf("5 set alternate setting returned %d\n", ret); usleep(62*1000); */ ret = usb_control_msg(devh, USB_TYPE_STANDARD + USB_RECIP_DEVICE, USB_REQ_SET_FEATURE, 00000001, 0, buf, 0, 1000); printf("4 Requisição de estabelecer característica retornou %d\n", ret); /* ret = usb_release_interface(devh, 0); assert(ret == 0); */ ret = usb_close(devh); assert(ret == 0); printf("Ligado-OK, Você tem os dispositivos ttyUSB0 e ttyUSB1 (use o usbserial vendor=0x12d1 product=0x1003)\n"); printf("veja /proc/bus/usb/devices\n"); return 0; } =========================================== EOF.