Jump to content

[KSP 1.10.0] Kerbal Simpit: A KSP serial mod for hardware controllers (1.4.1)


stibbons

Recommended Posts

Just now, stibbons said:

Correct. Port 0 is just the first port you've listed in your config file, and channel 4 is the altitude handler. I got a little bit lazy with my debug logging and didn't bother trying to resolve those to more sensible names.

Ahh, in this early stage it's kinda self explenatory. Just trying to understand what's happening.

Link to comment
Share on other sites

OK, I've made a little headway in to understanding what's happening here.

My plugin attempts to read from the serial port's underlying Stream object using the BeginRead and EndRead methods. This happens in a separate thread. But when the main thread writes the altitude packet out to the port, this triggers the EndRead. There's nothing to read and my slightly sloppy code reuses the last contents of the read buffer, which was the packet that subscribes to the altitude channel. Hence the weird logs.

This only happens on Windows, though. I only ever see expected behaviour on Linux and OS X.

I have a fairly hacky workaround in place that seems to be OK on my setup, except for the fact that it frequently causes my entire Windows 10 OS to bluescreen and reboot when KSP exits (I'm pretty proud of that, actually :D ). So looking for other options, and I strongly suspect I'll resort to a thread doing frequent serial polling.

Link to comment
Share on other sites

Version 0.7 is up now.

This release is still trying to get bidirectional serial handling right for all platforms. I've switched back to the original serial library, and written a new serial polling thread that is used on Windows instead of the old reading code.

This setup seems to be working for me everywhere I've tried it. And reading data this way also means that it works on a lot more hardware - Arduino boards that didn't work with the event-driven code in Windows previously are now doing the right thing with the polling code.

Unless there's any more problems with the serial handling, I'm looking forward to getting back and fleshing out the list of available telemetry providers in the next release.

Link to comment
Share on other sites

20 hours ago, stibbons said:

Version 0.7 is up now.

This release is still trying to get bidirectional serial handling right for all platforms. I've switched back to the original serial library, and written a new serial polling thread that is used on Windows instead of the old reading code.

This setup seems to be working for me everywhere I've tried it. And reading data this way also means that it works on a lot more hardware - Arduino boards that didn't work with the event-driven code in Windows previously are now doing the right thing with the polling code.

Unless there's any more problems with the serial handling, I'm looking forward to getting back and fleshing out the list of available telemetry providers in the next release.

I can confirm a working Staging button and surface-altimeter.

Under this link: https://bitbucket.org/pjhardy/kerbalsimpit/downloads/ Sometimes there is the arduino-library downloadable and sometimes, like now the source code is zipped "under" the download link. Can you provide two seperate links?

Link to comment
Share on other sites

Yay, finally a little headway on that one. :)

On 02/05/2017 at 6:24 PM, Benji said:

Under this link: https://bitbucket.org/pjhardy/kerbalsimpit/downloads/ Sometimes there is the arduino-library downloadable and sometimes, like now the source code is zipped "under" the download link. Can you provide two seperate links?

Sorry. I split the Arduino code out of that repository a little while ago, and it shouldn't be available from that link at all. And I haven't been uploading zip files of releases at all, so unless you know git it's probably been a right pain to figure out, sorry. :(

My long term plan for the arduino library is to have it added to the Arduino Library Manager, so you can just install it through the IDE. But until then, the library can be downloaded from https://bitbucket.org/pjhardy/kerbalsimpit-arduino/downloads/ . I've just uploaded a new zip file for the current master.

This evening I've also started adding more telemetry to the plugin. It's now sending apoapsis and periapsis, and I've started work on integrating Alternate Resource Panel to send fuel and power levels. I'd like to add a couple more types after that to make sure that the current method of multiplexing telemetry is scalable, and then I'll think seriously about promoting a 1.0 release.

Edited by stibbons
Link to comment
Share on other sites

23 hours ago, stibbons said:

This evening I've also started adding more telemetry to the plugin. It's now sending apoapsis and periapsis, and I've started work on integrating Alternate Resource Panel to send fuel and power levels. I'd like to add a couple more types after that to make sure that the current method of multiplexing telemetry is scalable, and then I'll think seriously about promoting a 1.0 release.

