Jump to content

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


stibbons

Recommended Posts

9 hours ago, Codapop said:

I believe Simpit expects 16-bit integers: -32768 to 32767.

So 0 on throttle is -32768, and 100% throttle is 32767. For rotation/translation it should still use the same intregers, but the program would interpret them differently (like -32768 is all the way left and 32767 is all the way right). When using Arduino, you map the input from the potentiometer to those integers. So the potentiometer reads a voltage, arduino reads that voltage as being somewhere between 0 and 1023, and then it gets mapped relative to -32768 and 32767 and then sent to Simpit.

Got throttling working. Judging from my tests I think zero throttle is 0 and full throttle is 32767. Maybe that's the reason why you ( @codapop ) need to read 1/3 minimum? Because if I remember correctly 1/3 on a logarithmic poti is half the resistance.

Attitude is still not working. I think I also don't now how to write a correct rotationMessage.

Edited by Benji
Link to comment
Share on other sites

On 1/24/2019 at 2:40 PM, Codapop said:

Also, I still can't seem to get rotation messages to work properly. I'm using this:


#include "KerbalSimpit.h"

KerbalSimpit mySimpit(Serial);

rotationMessage myRotation;

void setup() {
  Serial.begin(115200);

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  while (!mySimpit.init()) {delay(100);}
  digitalWrite(LED_BUILTIN, LOW);

  mySimpit.registerChannel(ROTATION_MESSAGE);
}

void loop() {
  int pitchRead = analogRead(A0);
  int pitchR = map(pitchRead, 0, 1023, -32768, 32767);
  myRotation.pitch = pitchR;
  mySimpit.send(ROTATION_MESSAGE, myRotation);
  delay(1);
}

I tried making some various changes to reflect the discussion above, but the information is sorta randomly talked about and difficult for me to understand with my limited coding knowledge. Can you please give a short example of how to write a proper rotation message?

Hey.

I looked at the struct for rotation message and found what we forgot. You need to set the bitmask in the rotationmessage:

myRotation.mask = 1; if you want to send pitch.

                                 = 2; if you want to send yaw.

                                 = 4; if you want to send roll.

Or in my case = 7; That's all bits combined.

Or you can use = 5; for pitch and roll.

 

Similar with myTranslation.mask

Link to comment
Share on other sites

Regarding SAS Modes. I do this:


  mySimpit.registerChannel(SAS_MODE_MESSAGE);

 

mySimpit.send(SAS_MODE_MESSAGE, AP_RADIALIN);

mySimpit.setSASMode(AP_RADIALIN);

...both ways don't work for me. Obviously I'm missing something there. Anyone have an idea?

 

Found this in Helpers.cpp:
void KerbalSimpit::setSASMode(byte mode)
{
  send(SAS_MODE_MESSAGE, &mode, 1);
}

Very odd, because me using it like this causes compiler errors.

Edited by Benji
being more polite
Link to comment
Share on other sites

22 hours ago, Benji said:

Got throttling working. Judging from my tests I think zero throttle is 0 and full throttle is 32767. Maybe that's the reason why you ( @codapop ) need to read 1/3 minimum? Because if I remember correctly 1/3 on a logarithmic poti is half the resistance.

Attitude is still not working. I think I also don't now how to write a correct rotationMessage.

Wow, that fixed it! Thank you very much.

 

Ok, so both throttle and rotation are working perfectly for me. Here's my code in case you or anyone needs it:

 

ROTATION

#include "KerbalSimpit.h"

KerbalSimpit mySimpit(Serial);

rotationMessage myRotation;

void setup() {
  Serial.begin(115200);

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  while (!mySimpit.init()) {delay(100);}
  digitalWrite(LED_BUILTIN, LOW);

  mySimpit.registerChannel(ROTATION_MESSAGE);
}

void loop() {
  int pitchRead = analogRead(A0);
  int pitchR = map(pitchRead, 0, 1023, -32768, 32767);
  // Set myRotation.mask to 7 for pitch+yaw+roll, 1 for only pitch.
  myRotation.mask = 1;
  myRotation.pitch = pitchR;
  mySimpit.send(ROTATION_MESSAGE, myRotation);
  delay(1);
}

THROTTLE

#include "KerbalSimpit.h"

KerbalSimpit mySimpit(Serial);

