Grasping at straws I tried this SwitchModem utility in this blogpost. It is 
designed for the Huawei.

http://tinyurl.com/yk348qb

This was the result:

felixdz at rEn0:~$ echo ::prtusb | pfexec mdb -k
INDEX   DRIVER      INST  NODE            VID.PID     PRODUCT             
1       ehci        0     pci1025,15b     0000.0000   No Product String
2       uhci        0     pci1025,15b     0000.0000   No Product String
3       uhci        1     pci1025,15b     0000.0000   No Product String
4       uhci        2     pci1025,15b     0000.0000   No Product String
5       uhci        3     pci1025,15b     0000.0000   No Product String
6       usb_mid     0     miscellaneous   0c45.62c0   USB 2.0 Camera
7       scsa2usb    0     storage         1a8d.1000   
BandLuxe  3.5G HSPA Adapter
felixdz at rEn0:~$ /usr/sfw/bin/gcc switch_modem.c -lusb -o switch_huawei
switch_modem.c:18: error: syntax error before numeric constant
switch_modem.c:18:22: invalid suffix "a8d" on integer constant
switch_modem.c: In function `send_bulk_command':
switch_modem.c:35: error: `udev' undeclared (first use in this function)
switch_modem.c:35: error: (Each undeclared identifier is reported only once
switch_modem.c:35: error: for each function it appears in.)
switch_modem.c: In function `main':
switch_modem.c:72: error: `udev' undeclared (first use in this function)

My switch_modem.c:

/*
 *  Copyright (C) 2009 ChenL
 *
 *  switch_modem.c
 *  Switch HUAWEI series modem from storage to modem device.
 *  To compile:
 *      /usr/sfw/bin/gcc switch_modem.c -lusb -R/usr/sfw/lib/ \
 *              -L /usr/sfw/lib -o switch_huawei
 *  or if your libusb is in /usr/lib, just:
 *      /usr/sfw/bin/gcc switch_modem.c -lusb -o switch_huawei
 */

#include <stdio.h>
#include "usb.h"

#define HUAWEI_VENDOR   0x12d1
#define HUAWEI_PRODUCT  0x1446 /* Change this to your own device ID! */
define HUAWEI_VENDOR 00001a8d
define HUAWEI_PRODUCT 00001000
static usb_dev_handle *udev;

/*
 * Not sure what's purpose of this command. But we need it. The device
 * seems to perform a reset upon receiving it.
 */
int send_bulk_command()
{
        unsigned char command[] = {
                0x55, 0x53, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,
                0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
        };
        
        if (usb_claim_interface(udev, 0) != 0) {
                printf("Fail to claim interface: %d\n", usb_strerror());
                return (-1);
        }

        if ((usb_clear_halt(udev, 0x87) != 0) ||
            (usb_clear_halt(udev, 0x08) != 0)) {
                printf("Fail to clear halt: %d\n", usb_strerror());
                return (-1);
        }

        if (usb_bulk_write(udev, 0x08, (char *)command, 31, 0) != 0) {
                printf("Fail to send SCSI command: %s\n", usb_strerror());
        }
}

int main(void)
{
        struct usb_bus *bus;
        struct usb_device *dev;

        usb_init();

        usb_find_busses();
        usb_find_devices();

        printf("bus/device  idVendor/idProduct\n");

        for (bus = usb_busses; bus; bus = bus->next) {
                for (dev = bus->devices; dev; dev = dev->next) {
                        int i, ret;
                        char string[256];

                        printf("%s/%s     %04X/%04X\n", bus->dirname,
                            dev->filename, dev->descriptor.idVendor,
                            dev->descriptor.idProduct);

                        udev = usb_open(dev);
                        if (udev) {
                                if (dev->descriptor.iManufacturer) {
                                        ret = usb_get_string_simple(udev,
                                            dev->descriptor.iManufacturer,
                                            string, sizeof(string));
                                        if (ret > 0)
                                                printf("- Manufacturer : %s\n",
                                                    string);
                                        else
                                                printf("- Unable to fetch"
                                                    " manufacturer string %d\n",
                                                    ret);
                                }


                                if (dev->descriptor.iProduct) {
                                        ret = usb_get_string_simple(udev,
                                            dev->descriptor.iProduct,
                                            string, sizeof(string));
                                        if (ret > 0)
                                                printf("- Product      : %s\n",
                                                    string);
                                        else
                                                printf("- Unable to fetch"
                                                    " product string\n");
                                }

                                if (dev->descriptor.iSerialNumber) {
                                        ret = usb_get_string_simple(udev,
                                            dev->descriptor.iSerialNumber,
                                            string, sizeof(string));
                                        if (ret > 0)
                                                printf("- Serial Number: %s\n",
                                                    string);
                                        else
                                                printf("- Unable to fetch 
serial"
                                                    " number string\n");
                                }

                                if ((dev->descriptor.idVendor == HUAWEI_VENDOR)
                                    && (dev->descriptor.idProduct == 
HUAWEI_PRODUCT)) {
                                        int rval;

                                        rval = usb_control_msg(udev,
                                            USB_TYPE_STANDARD | 
USB_RECIP_DEVICE,
                                            USB_REQ_SET_FEATURE,
                                            1, /* wValue */
                                            0, /* wIndex */
                                            0, /* wLength */
                                            0, /* size */
                                            0  /* timeout */);

                                        if (rval != 0) {
                                                printf("Can't switch the 
modem's"
                                                    " configuration \n");
                                        } else {
                                                printf("Switch Huawei modem's"
                                                    " config successfully\n");
                                        }

                                        send_bulk_command();

                                        usb_close(udev);

                                        goto done;
                                }

                                printf("No matching devices found!\n");

                                usb_close(udev);
                        }
                }
        }

done:
        return 0;
}


Any other Ideas?
-- 
This message posted from opensolaris.org

Reply via email to