The only "special"(meaning, perhaps you don't plan to add?) information I want to use on my panel is vertical, horizontal velocity (perhaps as part of a velocity package) and battery charge-rate (negative to positive).

If they are not already on, would you add these to your list?

Link to comment
Share on other sites

Hi guys... I have recently bought KSP through steam on OSX and have been looking into making a control panel so I after a few late nights of pulling my hair trying to get KSPserialIO to work I am so glad I have found you are working on a Mac implementation.  I tried the handshake example last night and it all seems to work ok but I am relatively new to arduino so I am slowly getting the hang of it.  I am more than willing to be you Mac guinea pig as I will be trying everything you are putting up.  Couldn't get the staging example working last night but it was late so gave up it but will probably give it another shot over the weekend.

 

Keep up the good work!

Link to comment
Share on other sites

13 hours ago, Gizzum said:

after a few late nights of pulling my hair trying to get KSPserialIO to work

Erk, sorry, that's probably my fault. :( I've been maintaining a cross-platform KSPSerialIO fork for a while that runs well on my Linux gaming machine and I occasionally test on MacOS. But between this project and a lot of other things, just haven't had the time to update that for the latest version. Should hopefully get it done soon.

But welcome! I'm glad you like how it's going so far. :D Let me know how you go with the stage code. I've checked it on my Mac Air, but more eyes are good for figuring out how I can make it easier to use.

On 05/05/2017 at 2:33 AM, Benji said:

The only "special"(meaning, perhaps you don't plan to add?) information I want to use on my panel is vertical, horizontal velocity (perhaps as part of a velocity package) and battery charge-rate (negative to positive).

Surface and orbital velocity, as well as vertical velocity, are definitely on the list, almost certainly in the next release. I'm including current and max power levels as well, but didn't have any plans to include charge rate. If that's something readily available through the KSP or ARP APIs then I'd gladly include it. A little less certain about having to write the code to calculate it myself, but I'll see what I can do.

Link to comment
Share on other sites

On 03/05/2017 at 1:56 PM, stibbons said:

Yay, finally a little headway on that one. :)

Sorry. I split the Arduino code out of that repository a little while ago, and it shouldn't be available from that link at all. And I haven't been uploading zip files of releases at all, so unless you know git it's probably been a right pain to figure out, sorry. :(

My long term plan for the arduino library is to have it added to the Arduino Library Manager, so you can just install it through the IDE. But until then, the library can be downloaded from https://bitbucket.org/pjhardy/kerbalsimpit-arduino/downloads/ . I've just uploaded a new zip file for the current master.

This evening I've also started adding more telemetry to the plugin. It's now sending apoapsis and periapsis, and I've started work on integrating Alternate Resource Panel to send fuel and power levels. I'd like to add a couple more types after that to make sure that the current method of multiplexing telemetry is scalable, and then I'll think seriously about promoting a 1.0 release.

I've noticed this week that you've pushed commits at about the same time I was finally giving this a spin :D

Got my 'duino some time ago, but halted the project because I didn't have a good enough communication with the game (I was using Telemachus back then, and got bored writing the python middle-man script), and because not all my parts had shipped (and I'm still waiting for something to help me with the multitude of IO pins needed).

Recently I was keeping an eye on this, and on this week on vacation I dusted off the electronics and gave this a spin.

Eagerly awaiting for a proper release with complete telemetry! I've managed my hello worlds and first prototypes, now I'm just waiting for this to update and for the multiplexer to arrive to start something more serious :)

Link to comment
Share on other sites

4 hours ago, monstah said:

Eagerly awaiting for a proper release with complete telemetry! I've managed my hello worlds and first prototypes, now I'm just waiting for this to update and for the multiplexer to arrive to start something more serious :)

Wow, it sure is nice to hear other folk are interested in something I started just to scratch a personal itch. :)

I started thinking about how to send resource counts last night, and it's a little intimidating because the stock game has quite a few resources now (eight by my count, if you include ablator). For staged resources I'm planning on sending total and stage levels in the one packet. And other stuff like monoprop will go in a smaller packet. Something like

public struct StagedResourceStruct
{
    public float totalMax;
    public float totalAvailable;
    public float stageMax;
    public float stageAvailable;
}

public struct ResourceStruct
{
    public float totalMax;
    totalAvailable;
}

I think I'm going to end up staggering updates for these. Right now the plugin loops through the list of providers that want to send every 40ms. Instead of sending all of the resources each loop I'll probably spread them out. That would mean you only find out how much liquid fuel is in the tank every third of a second, but it seems like a worthwhile tradeoff. Something I'll experiment with I guess.

 

Link to comment
Share on other sites

On 6.5.2017 at 1:19 AM, stibbons said:
On 4.5.2017 at 6:33 PM, Benji said:

