Einzelnen Beitrag anzeigen

wschrabi

Registriert seit: 16. Jan 2005
448 Beiträge
 
#28

AW: Komponente Android Daten USB senden/empfangen

  Alt 23. Mär 2016, 13:50
On initial connect, a serial is generated by the main system, and stored in firmware of the mcu.

If you do not connect multiple identical USB HID devices onto a single system, then you do not need the whole serial selection protocol.

Just use:
Code:
HidCtl.OnArrival:= DeviceArrival;
HidCtl.OnRemoval:= DeviceRemoval;
Also adjust
Code:
TReport = packed record
  ReportID: byte;
  Data:   array [0..15] of byte; // adjust 15 to fit your datapacket lenghth (often 64 bits so 63 is a good guess!!)
end;
thanks Don, I only have one USB Device, but no EP-OUT defined in the Firmware, so writing a serial to the device is not possible.
I have only one IN EP, like a mouse.

BTW: For what is that:
{.$define WITHPERMISSION}

I see that you use this here:
Code:
...
    {$ifdef WITHPERMISSION}
    FPermissionIntent : JPendingIntent;
    {$endif}
...
        {$ifdef WITHPERMISSION}
        FMyController.UsbManager.requestPermission(FUsbDevice,FMyController.PermissionIntent);
        {$endif}
Do I need that on my Tablet?

One more I think to change:
I have a NON INterupted HID Device and in your code there is:
Code:
 // Get HID endpoint 1
      if FUsbInterface.getEndpointCount>1 then
      begin
        FUsbEP := FUsbInterface.getEndpoint(1);
        if FUsbEP.getType=TJUsbConstantsUSB_ENDPOINT_XFER_INT then
        begin
          if FUsbEP.getDirection = TJUsbConstantsUSB_DIR_OUT then
          begin
            FEpOut := FUsbEP;
          end
          else if FUsbEP.getDirection = TJUsbConstantsUSB_DIR_IN then
          begin
            FEpIn := FUsbEP;
          end;
        end;
      end;
I think the TJUsbConstantsUSB_ENDPOINT_XFER_INT must also change. RIght?

Thank you very much!

Geändert von wschrabi (23. Mär 2016 um 14:28 Uhr)
  Mit Zitat antworten Zitat