I'm new to Unity3D, in fact just today. I'm doing a project that requires input from a device that sends data to a computer via a serial port. Is there a way to program Unity in C/C++ to be able to open a serial port and receive data streamed from it?
Shouldn't need a plugin, at least not with Unity 3.0:
"Then along comes .Net 2.0, and this time Microsoft added the System.IO.Ports Namespace, and within that was the SerialPort Class. DotNet developers finally had an intrinsic way of serial port communication,"
Also, be sure to set API compatibility level to .NET 2.0. The default is something like .NET 2.0 reduced.
I've just did a blogpost on communicating with an Arduino device using System.IO.Ports.SerialPort class. Basically you create an instance of the SerialPort class in Start() specifying the COM port and baud rate, and then in Update your extract data.
If you're interested you can find the post here
I have a PIC based controller that uses a USB virtual serial port. I've been using it with XNA and all my interface software is in C#. I'll let you know how it goes with getting it to talk with Unity. Any advice out there?
I am trying the same thing whenever I use readline . the framerate goes down to 1fps and if I try coroutine then then the data is not correct it is merged one inside the another.
Can somebody help on this
I found a alternative temporal solution for this, please read the following thread:
Some time ago I made this unitypackage for communicating with COM ports from Unity. I still use it from time to time, it does all the threading, polling, etc.
Hope it is useful.
You'd need to write a plugin for that (requires Unity Pro).