c# - Serial Communication Running Slow in Unity -


i have connected imu (gyroscope&acc&magnetometer) unity3d project , using serial communication via usb.

the problem is, when script becomes little heavy gaming codes, serial communication slows down - when values imu supposed change @ point of time, change after couple of seconds , time goes, data stream cannot catch game.

i calling myport.readline() update function read serial data com port.

what solution? - if understand problem right, want serial data reading not waiting app's next frame receive new values.

may reducing baud rate of imu device work?

there several things can optimizing project:

1) can change communication parameters. if sending pitch, yaw or roll, don't send them string, instead use ieee 754 format, send them bytes. also, if getting quaternion values, not loose time convert them euler angles.

2) try change update rate in unity settings careful smaller update rate = slower unity frame rate.

3) try use high baud rate, such 115200 or higher. if reduce baud rate, data imu can corrupted.

4) in imu code, can toggle serial port communication (you may not want send data continuously, may send data shirkingly). mean, can downsample data.

5) don't know data size can use coroutines & yield or invoke. know, unity not allow use data received event can create own event understand if of data has been received. (also try discardinbuffer if have problem streaming)

6) can write own dll (c# dll not make bigger changes way use c++). if using windows, can start searching kernel32.dll , ws2_32.dll.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -