Willi M
Willi M

Reputation: 1

How to setup USB Serial Device over dart/flutter?

I have an RFID Reader from a company called Metratec. I actually enjoy this reader very much and there is a detailed PDF and prewritten packages for Java, Python and .NET. Now I want to write my own package for it for dart/flutter. But I just can't get behind some parameters I have to setup and the documentation for it is no help. Can maybe somebody help me or link me some information?

This is the package I want to use: https://pub.dev/packages/usb_device

I actually managed to pair the device, but I'm not able to send commands/receive commands.

For this function:

controlTransferOut(dynamic device, SetupParam setup, {dynamic data})

I have to give it a SetupParam object. The class looks like this:

class SetupParam {
  final String requestType;
  final String recipient;
  final int request;
  final int value;
  final int index;
}

I actually have no idea what to do with this params.

On this: https://www.metratec.com/de/produkte/rfid/rfid-reader/deskid-uhf-v2/ are the prewritten packages and also the UHF AT Protocol Guide, where the information should be located. Would be grateful if anybody could help!

Tried this setup from chatgpt: SetupParam setup = SetupParam( requestType: 'USB_REQUEST_TYPE_VENDOR', // Adjust for your device's protocol (likely vendor-specific) recipient: 'USB_RECIPIENT_DEVICE', // Sending to the device itself request: 0x0D, // Vendor-specific request code (check your device docs) value: 0, // Often set to 0 for simple commands index: 0, // Typically set to 0 for commands );

Upvotes: 0

Views: 31

Answers (1)

Saddam Sheikh
Saddam Sheikh

Reputation: 11

requestType: 'USB_REQUEST_TYPE_VENDOR',  
recipient: 'USB_RECIPIENT_DEVICE',  
SetupParam setup = SetupParam(
  requestType: 'USB_REQUEST_TYPE_VENDOR', // Check guide for correct type
  recipient: 'USB_RECIPIENT_DEVICE', // Likely correct, but confirm
  request: 0x05, // Example: Update with the correct request from guide
  value: 0x0001, // Check if this needs a specific value
  index: 0x0000, // Check if this needs to target a specific endpoint
);

Upvotes: 0

Related Questions