Skip to content

Commit 8cbd20c

Browse files
author
Patrick Bechon
committed
Add some explanation on the serial buffer overflow in the documentation
1 parent f1c98bb commit 8cbd20c

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

extras/docs/troubleshooting.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ Here is an example.
8181
System.Threading.ThreadHelper.ThreadStart () (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
8282
UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)
8383

84+
When I add more functionalities to my controller, it starts to behave strangely (messages lost, corrupted, etc.)
85+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86+
87+
It is probable that the Arduino serial buffer size is too small given the time between each call to ``simpit.update`` and the number of messages sent. You can test this by displaying ``mySimpit.packetDroppedNbr``. If it is non-zero, it means that some messages were corruped.
88+
89+
To fix it, you have several solutions :
90+
* Increase the serial buffer size in ``HardwareSerial.h``. To find the right file to modify, see here : https://forum.arduino.cc/t/solved-serial-buffer-size/581828/10. There should be a log line in KSP.log indicating the buffer size when an Arduino connect. The default is 64 bytes and the recommandation is at least 256.
91+
* Reduce the number of channels you subscribe to
92+
* Call ``simpit.update`` more frequently. For instance if you have a controller with several parts, you can call ``simpit.update`` between each part update instead of updating all the parts and only then call ``simpit.update``.
93+
94+
To test that this is not the root cause of your issue, you can use the KerbalSimpitStressTest example. Subscribe to all the channels you want to use, and test several values of delay to see if some messages are lost. Then try on you controller to measure what is the delay between two calls to ``simpit.update`` and compare the two values.
8495

8596

8697

0 commit comments

Comments
 (0)