void setup() {
  Serial.begin(115200);

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  while (!mySimpit.init()) {delay(100);}
  digitalWrite(LED_BUILTIN, LOW);

  mySimpit.registerChannel(THROTTLE_MESSAGE);
}

void loop() {
  int pitchRead = analogRead(A0);
  int throttle = map(pitchRead, 0, 1023, 0, 32767);
  mySimpit.send(THROTTLE_MESSAGE, throttle);
  delay(1);
}

I went ahead and downloaded the latest version of the arduino library to try to help work through the SAS mode problem, and I had the same luck as you. mySimpit.send(SAS_MODE_MESSAGE, AP_PROGRADE); resulted in a compiling error. mySimpit.setSASMode(AP_PROGRADE); compiles fine but doesn't work in game, though the LED on my arduino shows it's sending properly.

My guess is there's an issue between the arduino library and the mod itself. You may be able to download the latest version of Simpit and see if it works (not off CKAN but whereever new releases are kept), or perhaps Stibbons still needs to upload it.

Link to comment
Share on other sites

20 hours ago, Codapop said:

I went ahead and downloaded the latest version of the arduino library to try to help work through the SAS mode problem, and I had the same luck as you. mySimpit.send(SAS_MODE_MESSAGE, AP_PROGRADE); resulted in a compiling error. mySimpit.setSASMode(AP_PROGRADE); compiles fine but doesn't work in game, though the LED on my arduino shows it's sending properly.

My guess is there's an issue between the arduino library and the mod itself. You may be able to download the latest version of Simpit and see if it works (not off CKAN but whereever new releases are kept), or perhaps Stibbons still needs to upload it.

mySimpit.send(SAS_MODE_MESSAGE, AP_PROGRADE) does compile for me. But in Helpers.cpp it's

  send(SAS_MODE_MESSAGE, &mode, 1);       -> no matching function for call to 'KerbalSimpit::send(InboundPackets, AutopilotMode&, int)'

So, the 1 is the message size [byte], like in

  mySimpit.send(THROTTLE_MESSAGE, (unsigned char*) &throttle, 2);             (Why is it detected as byte and not as int ?)

Then I defined it as byte and did some bit manipulation, but it still doesn't compile.   -> no matching function for call to 'KerbalSimpit::send(InboundPackets, AutopilotMode&, byte&)'

I think today is a day to not think about arrays and/or pointers. Sometimes this is very confusing.

And like always everything becomes clear after a minute not thinking about it. That's compileable:

mySimpit.send(SAS_MODE_MESSAGE,  (unsigned char*) &mySASMode, 1); 

Like with throttle of course.

But KSP doesn't set SAS commands.

 

 

