如何在android中增加USB的缓冲区大小

时间:2014-12-20 08:13:08

标签: android usb

我正在编写一个应用程序,即使用usb cable通过虚拟通信端口在android设备和微控制器之间进行通信。但是在这里我想要接收3000字节的数据,但在usb中,它限制为usb的64字节缓冲区。我的问题是如何将usb端口的大小从64字节增加到3000字节。 RASAP请

Thread Receive  = new Thread(new Runnable()
    {

    @SuppressWarnings("unused")
    @Override
    public void run() 
    {

        ByteBuffer buffer = ByteBuffer.allocate(3050);
        byte[] sample = new byte[3050];
        int Frame_Size;
        UsbRequest request = new UsbRequest();
        @SuppressWarnings("unused")
        int i,j;
        byte [] datarx=new byte[1]; 
        char q;
        while (true) 
        {
        request.initialize(UsbDriver.USB_Device_Connection, UsbDriver.Data_In_End_Point);
       // request.queue(buffer, 3050);      ----------->> Here the buffer size was notexceeded from 64 how to increase to 3050
      //  if (UsbDriver.USB_Device_Connection.requestWait() == request) 
            if(UsbDriver.USB_Device_Connection.bulkTransfer(UsbDriver.Data_In_End_Point,sample, 3050, 500)>=0)
            {
    //  sample=buffer.array(); 
                for(i=0;i<3050;i++)
                {
                        if(sample[i]=='&')
                        {
                            Communication_Ok=true;
                            break;
                        }
                        else if(sample[i]==0x03)
                        {
                            if(sample[0]==0x02)
                            Frame_Ok=true;  
                            break;
                        }
                }
                if(Frame_Ok==true)
                {
                    Frame_Ok=false;

                    Frame_Size=(int)(((sample[2]&0x00FF)<<8) + (sample[3]&0x00FF));
          //        Frame_Size=Frame_Size/2;
                    for(i=4,j=0;i<Frame_Size;i=i+2,j++)
                    {
                    //  Wave_Form_Data[j]=(int)(sample[i] + sample[i+1]);   
                    //  Wave_Form_Data_1[j] = (float)((((int)(((sample[i]&0x00FF)<<8) + (sample[i+1]&0x00FF)))*(float)3.3)/4096);
                        Wave_Form_Data_1[j]= (int)(((sample[i]&0x00FF)<<8) + (sample[i+1]&0x00FF));
                    }
            //      Respsonse_Time=(float)((int)(((sample[Frame_Size]&0x00FF)<<8) + (sample[Frame_Size+1]&0x00FF)));
            //      Drive_Voltage=(float)((int)(((sample[Frame_Size+2]&0x00FF)<<8) + (sample[Frame_Size+3]&0x00FF)));
                    for(j=0;j<Frame_Size/2;j++)
                        Wave_Form_Data[j] =(float) ((Wave_Form_Data_1[j]*3.3)/4095);    
            //      Respsonse_Time=Drive_Voltage=(++Temp);
                    if((sample[1]-0x30)==1)
                    Coil_No=1;
                    else
                    Coil_No=2;  
                    Total_Frame_Decoded=true;

                }
                sample = null;
            }   
        }
     }
    });

0 个答案:

没有答案