Hi, I'm glad to know the package is being useful for you! About the delay, I can think of two main factors that you might be experiencing: (1) SerialCommUnity reads from your device as often as the Update function of your MonoBehaviour is being called. That Update function runs once per frame, so if your program runs at 30 FPS, the library will try to read from your device every ~33ms (1 second/30 fps = 0.033s). I don't know how you are doing your delay measurement, but this is a big factor. (2) The default baudrate in my examples is the slowest 'standard' value: 9600. Set it to something like 115200 to increase the communication speed. You will also need to change the baud-rate in your piece of hardware to match this. Why did I default to 9600? Because though it is the slowest, it's the less error prone (there is less chance of bits being flipped because of network errors, and we are talking here at network protocols without error correction). So if you plan to increase your baudrate, increase it to the lowest value you can get off with! Assets for integrating Arduino and Unity (or Unity and any hardware that communicates over a COM port) - dwilches/Ardity. Serial-comm-unity-1.1.0 serial-comm-unity-1.0.0 ardity-1.1.0 ardity-1.0.0 Nothing to show. New pull request Find file Clone or download Clone with HTTPS. Unity communicate with serialport. Contribute to mogoson/MGS-SerialPort development by creating an account on GitHub. Download tuxedomoon rapidshare. Serialport serial port communicate. And use only the 'standard' values. Is a list of baudrates and further explanation, in case you are not familiar with the concept. I hope this is useful! (I copied your question as well because it is a very useful question, and I want other people to find it quickly). Thank you for the serial package. I'm currently trying to use it for my Final Year Project. However, after I imported the package, I noticed that the console returns quite weird error. Assets/SerialComm/Scripts/SerialThread.cs(245,46): error CS1061: Type System.IO.Ports.SerialPort' does not contain a definition for ReadLine' and no extension method ReadLine' of type System.IO.Ports.SerialPort' could be found (are you missing a using directive or an assembly reference?) The same error type also appears on the other ReadLine function (line 238) and WriteLine function (line 166). I try to check for this error on your code however I feel that its quite weird because WriteLine and ReadLine is included in the library and the implementation is correct based on MSDN (and no other complain). I already changed the project settings to NET 2.0 based on your Github. Did I miss something? In a previous post,, we have shown how data can be sent and received through the serial port. The main problem encountered was dealing with the latency and the delays that communicating across different devices introduces. The solution proposed in that tutorial used a coroutine; decoupling the device communication from the game logic attenuates the problem, but it doesn’t remove it. The main problem is that, despite the name, Unity coroutines are not really executed in parallel with the rest of the game. Unity, by design, is not thread safe. This means that true parallelism is intentionally avoided by the engine, as it could result in race conditions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |