Simpit-team / KerbalSimpitRevamped-Arduino

BSD 2-Clause "Simplified" License
18 stars 19 forks source link

[Feature]: Add disconnect/reconnect function in Arduino library to be able to manually control connection via board #14

Open CodapopKSP opened 3 years ago

CodapopKSP commented 3 years ago

This could function as a 'soft' reset to handle times when the connection has problems. Most boards have the arduino located inside and potentially inaccessible, so pressing the reset button may not be an option.

A simple callable set of functions would be ideal, maybe "mysimpit.connect, mysimpit.disconnect".

PBechon commented 3 years ago

What should this do ? This will not reset the whole arduino as the reset button does. If you need an actual Arduino reset, you can use a dedicated button on your controller.

If you want you can unsubscribe all the channel and stop sending messages to KSP. It will remove all the traffic on the serial connection. What should the call to mysimpit.disconnect() do differently ?

On the other end, a call to mysimpit.init() is the function that open the connection. What would be the difference with mysimpit.connect() ?

CodapopKSP commented 3 years ago

Does unsubscribing from every channel also end the serial connection? In the case of my board, the arduino sometimes has to do other things that aren't part of simpit, and sometimes it needs the serial connection to do that. It would be nice to be able to script the start/stop in the arduino code so it can handle the switch between modes automatically.

PBechon commented 3 years ago

You can call Serial.end if you need to close the connection.

CodapopKSP commented 3 years ago

That doesn't appear to allow the arduino to reconnect again, and a reset is neccesary either way.

LRTNZ commented 2 years ago

Do you still need this?

LRTNZ commented 2 years ago

In fact... give me an hour....