vranki / ExtPlane

Plugin for X-Plane flight simulator which allows reading and writing simulation properties
138 stars 44 forks source link

Setting byte[] datarefs crash XPlane #38

Open kamgolabek opened 6 years ago

kamgolabek commented 6 years ago

Like in title, while I am trying to set any data ref with byte[] type , XPlane is crashing. For example: set sim/aircraft/view/acf_tailnum sometexthere cause XPlane crash.

vranki commented 6 years ago

Sounds like a bug indeed. Can you or someone get a stack trace on what happens?

kamgolabek commented 6 years ago

I did more investigation:

  1. Not causing crash, but value is not changed after this commands (tested on many datarefs) _telnet localhost 51000 sub sim/aircraft/view/acftailnum:string <- value returned here in readable form _set sim/aircraft/view/acftailnum soemstringhere <- nothing happened
  2. Causing crash immediately _telent localhost 51000 sub sim/aircraft/view/acftailnum <- base64 value returned _set sim/aircraft/view/acftailnum soemvalueHereORbase64encoded <- immediate crash XPlane

And in logs there is nothing about it..

kamgolabek commented 6 years ago

Ok I have found in code of ExtPlane plugin: (dataref.cpp) void DataDataRef::setValue(QByteArray &newValue) { Q_UNUSED(newValue); //TODO: @dankrusi: finish this implementation and test qFatal("Writing of Data DataRefs is not yet supported"); /* // Limit number of values to write to ref length or number of given values int numberOfValuesToWrite = qMin(_length, values.size());

// Convert values to float and copy to _valueArray
for(int i=0;i<numberOfValuesToWrite;i++) {
    bool ok = true;
    float value = values[i].toFloat(&ok);
    if(!ok) {
        qDebug() << Q_FUNC_INFO << "Invalid value " << values[i] << "in array";
        return;
    }
    _valueArray[i]=value;
}
XPLMSetDatavf(_ref, _valueArray, 0, numberOfValuesToWrite);
*/

}

vranki commented 6 years ago

Setting value seems unimplemented feature, but should never cause a crash. There should be "Writing of Data DataRefs is not yet supported" in log or console output.

kamgolabek commented 6 years ago

okay.. but you can simply reproduce it by using telnet commands I pasted above.. and it crash..

waynepiekarski commented 5 years ago

There probably won't be any logging, since stdout and stderr do not go anywhere on Windows within X-Plane. See issue #23

Clamb94 commented 5 years ago

Is there any progress on this? I'm looking for a way to write data datarefs to X-Plane. Do you guys have any other idea how to modify data datarefs via the network?

kamgolabek commented 5 years ago

you can encode characters and save as int array..

Clamb94 commented 5 years ago

you can encode characters and save as int array..

Thanks, I'll give a try

Clamb94 commented 5 years ago

you can encode characters and save as int array..

Have you been able to do this? I tried: set xxx [1,1] But this causes a crash as well

vranki commented 5 years ago

Pushed a potential implementation of setting byte array (data) datarefs to a feature branch. See README for instructions. This has not been tested properly (coding in train on laptop without X-Plane) but at least it compiles :) . Feel free to test. If it still crashes, a stack trace would be appreciated.