Android to single board computer over serial error
I am trying to open a serial port on Android to communicate with a single board computer. I load the Unity application on Android. I do the set up and it seems to work fine.
stream = new SerialPort("COM4", 9600);
No error so far. But when I try to open the stream:
try{
if(!stream.IsOpen){
stream.Open();
}
}catch(Exception f) {
myText.text = f.Message;
}
I get MonoPosixHelper exception I have seen some posts on this, but I haven't seen anybody resolve it yet. Does anybody have any suggestions? Developed in Unity 5.3 and running on Android. I have tried it on several different boards, Arduino, Pi, etc. etc. all the same error. I do have .Net2.0 turned on, turned off .Net2.0 subset in player settings.
Thanks
I've added to Android$$anonymous$$anifest.xml:
<uses-feature android:name="android.hardware.usb.host" />
And even tryed to open any other /dev/ with the same code and I get same $$anonymous$$onoPosixHelper exception
Answer by absorkam · Mar 03, 2016 at 03:29 PM
I also have tried ttySo, ttyS1.......com1, com2........etc. etc. That could be part of my problem I'm not sure which com port to use. I printed the available serial available and got ttyS0 ....to.....ttyS3........but none worked.
Next, I'm going to try to program an Android Plugin and see if that works.....but would really like to know if anybody has got this working or knows my problem.
Thanks absorkam
$$anonymous$$aybe if I keep answering my own question somebody might see this that will have an answer. I got it running fine in Android Studio, still no luck with the $$anonymous$$onoPosix Error in Unity. looks like the $$anonymous$$ono libraries have been scaled down and whatever the SerialPort needs was stripped out? Still not completely sure.
I started making my Studio project a Unity plugin. $$anonymous$$aybe I could do that and then sell it on the store.............
That sounds posible to me, so on Android Studio is working?
Any news on Unity?
Have you confirmed if the library has been scaled out?
Have developed a library/plugin?
I'm about to commit suicide here...
Scaled out theory for non Windows boxes: http://forum.unity3d.com/threads/monoposixhelper-not-found.99951/#post-685579
Answer by pengyuenhao · Apr 14, 2016 at 02:09 PM
I am same as you... do you know what happened? if you get answer,please tell me,thank you very much pengyuenhao@qq.com
be friends ,will?
Same error here. opening /dev/ttyA$$anonymous$$A0 in my device, and any other similar device found on /dev/ causes the same $$anonymous$$onoPosixHelper.
Permissions problem? Native library opening this devices not implemented? Already opened ports?
Any workaround?
Answer by Fallouturama · Aug 10, 2016 at 03:47 PM
This may be a valid workaround:
Export Unity Project as Google Android Project.
build libmono.so with the same version of Android Studio that make serial io work
Replace libmono.so in the Google Android Project
Anyone can confirm if this is posible? @absorkam? @pengyuenhao?
Answer by andor734 · Jan 18, 2017 at 12:36 PM
It might be raising a DLL not found exception. Basically the version of .NET 2.0 running on Android doesn't include the SerialPort class... Though why that's the case, I don't know.
Currently trying to figure out what the problem is.
Your answer
Follow this Question
Related Questions
How to move character forward and also face moving direction ? 1 Answer
Unity Daydream Preview - Raycast/camera alignment 1 Answer
jni error has occurred local reference table overflow (max=512) Android crashes on start. 1 Answer
voice recognition 2 Answers
Android game updater (autopatch) 0 Answers