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

  • SEARCH
  • Home
  • 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 8127103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:24:19+00:00 2026-06-06T07:24:19+00:00

I have to read and write data to the COM ports of a device

  • 0

I have to read and write data to the COM ports of a device using Android. I am using javax.comm package for that, but when I installed the apk file, it is not displaying any ports of the device. Is there any permission which I need to add in the manifest file?

  • 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-06T07:24:22+00:00Added an answer on June 6, 2026 at 7:24 am

    Your problem is one with operating systems. Android runs Linux under the hood, and Linux treats serial ports differently than Windows does. javax.comm also contains win32com.dll, a driver file, which you won’t be able to install on an Android device. If you do find a way to achieve what you’re trying to do, you can’t actually look for a “COM” port in a Linux environment. The serial ports will go by different names.

     Windows Com Port   Linux equivalent  
          COM 1           /dev/ttyS0  
          COM 2           /dev/ttyS1
          COM 3           /dev/ttyS2 
    

    So, hypothetically, if your idea were to work, you have to look for these names.

    Luckily for you, Android does have provisions for interfacing with USB devices (Which I assume you want to connect to, as opposed to parallel or RS-232 ports). To do this, you will set up your device as a USB Host. Here’s what you’ll want to do:

    1. Get a USBManager.
    2. Find your device.
    3. Get the USBInterface and USBEndpoint.
    4. Open a connection.
    5. Transfer data.

    Here’s my rough estimate of how you’ll do it. Your code will, of course, have a more mature way of doing things.

    String YOUR_DEVICE_NAME;
    byte[] DATA;
    int TIMEOUT;
    
    USBManager manager = getApplicationContext().getSystemService(Context.USB_SERVICE);
    Map<String, USBDevice> devices = manager.getDeviceList();
    USBDevice mDevice = devices.get(YOUR_DEVICE_NAME);
    USBDeviceConnection connection = manager.openDevice(mDevice);
    USBEndpoint endpoint = device.getInterface(0).getEndpoint(0);
    
    connection.claimInterface(device.getInterface(0), true);
    connection.bulkTransfer(endpoint, DATA, DATA.length, TIMEOUT);
    

    Extra material for your reading pleasure: http://developer.android.com/guide/topics/connectivity/usb/host.html

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

Sidebar

Related Questions

I have to read/write an XML file that stores its data as bit masked
In the emulator I'm trying to write to the file: /mnt/sdcard/Android/data/com.Me.MyApp/files/myFile.txt I have set
I need to read and write some data through named pipes. I have tested
I have a specific object with image data. And I want read/write images (in
i have a c++ server which is using boost::asio to do read/write operations -
I have rooted phone. I want to copy data/data/com.android.providers.telephony/databases/mmssms.db file to sd card programatically.
I have two grails servers: Server - has read/write access to the database Web
So I have the following read and write file program for an Array. How
I have a problem. I need to trace all read/write operations to the registry
I have a asp.net webservice running in windows server 2003, i want it read/write

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.