hi everyone
I have a usb gsm modem (siemens MC35) and i wanna send an sms through this modem, but whatever command I send to the modem, the response is the same:1'
this is what i have done:

final UsbPipe usbPipein = usbEndpointin.getUsbPipe();
final UsbPipe usbPipeout = usbEndpointout.getUsbPipe();
//I had to define them as final to be able to work with them in the thread
after that i open the pipes, then:


Thread runner1 = new Thread () {
            public void run () {
                UsbIrp irp = usbPipeout.createUsbIrp();
                irp.setData("ATI".getBytes());

               try{
                   usbPipeout.syncSubmit(irp);
                   Thread.sleep(1000);

               if (1 > irp.getActualLength()){
                     System.out.print("failed");
                   throw new Exception("packet sending failed");
               }
               }catch(Exception e){};
            }};< br>           
        Thread runner2 = new Thread () {
            public void run () {
                byte[] resData = new byte[64];
                try{
                     Thread.sleep(1000);
                      UsbIrp inIrp = usbPipein.createUsbIrp();
                     inIrp.setData(resData);
                     int bytesRead = 0;
                     do{
                       usbPipein.syncSubmit(inIrp);
                       bytesRead = inIrp.getActualLength();
                       totalBytes += bytesRead;
                     } while (!inIrp.isComplete());
                        System.out.println("response: "+new String(resData,0,totalBytes));
                }catch(Exception e){}
            }};
          runner2.start ();
          runner1.start ();

if i set the sleep time of thread 2 to be 2000 or more, it will catch an exception
Im dont know much of usb programming, please help me correct the code.
Yours,
Alireza


Yahoo! Photos
Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.

Reply via email to