Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9132201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:16:16+00:00 2026-06-17T08:16:16+00:00

I have a USB device that I’m attempting to communicate to with my Android

  • 0

I have a USB device that I’m attempting to communicate to with my Android 4.1 device using the MonoDroid API, and I’ve run into some issues setting up a proper connection. First, the steps taken to arrive at what I “think” may be an issue:

  1. Filter my device by vendor and product ID with an intent filter in
    my AndroidManifest file. This works well, as when I plug in my
    device my app requests to launch by default, so permissions should
    correct.
  2. Grab my USB device from an Activity that my intent filter sends the program after discovering said device: UsbDevice device = (UsbDevice)this.Intent.GetParcelableExtra(UsbManager.ExtraDevice);
  3. After checking that there is only one interface present, I grab the associated interface by issuing: UsbInterface intf = device.GetInterface(0);
  4. Check the number of endpoints and grab them. There’s 2, as this is an input and output device: UsbEndpoint endpoint_IN = intf.GetEndpoint(0);
    UsbEndpoint endpoint_OUT = intf.GetEndpoint(1);
  5. Grab a connection to the device using the UsbManager: UsbDeviceConnection connection = device_manager.OpenDevice(device);

However, and I noticed that the endpoint at index 0 of the interface (endpoint_IN above) has UsbAddressing enumeration type “DirMask”, where endpoint_OUT has type “Out”; I’d expect endpoint_IN to be “In”, which is not the case. What is “DirMask?” The inline documentation states “Documentation for this section has not yet been entered”, and the online docs reflect the same: http://api.xamarin.com/?link=T%3aAndroid.Hardware.Usb.UsbAddressing

Could this be my issue? I’m just not really sure. I tried to implement the rest of the communication procedure, but haven’t been able to yield any results. For example, the following code should input a command to receive one reading:

Byte[] sys_command = Encoding.ASCII.GetBytes("!001:SYS?\r");
Java.Nio.ByteBuffer sys_command_buffer = Java.Nio.ByteBuffer.Wrap(sys_command);

Java.Nio.ByteBuffer output_buffer = Java.Nio.ByteBuffer.Allocate(4);

UsbRequest request_out = new UsbRequest();
request_out.Initialize(connection, endpoint_OUT);

connection.ClaimInterface(intf, forceClaim);

request_out.Queue(output_buffer, 4);
connection.BulkTransfer(endpoint_IN, sys_command, sys_command.Length, TIMEOUT);

if (connection.RequestWait() == request_out)
    readings.Text = output_buffer.GetFloat(0).ToString();

Any insight?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:16:17+00:00Added an answer on June 17, 2026 at 8:16 am

    I had the interface endpoints backwards, all things considered. That is, I was attempting to read/write to the wrong interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .sh script that automounts any usb device that is plugged in.
Is it possible to use a USB device peripheral that I have created directly
I have a USB device I'm trying to communicate with over a virtual serial
I do have a USB device which is using the WinUSB driver (winusb.sys) as
I have an SDK for a USB device. It includes some installer for .NET
I have code to set up notification for USB device add/remove using XCode 4.3.3
I have a usb device that is supposed to send a number when queried.
I'm using python to interface a hardware usb sniffer device with the python API
I have developed a USB device that communicates with linux over a simple but
I have device that is a USB HID Human Interface that sends keycodes to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.