mik3y / usb-serial-for-android

Android USB host serial driver library for CDC, FTDI, Arduino and other devices.
MIT License
4.95k stars 1.6k forks source link

How to connect to a serial port with this library #210

Closed BrotherV closed 5 years ago

BrotherV commented 6 years ago

Hi, I appreciate your work. Unfortunately I couldn't find a right way to connect to serial port, There are two different ways that you mentioned. first of them relate to jar library and second one relate to the last commit. In the first sample Jar file doesn't support any of control values such as stop bit and so on. Can you guide me to fix it? Even I can't connect to an Arduino.

Sample code: UsbSerialProber prober = UsbSerialProber.getDefaultProber(); UsbSerialDriver driver = prober.probeDevice(device); if(driver != null){ List ports = driver.getPorts(); }

I have a device with vendor id 0x2341 but driver always return null.

Thanks in advance.

kunofhan commented 6 years ago

meet with the same problem

BrotherV commented 6 years ago

I finally finished the project and I did it with two library(mik3y and felhr85 usb serial for android). If you would like, I can share what I did.

BrotherV commented 6 years ago

Send an email an I'll reply it for you. find my email in my profile.

kunofhan commented 6 years ago

haven't see your email in your profile

Send an email an I'll reply it for you. find my email in my profile.

haven't see your email in your profile.

BrotherV commented 6 years ago

haven't see your email in your profile

Send an email an I'll reply it for you. find my email in my profile.

haven't see your email in your profile.

I've sent you my codes. if you had any problem, you know how to find me.

HopeForWholeVillage commented 6 years ago

so i have a same problem,i can get the device ,but when i use the "connection = manger.openDevice(device);" this connection is always null error: java.lang.SecurityException: User has not given permission to device UsbDevice

i'd want a broadcastReceiver to deal with the action of the USB, if use the activity like example it's well,

ps: meta-data in the AndroidManifest.xml must in Activity statement

hacky97 commented 6 years ago

looks like you have to ask permission to the user to use the USB device. This can be done in the manifest. Here is a deeper explanation: http://blog.blecentral.com/2015/10/01/handling-usb-connections-in-android/

acaliaro commented 5 years ago

@BrotherV could you share your work with me? Thanks

eclectice commented 5 years ago

You can refer https://github.com/mik3y/usb-serial-for-android/issues/220 for usage idea and a useful example app from kai-morich fork.

acaliaro commented 5 years ago

Thanks @eclectice I have found another solution

BrotherV commented 5 years ago

@acaliaro Sure, give me your email and I can send it all for you.

acaliaro commented 5 years ago

Thanks @BrotherV , I have found another good solution to this project. I will contact you if I will need your help in the future. Thanks again

BrotherV commented 5 years ago

@acaliaro Your welcome. feel free and contact me with this email: mohsen_hatami@ymail.com Good luck

kai-morich commented 5 years ago

please look into examples at end of https://github.com/mik3y/usb-serial-for-android#quick-start for permission handling

lythamhoa commented 3 years ago

I finally finished the project and I did it with two library(mik3y and felhr85 usb serial for android). If you would like, I can share what I did.

I need them for my project, Can you send me your code use mik3y or felhr85. Thanks. My email. thang.phamduc@gmail.com. Sorry I can't find your email address.