Aaaaand Arduino library is at 1.1.5 using the IDE. But here (https://bitbucket.org/pjhardy/kerbalsimpit-arduino/commits/all) the latest version is 1.2.1

So I downloaded the library here (https://bitbucket.org/pjhardy/kerbalsimpit-arduino/downloads/)

But the arduino IDE still thinks Simpit is at 1.1.5 and there's no possibility to upgrade to 1.2.1

@stibbons, do you have a clue what's happening there?

Edited by Benji
Me not thinkng properly
Link to comment
Share on other sites

@stibbons@Codapop

Solved it.

SAS_MODE_MESSAGE has to be 28 .

I found the commit that causes this (https://bitbucket.org/pjhardy/kerbalsimpit/commits/232b15304532b5e9676671f657d34521c2d4876b)

I suppose that is for sane continuation of message-numbering but I suspect the KSP Simpit Plugin (1.3.0.64) still listens to "channel 28".

 

This works:

  mySimpit.send(28,  (unsigned char*) &mySASMode, 1);

 

Edit: But doesn't work correctly. Entered a pull request to fix it. On my machine it fixes it but the helper function is still not working.

Edited by Benji
Link to comment
Share on other sites

-

hello good day.

the errormeldung from : KerbalSimpitHelloWorld.

 

Greeting

----------------------------------------------------------------------------------------------------

Arduino: 1.6.8 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\pebi\Documents\Arduino\libraries\kerbalsimpit-arduino\examples\KerbalSimpitHelloWorld\KerbalSimpitHelloWorld.ino: In function 'void loop()':

KerbalSimpitHelloWorld:51: error: invalid conversion from 'const char*' to 'byte* {aka unsigned char*}' [-fpermissive]

       mySimpit.send(ECHO_REQ_MESSAGE, "low", 4);

                                               ^

In file included from C:\Users\pebi\Documents\Arduino\libraries\kerbalsimpit-arduino\examples\KerbalSimpitHelloWorld\KerbalSimpitHelloWorld.ino:11:0:

C:\Users\pebi\Documents\Arduino\libraries\kerbalsimpit-arduino\src/KerbalSimpit.h:72:8: error:   initializing argument 2 of 'void KerbalSimpit::send(byte, byte*, byte)' [-fpermissive]

   void send(byte messageType, byte msg[], byte msgSize);

        ^

KerbalSimpitHelloWorld:53: error: invalid conversion from 'const char*' to 'byte* {aka unsigned char*}' [-fpermissive]

       mySimpit.send(ECHO_REQ_MESSAGE, "high", 5);

                                                ^

In file included from C:\Users\pebi\Documents\Arduino\libraries\kerbalsimpit-arduino\examples\KerbalSimpitHelloWorld\KerbalSimpitHelloWorld.ino:11:0:

C:\Users\pebi\Documents\Arduino\libraries\kerbalsimpit-arduino\src/KerbalSimpit.h:72:8: error:   initializing argument 2 of 'void KerbalSimpit::send(byte, byte*, byte)' [-fpermissive]

   void send(byte messageType, byte msg[], byte msgSize);

        ^

C:\Users\pebi\Documents\Arduino\libraries\kerbalsimpit-arduino\examples\KerbalSimpitHelloWorld\KerbalSimpitHelloWorld.ino: In function 'void messageHandler(byte, byte*, byte)':

KerbalSimpitHelloWorld:70: error: invalid conversion from 'byte* {aka unsigned char*}' to 'const char*' [-fpermissive]

     if (strcmp(msg, "low")) {

                          ^

In file included from F:\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:25:0,

                 from sketch\KerbalSimpitHelloWorld.ino.cpp:1:

f:\arduino\hardware\tools\avr\avr\include\string.h:125:12: error:   initializing argument 1 of 'int strcmp(const char*, const char*)' [-fpermissive]

 extern int strcmp(const char *, const char *) __ATTR_PURE__;

            ^

exit status 1
invalid conversion from 'const char*' to 'byte* {aka unsigned char*}' [-fpermissive]

---------------------------------------------------------------------------------------------

Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre.
 

Hi good afternoon.
this command is different than in the description.
KerbalSimpitAltitudeTrigger.ino :

void messageHandler(byte messageType, byte msg[], byte msgSize) {
  switch(messageType) {
  case ALTITUDE_MESSAGE:
........

https://kerbalsimpit-arduino.readthedocs.io/en/stable/quickstart.html

void myCallbackHandler(byte messageType, byte mesesage[], byte messageSize) { switch(messageType) { case ALTITUDE_MESSAGE:

 

Greeting

 

Link to comment
Share on other sites

Hey Fellow Tinkers,

I've been lurking for awhile and jumped in to building my own controller a couple weeks back. Gotten staging and action groups going no problem. Tonight I set up two four axis joysticks, which worked with a bit of helped from past posts. However, i'm having trouble setting a deadzone (or some sort of restraint that limits the input until its reach a certain threshold, one way or another). Currently the crafts end up fairly unstable (basically spinning faster and faster until its out of control in orbit...) as I believe the Joysticks may be providing a slightly off centre inut when nothing is pressed. I'm super excited to keep going with this build so I'd really appreciate some insights as to how to get this sorted out. Thanks in advance and thanks so much for all the inspiration! I never would've thought i could've done this two months ago. 


#include "KerbalSimpit.h"

KerbalSimpit mySimpit(Serial);

rotationMessage myRotation;
translationMessage myTranslation;

void setup() {
  Serial.begin(115200);

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  while (!mySimpit.init()) {delay(100);}
  digitalWrite(LED_BUILTIN, LOW);

  mySimpit.registerChannel(ROTATION_MESSAGE);
  mySimpit.registerChannel(TRANSLATION_MESSAGE);
    // This loop continually attempts to handshake with the plugin.
  // It will keep retrying until it gets a successful handshake.
  while (!mySimpit.init()) {
    delay(100);
  }
  // Turn off the built-in LED to indicate handshaking is complete.
  digitalWrite(LED_BUILTIN, LOW);
}
    
void loop() {
//ROTATION//
  //Pitch - Back and Forward on Joystick//
  int pitchRead = analogRead(A0);
  int pitchR = map(pitchRead, 0, 1023, -32768, 32767);
  myRotation.mask = 1;
  myRotation.pitch = pitchR;
  mySimpit.send(ROTATION_MESSAGE, myRotation);
  delay(1);

  //Yaw - Side to Side on Joystick//
    int yawRead = analogRead(A1);
  int yawR = map(yawRead, 0, 1023, -32768, 32767);
  myRotation.mask = 4;
  myRotation.yaw = yawR;
  mySimpit.send(ROTATION_MESSAGE, myRotation);
  delay(1);
  
//Roll - Twist Joystick//
  int rollRead = analogRead(A2);
  int rollR = map(rollRead, 0, 1023, -32768, 32767);
  myRotation.mask = 2;
  myRotation.roll = rollR;
  mySimpit.send(ROTATION_MESSAGE, myRotation);
  delay(1);

//TRANSLATION//
  //X - XX//
  int XRead = analogRead(A3);
  int XR = map(XRead, 0, 1023, -32768, 32767);
  myTranslation.mask = 1;
  myTranslation.X = XR;
  mySimpit.send(TRANSLATION_MESSAGE, myTranslation);
  delay(1);

  //Y - YY//
    int YRead = analogRead(A4);
  int YR = map(YRead, 0, 1023, -32768, 32767);
  myTranslation.mask = 4;
  myTranslation.Y = yawR;
  mySimpit.send(TRANSLATION_MESSAGE, myTranslation);
  delay(1);
  
//Z - ZZ//
  int ZRead = analogRead(A5);
  int ZR = map(ZRead, 0, 1023, -32768, 32767);
  myTranslation.mask = 2;
  myTranslation.Z = ZR;
  mySimpit.send(TRANSLATION_MESSAGE, myTranslation);
  delay(1);
}

Link to comment
Share on other sites

@YuppeeMusings have you tried testing the joysticks on their own, without ksp? I would advise looking at directly printing the value of each of the axis, one at a time to the ide terminal and seeing how the values behave. That way, we can eliminate all the other potential variables that ksp introduces, and only work with the bare minimum of variables. 

Link to comment
Share on other sites

4 hours ago, YuppeeMusings said:

Hey Fellow Tinkers,

I've been lurking for awhile and jumped in to building my own controller a couple weeks back. Gotten staging and action groups going no problem. Tonight I set up two four axis joysticks, which worked with a bit of helped from past posts. However, i'm having trouble setting a deadzone (or some sort of restraint that limits the input until its reach a certain threshold, one way or another). Currently the crafts end up fairly unstable (basically spinning faster and faster until its out of control in orbit...) as I believe the Joysticks may be providing a slightly off centre inut when nothing is pressed. I'm super excited to keep going with this build so I'd really appreciate some insights as to how to get this sorted out. Thanks in advance and thanks so much for all the inspiration! I never would've thought i could've done this two months ago. 

...

    
void loop() {
//ROTATION//
  //Pitch - Back and Forward on Joystick//
  int pitchRead = analogRead(A0);
  int pitchR = map(pitchRead, 0, 1023, -32768, 32767);
  myRotation.mask = 1;
  myRotation.pitch = pitchR;
  mySimpit.send(ROTATION_MESSAGE, myRotation);
  delay(1);

...

My deadband-applying-code looks like this:

 

#define DEADBAND 1500

if(abs(pitchR) - DEADBAND < 0)
    pitchR = 0;

 

Don't be alarmed by the "large" number. 1500 is about 5%. You can put right after mapping.

Edited by Benji
Link to comment
Share on other sites

1 hour ago, funkheld said:

Hi good afternoon.
throttle = map(pitchRead, 0, 1023, 0, 32767);

what does this table mean?
I want to set the trottle with it.
it does not work.
the word of A0 is 23-1017.

 

greeting

KSP expects throttle values from 0 to 32767.

With map(value, fromLow, fromHigh, toLow, toHigh) you can span or reduce ranges.

 

If your readings at A0 give values between 23-1017 you can use the map like this:

throttle = map(throttleRead, 23, 1017, 0, 32767);

-> 23 gets mapped to 0

-> 1017 gets mapped to 32767

-> Values in between are mapped linearly.
 

 

I would advice using it like this:

This way you get a little deadband to be sure you can reach "zero throttle" and "full throttle"

throttle = map(throttleRead, 40, 1000, 0, 32767)

if (throttle > 32767) {
    throttle = 32767;
  }

More elegant:   throttle = constrain(throttle, 0, 32767);

Sending throttle over 100% to KSP sets it to zero. (It's not KSP's fault, just the way integers work.)

1 hour ago, funkheld said:

Hi good afternoon.
throttle = map(pitchRead, 0, 1023, 0, 32767);

what does this table mean?
I want to set the trottle with it.
it does not work.
the word of A0 is 23-1017.

 

greeting

Ohh. Is this intentional? Reading your "pitchPin" to control throttle?

Edited by Benji
A bit sloppy today...
Link to comment
Share on other sites

1 hour ago, funkheld said:

Hi good afternoon.
I wanted to stop the trottle with A0.
How is that possible?

greeting

I took the Staging demo and changed it a bit:

#include "KerbalSimpit.h"

// constants won't change. They're used here to
// set pin numbers:
const int potiThrottle = A0;// the number of the poti pin
const int ledPin = 13;      // the number of the LED pin

// Variables will change:
int ledState = HIGH;         // the current state of the output pin


// Declare a KerbalSimpit object that will
// communicate using the "Serial" device.
KerbalSimpit mySimpit(Serial);

void setup() {
  // Open the serial connection.
  Serial.begin(115200);

  // Set initial pin states, and turn on the LED
  pinMode(potiThrottle, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(ledPin, HIGH);

  // This loop continually attempts to handshake with the plugin.
  // It will keep retrying until it gets a successful handshake.
  while (!mySimpit.init()) {
    delay(100);
  }
  // Turn off the built-in LED to indicate handshaking is complete.
  digitalWrite(LED_BUILTIN, LOW);

  //register the throttle channel
  mySimpit.registerChannel(THROTTLE_MESSAGE);
}

void loop() {
  // Read the state of the poti into a local variable.
  int reading = analogRead(potiThrottle);

  //map it to a range KSP likes
  reading = map(reading, 23, 1017, 0, 32767);

  //sending it to the plugin
  mySimpit.send(THROTTLE_MESSAGE, (unsigned char*) &reading, 2);
}

 

Link to comment
Share on other sites

On 2/2/2019 at 3:21 AM, Benji said:

My deadband-applying-code looks like this:

 

#define DEADBAND 1500

if(abs(pitchR) - DEADBAND < 0)
    pitchR = 0;

 

Don't be alarmed by the "large" number. 1500 is about 5%. You can put right after mapping.

Thank you! Popping this in and playing around with the deadband figure worked beautifully.

Link to comment
Share on other sites

I tried to rebuild my working controller to this simpit plugin.  Link to my controller
All the controlls work well so far. I just dont get the displays to work well. Seems they just start to crash and get crazy and i don´t know why.

For someone who need a bit code example on how to use controlls, I uploaded the code here.
https://github.com/Richi0D/KerbalController-Simpit

Link to comment
Share on other sites

  • 3 weeks later...

I'm still in the process of working out who I want to implement my console and comparing the two options of SimPit and KSPSerialIO.

I've tested and 'get' the KSPSerialIO process and think I understand it's pros and cons. I can see how I can take a fork, rewrite the protocol for what I want on my console and what I'd need to grab the data. It is a firehose solution though, in that you're sending the data all the time in that main packet to the microcontroller. I very much like the idea proposed by @stibbonsand was keen to test it out.

I'm still in the process of reading through the details of this thread (page 5 at the moment) So far I'm liking what I'm reading. I'm going for an analog cockpit so having the ability to just the activate and deactivate actions is great.

I recently tried the Simpit helloworld script and installed on a Teensy3.6 and I can't get it past the " while (!mySimpit.init());" handshake step.I had to dump everything in the loop due to various errors regarding type conversion with byte & char, but that's all fixable later. I just wanted to test the connection.
I know the Wiki says it's not working for a Teensy 3.2 on MacOS, but is this likely a similar problem? For reference, I'm on Win10 Home, TeensyDuino 1.44, Arduino 1.87,  - Teensy 3.6 Hardware.

Separate related request. In setting up the Teensy, I had an issue where the COM port would disappear. Now this was the Teensyduino software 1.41 fault, not KSP,. So no need to troubleshoot. I updated to 1.44 and that problem went away, but it occurred to me to suggest adding error detection when Simpit looses the COM port. In the current version, when the COM port disappears, after about 10 seconds of log spam the Simpit mod dies hard and KSP crashes in sympathy. ie "KSP is not responding" windows dialog box.

Note: I'm happy to debug / test options if there is any interest in another tester :)

 

Edited by wile1411
Link to comment
Share on other sites

Wow - that was some testing. Had good long two attempts at over the last few days and was rewarded with this.

12QJMvql.png9sfGMlfl.jpg

I've managed to get blinking LED13 on both an Arduino Uno and Teensy 3.6 using the helloworld test script. Couple of caveats I had to do to work around some ..issues.

I still can't get either board to handshake with KSP. I commented out the below line just to see if it would still connect (it was a long shot, but reading the code it's seemed good odds to work for the test) This allowed the board to move to the loop and keep sending the high/low char string every 100ms.

while (!mySimpit.init())

 

Not sure what's up with my setup that forced this (it might be to do with the Teensyduino I have installed...) Anyway, I had to recast the low/high message as  (byte*) to get these lines not to error in the compiler. The compiler kept giving the error: 
no matching function for call to 'KerbalSimpit::send(CommonPackets, const char [4], int)'.
Checking KerbalSimpit.h I see the send function declared as: void send(byte messageType, byte msg[], byte msgSize);
Should the type conversion from char to byte happen automatically and it's just not for me? Below was my work around.

    if (state) {
      mySimpit.send(ECHO_REQ_MESSAGE, (byte*)"low", 4);
    } else {
      mySimpit.send(ECHO_REQ_MESSAGE, (byte*)"high", 5);
    }

 

The other data type issue that was stopping the helloworld script from compiling was an if statement in the messageHandler function. The msg[] variable is set to type "byte msg[]" This wasn't being allowed as the strcmp function expects two (char*) variables to be passed.

Within helloworld function messageHandler: 
  void messageHandler(byte messageType, byte msg[], byte msgSize) {
    if (messageType == ECHO_RESP_MESSAGE) {
	  if (strcmp(msg, "low")) {

Within string.h that came with the Teensyduino software:
  int _EXFUN(strncmp,(const char *, const char *, size_t));

Below is my workaround to get that past the compiler.
if (strcmp((char*)msg, "low")) {

 

Compiler threw a warning regarding KerbalSimpit.cpp: In member function 'bool KerbalSimpit::init()': Comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (i=0; i<sizeof(KERBALSIMPIT_VERSION); i++) {

 

This one is more for my understanding of the code - so excuse me if it's a stupid question: Under the KerbalSimpit.cpp and then function void KerbalSimpit::send(byte messageType, byte msg[], byte msgSize) 
There is this for loop.
  for (int x=0; x<msgSize; x++) {
    _serial->write(*(msg+x));
  }
If the 'bytesize' variable is passed as a byte, does the 'x' counter var need to be an int? Wouldn't that also be a byte so the loop evaluation of "x<msgSize" is the same type?

 

As mentioned in the above post, adding some code to handle the loss of a COM port (for whatever reason - but usually it seem to be the Microcontroller resetting itself) Maybe when seeing the loss of the object, stop using it in the queue to send messages and still it in a side queue to check for a pulse every 5secs or so. If starts responding again, it can go can be allow to send message in the normal queue. This would go a great way to keeping the game running regardless of what bit of code on the Arduino might cause a dropped connection. The mod already handles reconnect awesomely, but this is only when the COM port hasn't been dropped.

To replicate: have a device connected (even with just the hellowworld script) and then pull the USB out. I've seen similar log files already posted on the thread so far, but here' my screenshot if it helps.

zL2AzgYl.png

 

All up, glad I got it somewhat working. I need to dig into why it's not getting through the init function.

Has anyone done any functions or have a methodology to keep an eye on the board buffer being overwhelmed when the speed has been set too fast? I really want to know where my limits are for sending information, whether it be per device, or from KSP in general as I plan to push the code as far & as fast as I can.

Edited by wile1411
Link to comment
Share on other sites

  • 4 weeks later...
On 2/5/2019 at 1:55 PM, Wurmi said:

I tried to rebuild my working controller to this simpit plugin.  Link to my controller
All the controlls work well so far. I just dont get the displays to work well. Seems they just start to crash and get crazy and i don´t know why.

For someone who need a bit code example on how to use controlls, I uploaded the code here.
https://github.com/Richi0D/KerbalController-Simpit

@Wurmi

Love your controller! Saw it on Reddit a few weeks back before you transitioned over to SimPit. Question for you, how did you incorporate your arm switch as a function in Simpit? It's something I ordered the part to do before realizing there wasn't any obvious way to include the function. 

 

Congrats again on a wicked looking controller! 

Link to comment
Share on other sites

@YuppeeMusings

thanks, i did it inside the arduino code. It is just a simple check. If the arm Switch is on then it will send the stage signal if stage button is pressed, else it will do nothing and ignore the stage button.

But i moved forward again to another plugin. Right now i try to do it with KRPC and Python. It have much more functionality. I will try to make some touch buttons with the nextion displays, but first i need to get all the controls working.

Link to comment
Share on other sites

On 3/17/2019 at 3:24 AM, YuppeeMusings said:

@Wurmi

Love your controller! Saw it on Reddit a few weeks back before you transitioned over to SimPit. Question for you, how did you incorporate your arm switch as a function in Simpit? It's something I ordered the part to do before realizing there wasn't any obvious way to include the function. 

 

Congrats again on a wicked looking controller! 

Not sure why you would spend time coding the arm switch when you can just do it mechanically. Just have both the switch and the button complete the same circuit. Like VCC > switch > button > Arduino input pin, with a pull down resistor in there.

You can do the same with the precision controls switch by turning it into a voltage divider, as SimPit doesn't have that functionality either.

Edited by Codapop
Link to comment
Share on other sites

  • 2 months later...
8 hours ago, Calyhre said:

Did anyone managed to make it work with 1.7.x? I can't make any of the examples on my Leonardo connect with Kerbal

I don't know when the last time any dev work on this was done? I submitted a pull request a while back and am not sure if that has been pulled in yet. I may have a look at this in a week or two when I have some spare time, and see about getting the mod updated. 

Link to comment
Share on other sites

Hello fellow Kerbonauts,

I wanted to build a custom controller for ksp and found this mod, so i got started.

Thanks to this awesome mod the coding went smooth and really fast i was able to get some action custom action groups, staging, abort, sas etc. working. so i turned my attention tto controlling the S.A.S. autopilot (prograde, retrograde, target, ...).

 

So just like in the documentation (https://kerbalsimpit-arduino.readthedocs.io/en/stable/kerbalsimpit.html) in the case of a button press i wanted to execute this:

          mySimpit.setSASMode(AP_PROGRADE);

which gave me compiler errors like theses: 'class KerbalSimpit' has no member named 'setSASMode'

 

After searching for a solution i read through the comments here and found the posts

of benji:

On 1/26/2019 at 10:03 PM, Benji said:

Regarding SAS Modes. I do this:


  mySimpit.registerChannel(SAS_MODE_MESSAGE);

 

mySimpit.send(SAS_MODE_MESSAGE, AP_RADIALIN);

mySimpit.setSASMode(AP_RADIALIN);

...both ways don't work for me. Obviously I'm missing something there. Anyone have an idea?

On 1/28/2019 at 11:13 AM, Benji said:

Aaaaand Arduino library is at 1.1.5 using the IDE. But here (https://bitbucket.org/pjhardy/kerbalsimpit-arduino/commits/all) the latest version is 1.2.1

So I downloaded the library here (https://bitbucket.org/pjhardy/kerbalsimpit-arduino/downloads/)

But the arduino IDE still thinks Simpit is at 1.1.5 and there's no possibility to upgrade to 1.2.1

@stibbons, do you have a clue what's happening there?

So i checked the lib version and saw, that in the arduino IDE the version is still on 1.1.5 and on bitbucket 1.1.3 is available.

According to the commits on Bitbucket SAS modes were implemented after 1.1.5, which explaines the compiler error, and there is also versions of 2.0 and 2.1.

 

So are these versions availeble to download?

and if i change the code manually according to the commits, will this be still compatible to the mod downloaded via cKan?

 

 

 

Link to comment
Share on other sites

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