The only "special"(meaning, perhaps you don't plan to add?) information I want to use on my panel is vertical, horizontal velocity (perhaps as part of a velocity package) and battery charge-rate (negative to positive).

Surface and orbital velocity, as well as vertical velocity, are definitely on the list, almost certainly in the next release. I'm including current and max power levels as well, but didn't have any plans to include charge rate. If that's something readily available through the KSP or ARP APIs then I'd gladly include it. A little less certain about having to write the code to calculate it myself, but I'll see what I can do.

Yeah...

 

Later on... what about sending control commands to the GUI. Changing between Mapview and Vesselview. Or switching the Navball between Surface and Orbital.

Link to comment
Share on other sites

Hello again guys... For some unknown reason I cannot get the staging to work with the example I downloaded from bitbucket.  I can get the handshake example to work, but the only time it will stage is when i reset the arduino.  In the ksp.log i then get an entry stating handshake received.  The tx led does flash when i press the button but no staging.  Any ideas??

[LOG 17:24:25.339] Load(Assembly): KerbalSimPit/KerbalSimPit
[LOG 17:24:25.340] AssemblyLoader: Loading assembly at /Users/Jez/Library/Application Support/Steam/SteamApps/common/Kerbal Space Program/GameData/KerbalSimPit/KerbalSimPit.dll
[LOG 17:24:25.360] AssemblyLoader: KSPAssembly 'KerbalSimPit' V0.7
[LOG 17:24:25.360] Load(Assembly): KerbalSimPit/Mono.Posix
[LOG 17:24:25.360] AssemblyLoader: Loading assembly at /Users/Jez/Library/Application Support/Steam/SteamApps/common/Kerbal Space Program/GameData/KerbalSimPit/Mono.Posix.dll
[LOG 17:24:25.361] Load(Assembly): KerbalSimPit/PsimaxSerial
[LOG 17:24:25.361] AssemblyLoader: Loading assembly at /Users/Jez/Library/Application Support/Steam/SteamApps/common/Kerbal Space Program/GameData/KerbalSimPit/PsimaxSerial.dll
KerbalSimPit v0.7.0.0
KerbalSimPit
[LOG 17:24:25.445] [AddonLoader]: Instantiating addon 'KerbalSimPit' from assembly 'KerbalSimPit'
[LOG 17:24:25.703] KerbalSimPit: Settings loaded.
[LOG 17:24:25.729] KerbalSimPit: Starting async read thread for port /dev/tty.usbmodem1411
[LOG 17:24:25.729] KerbalSimPit: Started.
[LOG 17:24:25.729] KerbalSimPit: Starting event dispatch loop
[LOG 17:24:27.290] KerbalSimPit: ACK received on port /dev/tty.usbmodem1411. Handshake complete.
[LOG 17:25:32.055] [AddonLoader]: Instantiating addon 'KerbalSimPitCAGProvider' from assembly 'KerbalSimPit'
[LOG 17:25:32.055] [AddonLoader]: Instantiating addon 'KerbalSimPitActionProvider' from assembly 'KerbalSimPit'
[LOG 17:25:32.055] [AddonLoader]: Instantiating addon 'KerbalSimPitEchoProvider' from assembly 'KerbalSimPit'
[LOG 17:25:32.056] [AddonLoader]: Instantiating addon 'KerbalSimPitTelemetryProvider' from assembly 'KerbalSimPit'
[LOG 17:27:14.032] KerbalSimPit: Couldn't remove AltitudeProvider



[LOG 17:27:29.584] KerbalSimPit: Shutting down.

The above is the log when I use the handshake example...

[LOG 17:28:38.757] Load(Assembly): KerbalSimPit/KerbalSimPit
[LOG 17:28:38.757] AssemblyLoader: Loading assembly at /Users/Jez/Library/Application Support/Steam/SteamApps/common/Kerbal Space Program/GameData/KerbalSimPit/KerbalSimPit.dll
[LOG 17:28:38.777] AssemblyLoader: KSPAssembly 'KerbalSimPit' V0.7
[LOG 17:28:38.777] Load(Assembly): KerbalSimPit/Mono.Posix
[LOG 17:28:38.777] AssemblyLoader: Loading assembly at /Users/Jez/Library/Application Support/Steam/SteamApps/common/Kerbal Space Program/GameData/KerbalSimPit/Mono.Posix.dll
[LOG 17:28:38.778] Load(Assembly): KerbalSimPit/PsimaxSerial
[LOG 17:28:38.778] AssemblyLoader: Loading assembly at /Users/Jez/Library/Application Support/Steam/SteamApps/common/Kerbal Space Program/GameData/KerbalSimPit/PsimaxSerial.dll
KerbalSimPit v0.7.0.0
KerbalSimPit
[LOG 17:28:38.863] [AddonLoader]: Instantiating addon 'KerbalSimPit' from assembly 'KerbalSimPit'
[LOG 17:28:39.128] KerbalSimPit: Settings loaded.
[LOG 17:28:39.154] KerbalSimPit: Starting async read thread for port /dev/tty.usbmodem1411
[LOG 17:28:39.154] KerbalSimPit: Started.
[LOG 17:28:39.154] KerbalSimPit: Starting event dispatch loop
[LOG 17:28:40.714] KerbalSimPit: ACK received on port /dev/tty.usbmodem1411. Handshake complete.
[LOG 17:30:27.373] KerbalSimPit: ACK received on port /dev/tty.usbmodem1411. Handshake complete.
[LOG 17:30:40.960] [AddonLoader]: Instantiating addon 'KerbalSimPitCAGProvider' from assembly 'KerbalSimPit'
[LOG 17:30:40.960] [AddonLoader]: Instantiating addon 'KerbalSimPitActionProvider' from assembly 'KerbalSimPit'
[LOG 17:30:40.960] [AddonLoader]: Instantiating addon 'KerbalSimPitEchoProvider' from assembly 'KerbalSimPit'
[LOG 17:30:40.961] [AddonLoader]: Instantiating addon 'KerbalSimPitTelemetryProvider' from assembly 'KerbalSimPit'
[LOG 17:31:15.658] KerbalSimPit: ACK received on port /dev/tty.usbmodem1411. Handshake complete. //entry when I hit reset on arduino
[LOG 17:31:21.147] KerbalSimPit: ACK received on port /dev/tty.usbmodem1411. Handshake complete. //hit reset a second time
[LOG 17:31:28.467] KerbalSimPit: Couldn't remove AltitudeProvider
[LOG 17:31:48.276] KerbalSimPit: Shutting down.

Above is when I use the staging example.

 

Any ideas?

Link to comment
Share on other sites

6 hours ago, Gizzum said:

[LOG 17:31:28.467] KerbalSimPit: Couldn't remove AltitudeProvider

That's a little bit concerning. I'll check again when I'm back home (it's the start of the work day here), but I was sure I had sorted out why that was happening before.

