Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Zeterro · Aug 19, 2014 at 02:43 PM · androiddatacommunicationarduinousb

Access to serial port on Android device

Hello there !

My problem is the following : I've got an android application who is installed on a Xperia Tablet linked to an Arduino with USB. I need to open a serial port to send data to Arduino board but nothing happen. So my questions are :

  • Does Serial Ports are enabled on Android ?

  • Does anyone knows how to enable it in case of they're not enabled ?

I used System.IO.ports, it's worked perfectly on PC but not on Android device. So I've got an error in console when i run my application :

 Dll not found Exception : MonoPosixHelper

Does anyone knows what is it talking about ?

Thanks for reading !

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image rayellam · Jan 06, 2015 at 06:20 AM 0
Share

did you get this working as im doing something similar?

avatar image DjEmix · Jun 28, 2015 at 11:08 PM 0
Share

Hello @Zeterro! I have the same problem. I get Dll not found Exception : $$anonymous$$onoPosixHelper. Can you solve this?

avatar image absorkam · Mar 01, 2016 at 08:20 AM 0
Share

I was trying to open the serial port comm on an Android writing my script in Unity, setup of the com port seems to be fine, but when I call mySerial.open() I get the monoposixhelper exception. Has anybody figured out a solution to this? Thanks. @Zeterro @landern

5 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Landern · Aug 19, 2014 at 02:45 PM

Hmm, it shows it's supported in the Normal Net 2.0, if your android is set to Subset 2.0 then it will fail.

Check out the namespace compatibility here (search for "Namespace System.IO.Ports" without the quotes on the page.)

Also check your Player Settings for android <- you will need to scroll down for android.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Zeterro · Aug 19, 2014 at 02:58 PM 0
Share

Hmm, thanks but Api compatibility Level is set to Normal Net 2.0 in my Player Settings and the namespace is compatible... :/

avatar image Landern · Aug 19, 2014 at 03:00 PM 0
Share

Not to beat a dead "animal name here", but you checked with the player settings set to PC and then you checked Android correct, knowing that they can be different?

avatar image Zeterro · Aug 19, 2014 at 03:07 PM 0
Share

Yeah, that's the same in Android tab and PC tab : .NET 2.0.

avatar image
0

Answer by Zeterro · Aug 19, 2014 at 05:22 PM

Here is a Exemple of my code. Nothing strange i think, but not working on tablet.

 using UnityEngine;
 using System.Collections;
 using System;
 using System.Threading;
 using System.IO;
 using System.IO.Ports;
 
 public class TeensyNetWork : MonoBehaviour
 {
 
     static private SerialPort serialPort = new SerialPort("COM6", 9600);
 
     void Start()
     {
         Debug.Log("Connecting ...");
         showPort();
         OpenConnection();
     }
 
     void showPort()
     {
         // Get a list of serial port names. 
         string[] ports = SerialPort.GetPortNames();
 
         Debug.Log("The following serial ports were found:");
 
         // Display each port name to the console. 
         foreach (string port in ports)
         {
             Debug.Log(port);
         }
     }
 
     void OpenConnection()
     {
         if (serialPort != null)
         {
             if (!serialPort.IsOpen)
             {
                 serialPort.Open(); // ouverture de la connection
                 serialPort.ReadTimeout = 1;
                 Debug.Log("Port ouvert");
             }
         }
 
         else
         {
             Debug.Log("Port == null");
         }
     }
 
     public static void SendIntMessage(int pin, int value)
     {
         string pinMessage = Convert.ToString(pin);
         string valueMessage = Convert.ToString(value);
 
         char[] message = new char[6]; ;
 
         if (value >= 100) // si la valeur est superieure a 100
         {
             if (pin < 10)
             {
                 message[0] = '0';
                 message[1] = pinMessage[0];
                 message[2] = valueMessage[0];
                 message[3] = valueMessage[1];
                 message[4] = valueMessage[2];
                 message[5] = '\n';
             }
             else
             {
                 message[0] = pinMessage[0];
                 message[1] = pinMessage[1];
                 message[2] = valueMessage[0];
                 message[3] = valueMessage[1];
                 message[4] = valueMessage[2];
                 message[5] = '\n';
             }
         }
         else if (value < 100 && value >= 10) // si la valeur est entre 99 & 10
         {
             if (pin < 10)
             {
                 message[0] = '0';
                 message[1] = pinMessage[0];
                 message[2] = '0';
                 message[3] = valueMessage[0];
                 message[4] = valueMessage[1];
                 message[5] = '\n';
 
 
             }
             else
             {
                 message[0] = pinMessage[0];
                 message[1] = pinMessage[1];
                 message[2] = '0';
                 message[3] = valueMessage[0];
                 message[4] = valueMessage[1];
                 message[5] = '\n';
             }
         }
 
         else if (value < 10) // si la valeur est inferieure a 10
         {
             if (pin < 10)
             {
                 message[0] = '0';
                 message[1] = pinMessage[0];
                 message[2] = '0';
                 message[3] = '0';
                 message[4] = valueMessage[0];
                 message[5] = '\n';
             }
             else
             {
                 message[0] = pinMessage[0];
                 message[1] = pinMessage[1];
                 message[2] = '0';
                 message[3] = '0';
                 message[4] = valueMessage[0];
                 message[5] = '\n';
             }
         }
         
         serialPort.Write(message, 0, 6);
         //Debug.Log("send");
     }    
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by $$anonymous$$ · Jul 28, 2016 at 01:19 PM

@Zeterro have you sloved this problem? Can you tell me how?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by absorkam · Jul 29, 2016 at 01:10 PM

@Zeterro I solved the problem by going to Android Studio and not using Unity......but I'd still like to use Unity if possible.....but I didn't have the time to figure it out, and Android Studio for me was easy.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fallouturama · Aug 10, 2016 at 03:21 PM 0
Share

Have you made a library/plugin for Unity?

avatar image
0

Answer by NGC6543 · May 18, 2017 at 11:29 AM

Are you looking for something like this? https://forum.unity3d.com/threads/serial-ports-in-android.363621/#post-3074558

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I want to receive gyroscope data from imu(arduino nano 33 iot) in andriod(made an apk from unity) using usb cable. 0 Answers

Arduino through an OTG + Android 2 Answers

Android USB Custom HID 0 Answers

Unity 2018 Android deployment problem,Android problem with Unity 2018.1 0 Answers

Load from Xml on Iphone and Android 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges