diff options
Diffstat (limited to 'extras/modem-modeswitch/ma8280p_us.c')
-rw-r--r-- | extras/modem-modeswitch/ma8280p_us.c | 334 |
1 files changed, 171 insertions, 163 deletions
diff --git a/extras/modem-modeswitch/ma8280p_us.c b/extras/modem-modeswitch/ma8280p_us.c index 13d11160e1..3cf9eb9eb2 100644 --- a/extras/modem-modeswitch/ma8280p_us.c +++ b/extras/modem-modeswitch/ma8280p_us.c @@ -87,11 +87,19 @@ #include <assert.h> #include <signal.h> #include <ctype.h> +#include <time.h> #include <usb.h> #include "utils.h" #include "ma8280p_us.h" +static void msleep(long msec) +{ + struct timespec duration = { 0, msec * 1000 * 1000 }; + + nanosleep(&duration, NULL); +} + int ma8280p_switch (struct usb_dev_handle *devh, struct usb_device *dev) { int ret = 1; @@ -104,11 +112,11 @@ int ma8280p_switch (struct usb_dev_handle *devh, struct usb_device *dev) } ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012); - usleep(6*1000); + msleep(6); ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012); - usleep(6*1000); + msleep(6); ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000400); - usleep(10*1000); + msleep(10); ret = usb_release_interface(devh, 0); if (ret != 0) debug ("%s: failed to release interface before set_configuration: %d", dev->filename, ret); @@ -117,335 +125,335 @@ int ma8280p_switch (struct usb_dev_handle *devh, struct usb_device *dev) if (ret != 0) debug ("%s: claim after set_configuration failed with error %d", dev->filename, ret); //ret = usb_set_altinterface(devh, 0); - //usleep(33*1000); + //msleep(33); ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE + USB_ENDPOINT_IN, 0x0000001, 0x0000300, 0x0000000, buf, 0x0000008, 1000); - usleep(5*1000); + msleep(5); memcpy(buf, "\xb0\x04\x00\x00\x02\x90\x26\x86", 0x0000008); ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000009, 0x0000300, 0x0000000, buf, 0x0000008, 1000); - usleep(4*1000); + msleep(4); memcpy(buf, "\xb0\x04\x00\x00\x02\x90\x26\x86", 0x0000008); ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000009, 0x0000300, 0x0000000, buf, 0x0000008, 1000); - usleep(4*1000); + msleep(4); - usleep(4*1000); + msleep(4); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(6*1000); + msleep(6); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + msleep(1); //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped - usleep(4*1000); + msleep(4); memcpy(buf, "\x37\x01\xfe\xdb\xc1\x33\x1f\x83", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(3*1000); + msleep(3); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + msleep(1); memcpy(buf, "\x37\x0e\xb5\x9d\x3b\x8a\x91\x51", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(7*1000); + msleep(7); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + msleep(1); memcpy(buf, "\x34\x87\xba\x0d\xfc\x8a\x91\x51", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(7*1000); + msleep(7); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(2*1000); + msleep(2); //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped - usleep(4*1000); + msleep(4); memcpy(buf, "\x37\x01\xfe\xdb\xc1\x33\x1f\x83", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(2*1000); + msleep(2); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + msleep(1); memcpy(buf, "\x37\x0e\xb5\x9d\x3b\x8a\x91\x51", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(7*1000); + msleep(7); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + msleep(1); memcpy(buf, "\x34\x87\xba\x0d\xfc\x8a\x91\x51", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(7*1000); + msleep(7); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + msleep(8); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + msleep(1); //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped - usleep(4*1000); + msleep(4); memcpy(buf, "\x33\x04\xfe\x00\xf4\x6c\x1f\xf0", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(3*1000); + msleep(3); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + msleep(1); //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped - usleep(4*1000); + msleep(4); memcpy(buf, "\x32\x07\xfe\xf0\x29\xb9\x3a\xf0", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(3*1000); + msleep(3); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); if (buf) |