Apart from that, though, there's nothing I can see that would be causing your issue in those logs. There might be some more detail if you set "verbose" in the config file to true though. Also, which version of KSP are you using (I only test against the 1.2.9 prerelease, although most things should be OK in 1.2.2).

And finally, what does your circuit look like? I just realised the comments in the Arduino sketch say to use a button connected to pin 1. This is wrong, and the button should be connected to pin 2. The pin 13 LED should light up as well whenever the button is pressed.

Link to comment
Share on other sites

23 hours ago, stibbons said:

I just realised the comments in the Arduino sketch say to use a button connected to pin 1. This is wrong, and the button should be connected to pin 2. The pin 13 LED should light up as well whenever the button is pressed.

I realised that the stage example sketch should mirror as closely as possible the debounce example. Because I want to illustrate that a staging button is a really trivial (and let's be honest, super fun) application. The next arduino library release will change that and polish the example sketches a fair bit.

Link to comment
Share on other sites

See... that shows how much of an Arduino noob I am... i thought the pins were labelled differently to what is declared in the code.  At least someone has thought about this!  Tried it again last night and it works so now ready to start playing! YAYYY.  Time to start buying switches, joysticks, buckets of LEDS and displays!  Really looking forward to this.  It would be interesting to see if the ESP chips could be integrated into this to remove the need for a usb cable.  I know it can be used as a wifi to serial bridge so it shouldn't take much to implement it.  How hard is it to assign buttons to IO pins on the arduino or is this what you are doing through this mod? i.e mapping the rcs keys to buttons or a joystick?  I had a quick look last night at modding but most of the tutorials or knowledge bases I managed to find discussed graphic modding and adding extra engine parts rather than extracting and controlling game values.  I would love to be able to contribute to this but feel that I am still a bit too far behind the curve than you guys. I have coding experience but nothing like this... mostly a few bits and pieces in basic, powershell, vbs, javascript, but this has been mainly for business domain environments rather than gaming.  I will have a try and keep an eye on this regularly as I am really enjoying farting about with breadboards and code again.  Plus KSP is an immense game that I am clocking up some serious hours on! :D

 

Cheers for your help gents (assuming stereotypically that you are both the male of the species!!)

 

Jez

Link to comment
Share on other sites

Glad it's working for you.

1 hour ago, Gizzum said:

It would be interesting to see if the ESP chips could be integrated into this to remove the need for a usb cable.  I know it can be used as a wifi to serial bridge so it shouldn't take much to implement it.

Eh, that's not really in the scope of what I'm doing, I'm deliberately only using serial interfaces. If you're interested in using a network connection, I believe the preferred method is interfacing with kRPC, although I'm not sure if anybody's using an esp8266 to talk directly with it yet.

1 hour ago, Gizzum said:

How hard is it to assign buttons to IO pins on the arduino or is this what you are doing through this mod? i.e mapping the rcs keys to buttons or a joystick?

Yes, this mod implements a serial protocol for sending commands to the game, and the Arduino library you started playing with provides a bunch of functions to simplify working with the protocol. Right now the system only properly supports sending action group commands (the stage demo is an example of this), but will eventually handle throttle, attitude and translation control, and probably more. An Arduino sketch for doing that would basically scale out the current stage demo - check the state of a bunch of input pins, and if the state changes then call the appropriate library function.

Link to comment
Share on other sites

The arduino function to send basic commands (abort, stage, RCS, etc) to KSP sends a byte, and I noticed on the defs they're powers of 2. If I OR them together, can I send a bunch of activations in a single message? Say, to enforce the panel is synchronized.

Link to comment
Share on other sites

14 minutes ago, monstah said:

If I OR them together, can I send a bunch of activations in a single message? Say, to enforce the panel is synchronized.

I set it up as a bitfield specifically so you could do that, yes. :)

