xseignard / cordovarduino

Cordova/Phonegap plugin for USB host serial communication from an Android device.
MIT License
166 stars 110 forks source link

Adapters solution #14

Closed ndvalkov closed 10 years ago

ndvalkov commented 10 years ago

Hello,

I tried to use this adapter cable with my remote control app and couldn't make it work. Even with the suggested(required?) Hyperterminal application that you are supposed to download from the app store if following the istructions.

http://eu.startech.com/Cards-Adapters/Serial-Cards-Adapters/micro-usb-serial-adapter-android~ICUSBANDR232

Then I decided to use two cables instead: micro to female USB OTG, and a standard USB to RS232 adapter. The adapter uses PL2303 Prolific chipset, I installed some drivers for android:

http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=230&pcid=41

I managed to establish connection and send some data to the serial device through a HyperTerminal app specific to the drivers. However, it still is not working with my app. I don't think the problem is in my implementation of the plugin's API.

Can you pls help with the above, or suggest some other easier/better cable solution. I have tablet and serial device, need them connected through RS232.

Thank you.

ndvalkov commented 10 years ago

usb-serial-for-android seem to have support for PL2303 https://github.com/mik3y/usb-serial-for-android/commit/2bdcbfd16e644f6e26b9fd74d5bdb3766e324cad

xseignard commented 10 years ago

Hello,

Yes, I was checking if @mik3y lib had PL2303, and I used PL2303 chip + arduino mini successfully with cordovarduino.

Some debug logs would be helpful. If you're running linux on your computer, could you plug the usb converter and check for VID and PID? As mentioned here: #11

Then you could run adb via wifi and check for some logs, first connect your anrdoid device to your computer and then run the following:

adb tcpip 5555
adb connect 192.168.1.10

Where 192.168.1.10 is the IP address of your tablet.

Now you can unplug your tablet and adb will debug your app over wifi.

Now you can have a look in the logcat to search for some errors.Your can run the following to check for some console.log messages.

adb logcat | grep CordovaLog

Hope this helps, but I'm sure we'll find a solution.

Regards

ndvalkov commented 10 years ago

Sorry, it was something in my implementation again. Started a new project, from zero. And now it triggers the success handlers for .requestPermission() and .open(), but when it reaches writeHex() it exits the app. No error, nothing. I remove the 'Hex' part and it triggers success callback as expected. Weird. I will look at it tomorrow, I think I have an idea where the problem may be.

Thanks for the info that it should work out of the box with PL2303. It helped.

ndvalkov commented 10 years ago

Oh, got it.:):)

Great plugin!.

Closing.

xseignard commented 10 years ago

Great!

Thanks for the compliment!

Could you tell us more about how you solved your problem? We'll then improve the documentation.

And if your project is public (and maybe open source!) could you tell us more about it too? We lack of showcase projects because I never used this plugin :)

I started the developement of it to control a tesla coil from a tablet, but the usb cable acts as an antenna and the tesla coil lightnings disconnects the tablet. I had to switch to a bluetooth connection.

Regards,

@xseignard

ndvalkov commented 10 years ago

It's at the beginning of the project. It will not be public. The serial device is a robot, moves some objects around:), RS232 is the only option at the moment. We excluded bluetooth. A remote control app, not too complex...

As for the issue, at some point I literally copy/pasted the code from the working project over the code of the not working one, and it threw error on the connection(requestPermission) again. In the broken app the serial object was there, no console errors, the rest was ok. Started a new Ionic project, you need to add some plugin, the android platform, then this plugin...and it was fixed. Maybe I missed some steps, or did them in different order, if that could have lead to a flawed installation of the serial plugin...

I am kinda new to mobile dev, and programming, and I do stupid things occasionally. Like the last one: using a string, instead of hex-string. Breaks the app.

ndvalkov commented 10 years ago

Damn, still trouble. Sends the string converted to hex, triggers success handler...nothing. The commands are valid, work fine with the hyperTerminal.

ndvalkov commented 10 years ago

a command like, let's say, 'AAA' is supposed to be sent with writeHex('414141', ...), right? Checked with intervals, dashes...alerts 'success', ..the robot hates me.

Obviously things are not meant to happen in this work week.