USB communication via HID device

Simone Benincasa 0 Punti di reputazione
2024-08-30T10:52:25.19+00:00

Hi, I am trying to create a cross-platform app with .net maui. The purpose of the app is to be able to communicate with a USB device (HID) by sending and receiving raw data. After much research I managed to find the library ‘hidlibrary’ which works perfectly on Windows form, however on .net maui at the first instruction to receive data it gives me the exception ‘Operation not supported on this platform’. How can I solve this? Am I taking the wrong approach? Thanks in advance

Windows
Windows
Famiglia di sistemi operativi Microsoft eseguiti su computer personali, tablet, portatili, telefoni, internet delle cose, visori VR di realtà mista autonoma, schermi di collaborazione di grandi dimensioni e altri dispositivi.
33 domande
ASP.NET
ASP.NET
Set di tecnologie in .NET Framework per la creazione di applicazioni Web e servizi Web XML.
5 domande
0 commenti Nessun commento
{count} voti

2 risposte

Ordina per: Più utili
  1. Yordan Ivanov (Convergys Corporation) 730 Punti di reputazione Fornitore Microsoft
    2024-08-30T15:18:24.63+00:00

    Good day,

    This is the italian forum. For italian support, please let us know. For english, please use the following link:
    https://video2.skills-academy.com/en-us/answers/questions/


  2. Yordan Ivanov (Convergys Corporation) 730 Punti di reputazione Fornitore Microsoft
    2024-09-02T14:23:22.4833333+00:00

    Buongiorno, Simone,

    il seguente potrebbe aiutare:

    Activity act = Platform.CurrentActivity;
    UsbManager manager = (UsbManager)act.GetSystemService(Context.UsbService);
    IDictionary<string, UsbDevice> devicesDictionary = manager.DeviceList;
    UsbDevice dvc = devicesDictionary.ElementAt(0).Value;
    string ACTION_USB_PERMISSION = "rzepak";
    var interf = dvc.GetInterface(1);
    outEndpoint = interf.GetEndpoint(1);
    PendingIntent mPermissionIntent = PendingIntent.GetBroadcast(act, 0, new Intent(ACTION_USB_PERMISSION), 0);
    IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
    if (manager.HasPermission(dvc) == false)
       manager.RequestPermission(dvc, mPermissionIntent);
    deviceConnection = manager.OpenDevice(dvc);
    if (deviceConnection != null)
        deviceConnection.ClaimInterface(interf, true).ToString();
        else return false;
    

    deviceConnection e' un tipo Android.Hardware.Usb.UsbDeviceConnection aperto in modalita' di conessione:

    byte[] test = new byte[] { input };
    if (deviceConnection.BulkTransfer(outEndpoint, test, test.Length, 500) < 0)
        Connected = false;
    

     

     

    c'e' sempre la pagina iniziale, con tutta l'informazione disponibile da Microsoft:

    https://dotnet.microsoft.com/en-us/apps/maui


Risposta

Le risposte possono essere contrassegnate come risposte accettate dall'autore della domanda. Ciò consente agli utenti di sapere che la risposta ha risolto il problema dell'autore.