That said, all of the standard action groups should behave as expected with multiple activation packets, except for the staging group. Currently I've tweaked that so that each activation packet will activate the next stage. That was a conscious choice - the staging demo looks much neater without having to send an explicit deactivation in between each button press.

Essentially, I'm preferring one-shot packet sending. I'll try to support sending multiple commands where feasible, but for instances like this where there has to be a choice, I'll go for one packet == one command.

Certainly happy to entertain changing that, and I guess I could hide the "activate/deactivate" dance behind a helper stage function in the library. But that's how it is right now.

In other progress news, this evening I've gotten the resource sending happening. You can implement a basic alarm light for the stage LF with something like this

void messageHandler(byte messageType, byte msg[], byte msgSize) {
  switch(messageType) {
  case LF_STAGE_MESSAGE:
    if (msgSize == sizeof(resourceMessage)) {
      resourceMessage myLF;
      myLF = parseResource(msg);
      if (myLF.total > 0 && myLF.available < 10) {
        digitalWrite(LED_BUILTIN, HIGH);
      } else {
        digitalWrite(LED_BUILTIN, LOW);
      }
    }
    break;
  }
}

I want to add a little more of the basic orbital parameters (velocity, vertical velocity, inclination, stuff like that), and finally make sure there's some real API docs for the Arduino library online. Then I'll package up a new prerelease.

Link to comment
Share on other sites

Thanks Stibbons.

 

If I where to try and understand what you are doing so that I may contribute to this where would you suggest is a good place to start researching?  I love to find out how things work so would love to follow this and actually understand what you guys are talking about, where the info comes from and how it integrates with the arduino.  Please fell free to tell me to do one if I am standing on your toes!

Link to comment
Share on other sites

Erm, well I keep track of everything that I want to do with this project on a Trello board, but honestly it's at the point where most of those tasks are boring housekeeping around making sure it's in a clean and tidy state for a real release.

I suppose the most interesting work right now is implementing more inbound and outbound data providers - the classes that pull info from KSP and send it to serial connections, and receive data from serial connections and feed commands in to KSP. Documenting those properly is... well... in a Trello card. :)

The serial protocol doc is slightly out of date, but should give a good grounding in to how data gets between the plugin and connected devices. After that, download the plugin source and start with the classes in the KerbalSimPit/Providers directory. All providers inherit from MonoBehaviour, and the majority of them will start in the flight scene.

The plugin uses many, many custom Game Events to pass data between providers and serial connections. For data going from serial to providers, there are "onSerialReceived" game events from "onSerialReceived0" up to a theoretical max of "onSerialReceived255". For data going from providers to serial devices, there's "toSerial0" up to "toSerial255". The ints in these game event names corresponds to the channel ID in the serial protocol.

If a provider wants to receive data from a serial device, in its Start method it should add a callback handler to the onSerialReceived Game Event with the appropriate channel ID. Have a look at Actions.cs file for an example of doing this for the standard action groups. Note that the serial receiving, and the callback, are executed in a different thread, so you usually want the callback handler to set a flag and then action that flag in the provider class Update method.

If a provider wants to send data to a serial device, it can find the appropriate "toSerial" Game Event with the appropriate channel ID, and just call that Game Event's Fire method, passing in the channel ID and any object representing the data to send. If the provider wants to, it can register a callback with the KSPit.AddToDeviceHandler() function. This callback will be called on a regular basis by the plugin (currently hardcoded to every 40ms, but will soon be user-configurable), giving the provider a way to send regular packets to interested devices. See the Telemetry.cs file for an example of doing this with altitude and apoapsis/periapsis.

SNEAKY EDIT: Oh, I forgot to mention the Arduino library. It's there to automate the handshaking, provide low-level send and receive functionality, and a bunch of structs and helper functions to make higher level channel handling easier. If you want to learn your way around that, pull down the repo, familiarise yourself with the class layout in KerbalSimPit.h , and read through the other header files to hopefully get a good idea of where I want to take it.

Hope that gives you enough to go on. Let me know if you have any more questions.

Edited by stibbons
Link to comment
Share on other sites

OK... been reading and my head hurts... a lot!

If I want to implement a switch for the standard action groups for example RCS, I would need check for the current status of the RCS_bit and then activate or deactivate the action accordingly dependent on the position of the switch.  How do I request from KSP the state of the RCS_Bit? Is there an RCS_MESSAGE? 

Link to comment
Share on other sites

1 hour ago, Gizzum said:

If I want to implement a switch for the standard action groups for example RCS, I would need check for the current status of the RCS_bit and then activate or deactivate the action accordingly dependent on the position of the switch.

You don't actually need to check the current state of RCS in the game (which is good because I haven't yet added a message for action groups coming out of the game :wink: ). You would just need to check the state of the switch, and send an activate or deactivate packet. I'm at work so can't test this, but you should be able to take the staging demo and just modify the loop() like this:

void loop() {
  // Read the state of the switch into a local variable.
  int reading = digitalRead(buttonPin);

  // check to see if you just pressed the button
  // (i.e. the input went from LOW to HIGH),  and you've waited
  // long enough since the last press to ignore any noise:

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

      if (buttonState == HIGH) {
        // If the switch has just gone HIGH, activate RCS
        mySimPit.activateAction(RCS_ACTION);
      } else {
        // If the switch has just gone LOW, deactivate RCS
        mySimPit.deactivateAction(RCS_ACTION);
      } 
    }
  }

 

Link to comment
Share on other sites

Thanks stibbons,

i had managed to get the switch to work as you discribed but was thinking if there was a point in the game where you go to a ship that has rcs on and your switch is in the off position it would instantly turn it off. Or worse something like landing gear.  If the switch was in the gear up position and you swap to a lander you wouldn't want you ship retracting its gear and falling over. Could that happen or am I talking rubbish. 

Link to comment
Share on other sites

That's not an impossible scenario, true. Although I think this plugin is safely at the point where I could just ask "What happened when you tried it?" :D

It's important to note that the code I've pasted above only sends a command when the switch state changes. Even though I will be adding channels so a controller can be notified of a scene change, and the current action group state when the flight scene starts, neither of those are required to avoid catastrophe. 

To take your landing gear example, it's very easy to get to a point where your gear switch is "up" when you switch to a vessel with gear down. Just flip the switch up at KSC and then switch to a vessel with its gear down. But when that happens, your controller won't send a gear up command to the vessel because the switch is already up. And when you flip the switch down your controller will send an activate gear command but nothing happens as the gear are already active. It's a cosmetic controller  issue that I don't particularly like much, but won't cause any problems in-game. 

 

Link to comment
Share on other sites

defo gonna try it now! :D.  The only problem is that my CDO (I am so OCD I have to put it in alphabetical order!!) is gonna be screaming at me to check the state of switches now when I change crafts!  It would be "a nice to have" that the status led flashes if it is the wrong position?? So how do you go about getting the action group status out of the game.  Is it the same procedure as the telemetry?  I don't have much time this weekend as I am a photographer at a wedding all day tomorrow but I would love to figure that part out as well.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...