Board index FlightGear Support Multiplayer

Unknown Error in MP

Trouble getting online, setting up a server?
Forum rules
In order to help you, we need to know a lot of information. Make sure to include answers to at least the following questions in your initial post.

- what OS (Windows Xp/Vista, Mac etc.) are you running?
- what FlightGear version do you use?
- copy&paste your commandline.

Please, also see Requesting Technical Help.

Note: If you did not get a reponse, even after 7 days, you may want to check out the FlightGear mailing lists to ask your question there.

Unknown Error in MP

Postby wlbragg » Thu Nov 03, 2022 4:53 am

Does anyone recognize this error in relation to MP?

Code: Select all
  538.73 [ALRT]:nasal      Nasal runtime error: nil used in numeric context
  538.73 [ALRT]:nasal        at d:/FlightGearBuild/install/flightgear/fgdata/Nasal/bits.nas, line 17
  538.73 [ALRT]:nasal        called from: D:/Aircraft/Development-Aircraft/J3Cub/Models/J3Cub.ac, line 46
  538.73 [ALRT]:nasal        called from: d:/FlightGearBuild/install/flightgear/fgdata/Nasal/globals.nas, line 137
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Unknown Error in MP

Postby TheEagle » Thu Nov 03, 2022 3:05 pm

No, but it seems to point to this setlistener call in Aircraft/J3Cub/Models/J3Cub.xml in the <nasal><load> section:
Code: Select all
            setlistener(securing_state_path, func (node) {
                var state = node.getValue();
                pitot_cover.setBoolValue(bits.test(state, 0));
                wheel_chock.setBoolValue(bits.test(state, 1));
                left_tiedown.setBoolValue(bits.test(state, 2));
                right_tiedown.setBoolValue(bits.test(state, 3));
                tail_tiedown.setBoolValue(bits.test(state, 4));
            }, 1, 0);
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3413
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Unknown Error in MP

Postby wlbragg » Thu Nov 03, 2022 6:39 pm

That is what has me puzzled. Look closer at the third line in the error
Code: Select all
called from: D:/Aircraft/Development-Aircraft/J3Cub/Models/J3Cub.ac, line 46

It is referencing an .ac file. Not the file your referring to.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Unknown Error in MP

Postby TheEagle » Thu Nov 03, 2022 7:25 pm

Yeah, that's a bug in the error reporting - when a Nasal error is reported to have occurred in an AC file, in reality it occurred in the <nasal> section of the XML file that loaded the AC file mentioned in the traceback - took me a while to figure that out ! :wink:
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3413
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Unknown Error in MP

Postby wlbragg » Thu Nov 03, 2022 8:09 pm

Ah, OK, good to know.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Unknown Error in MP

Postby wlbragg » Fri Nov 04, 2022 5:00 am

Anyone know how to encode and decode a string using mp_broadcast?

return Binary.encodeInt(seq) ~ Binary.encodeByte(aic) ~ Binary.encodeCoord(pos);

What is the difference between encodeInt and encodeByte? Is Byte a char or string?

Doc's do not match these substrings..

Binary.decodeCoord(substr(msg, 6))
Code: Select all
# Decodes an encoded geo.Coord object.
Binary.decodeCoord = func (str) {
  var coord = geo.aircraft_position();
  coord.set_latlon(Binary.decodeDouble(substr(str, 0)),
                   Binary.decodeDouble(substr(str, 10)),
                   Binary.decodeDouble(substr(str, 20)));
  return coord;
}


Binary.decodeByte(substr(msg, 5))
Code: Select all
Binary.decodeByte = func (str) {
  var v = str[0] - `A`;
  if (v / 64 >= 1) v -= 128;
  return int(v);
}


Binary.decodeDouble(substr(msg, 36))
Code: Select all
Binary.decodeDouble = func (str) {
  return Binary.decodeInt(substr(str, 0)) +
         Binary.decodeInt(substr(str, 5)) / Binary.TWOTO31;
}


So, where do these substr come from and what do they relate to? I can't make heads nor tails out of it?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Unknown Error in MP

Postby AndersG » Fri Nov 04, 2022 9:07 am

If I recall correctly substr(...) is a function that selects a part of a string so this is just choosing the bits of the string to work on.
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2525
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: Unknown Error in MP

Postby wlbragg » Fri Nov 04, 2022 5:49 pm

choosing the bits of the string to work on

I figured that as well, except I can't figure out how it is working in this example. I'm using Wildfire as an example and I don't understand how the substr is getting the needed info from the string. Usually there is a position and then length in a substring function. This is using only one component.

I suppose it might me logical if looked at a certain way and the order the data was placed into the msg and know the length of each data type that was placed there. But this would be a really messy way to do this.

the example is...

Send
broadcast.send(ignition_msg(pos));
return Binary.encodeInt(seq) ~ Binary.encodeByte(1) ~ Binary.encodeCoord(pos);

The parsing
Parse(source, msg)
var type = Binary.decodeByte(substr(msg, 5));
var pos = Binary.decodeCoord(substr(msg, 6));

Another example using different data...
Send
broadcast.send(retardant_drop_msg(pos, radius, volume));

Parse
var pos = Binary.decodeCoord(substr(msg, 6));
var radius = Binary.decodeDouble(substr(msg, 36));

Does it know what data by the "type" and the substring is the length of that type data or is it the position?
In the first example "byte" is at pos 5 and 1 byte or position long? So pos is at 6?

pos in both examples must be at position 6 and is by default the size of a coord?

OK, I think I see it now. For Coord...

coord.set_latlon(Binary.decodeDouble(substr(str, 0)),
Binary.decodeDouble(substr(str, 10)),
Binary.decodeDouble(substr(str, 20)));

That is 30, so pos, which is a coord starts at 6 and is 30 long, so radius "double" stars at 36.

I think the message has a 4 Byte id at the start, so the first encoded data will always be at 5.

Still need to know how to encode and decode a "type" sting.

I may have to use Emesary, but it looks as complicated and I am so close to having this working.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Unknown Error in MP

Postby AndersG » Sat Nov 05, 2022 7:55 am

Encoding a string is not possible with what I put there. The encoded result is a string!
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2525
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: Unknown Error in MP

Postby wlbragg » Sat Nov 05, 2022 6:18 pm

Is there a nasal sting function that converts string 0 to int 0, something similar to C++ atoi()?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Unknown Error in MP

Postby TheEagle » Sat Nov 05, 2022 7:25 pm

Well, in Nasal you can do math with strings as long as they are numerical IIRC (?), but there is a num() function.
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3413
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Unknown Error in MP

Postby wlbragg » Sun Nov 06, 2022 8:48 am

@AndersG

Is there anything special about Wildfire over multiplayer using the mp broadcast protocol?

I'm asking because, as you know I converted Wildfire to an addon and it works as it did in fgdata, MP and all. I am trying to pass some MP data in the cargo towing addon same as is done in Wildfire. I even went to the extremes and followed the Wildfire examples exactly. But I am experiencing some very strange behavior. As it stands right now I can only pass data in the cargo towing addon by using the wildfire addon channel name. I've narrowed it down to the mp channel definition...
var msg_channel_mpp = "environment/wildfire/data";

If I try making my own channel name for the cargo towing addon such as
var mp_msg_channel = "environment/cargo/data";
It fails to get the message across MP. I don't understand what could possibly going on with this.

Is there anything special about the Wildfire MP broadcast. I even got the cargo addon data to pass using the defined wildfire channel name without the wildfire addon even being loaded. The wildfire code didn't even exist as far as FG was concerned.
So that lead me to look into the property tree and see if there was any Wildfire MP data cached in the property tree and there is. I found out wildfire data was defined in fgdata in the "fgdata/Environment/environment.xml" file. So I moved that definition block for wildfire out of fgdata and into the Wildfire addon where it belongs. Wildfire still works, MP included.

Once I noticed that I thought maybe the problem was, environment/wildfire/data, or in the case of the cargo towing addon, sim/cargo/mp/data channels needed to be pre defined in order for MP to see it and use it. Such as...
<environment>
<wildfire>
<enabled type="bool" userarchive="y">false</enabled>
<share-events type="bool" userarchive="y">false</share-events>
<save-on-exit type="bool" userarchive="y">false</save-on-exit>
<restore-on-startup type="bool" userarchive="y">false</restore-on-startup>
<fire-on-crash type="bool" userarchive="y">false</fire-on-crash>
<report-score type="bool" userarchive="y">false</report-score>

<data type="string"/>
</wildfire>
</environment>

I removed all the other defined wildfire properties as they are not being used in the duplicate example nor are they relevant, such as enabled or share-events. In my cargo addon, I removed those options for ease of debugging it.

Well that wasn't it even though I defined my own cargo towing data channel...
<environment>
<cargo>
<data type="string"/>
</cargo>
</environment>

It still doesn't work using the cargo channel name. My cargo data will only transfer if I use the wildfire channel name even thought the wildfire addon isn't even loaded. Although the definition data is still showing up in the property tree.

I've checked the data and names over and over and there is no reason I can find that it will only work with the wildfire channel definition.

I mean there just isn't that much there.

Wildfire definitions are...

var msg_channel_mpp = "environment/wildfire/data";
var broadcast = nil;
var Binary = mp_broadcast.Binary;
broadcast = mp_broadcast.BroadcastChannel.new(msg_channel_mpp, parse_msg);
broadcast.start();
broadcast.send(ignition_msg(pos));

My cargo towing definitions are...

var msg_channel_mpp = "environment/cargo/data";
var broadcast = nil;
var Binary = mp_broadcast.Binary;
broadcast = mp_broadcast.BroadcastChannel.new(msg_channel_mpp, parse_msg);
broadcast.start();
broadcast.send(drop_msg(aicVal), click_pos));

My cargo towing broadcast wont work unless I use...
var msg_channel_mpp = "environment/wildfire/data";
Even when the wildfire addon is not loaded, so it is not piggy backing on the code, only the channel name. What is special about the Wildfire channel name an MP broadcast?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Unknown Error in MP

Postby wkitty42 » Sun Nov 06, 2022 12:28 pm

wlbragg wrote in Sun Nov 06, 2022 8:48 am:Wildfire definitions are...

var msg_channel_mpp = "environment/wildfire/data";
var broadcast = nil;
var Binary = mp_broadcast.Binary;
broadcast = mp_broadcast.BroadcastChannel.new(msg_channel_mpp, parse_msg);
broadcast.start();
broadcast.send(ignition_msg(pos));

My cargo towing definitions are...

var msg_channel_mpp = "environment/cargo/data";
var broadcast = nil;
var Binary = mp_broadcast.Binary;
broadcast = mp_broadcast.BroadcastChannel.new(msg_channel_mpp, parse_msg);
broadcast.start();
broadcast.send(drop_msg(aicVal), click_pos));

is the data that your "drop_msg()" function outputs the same data type as what the "ignition_msg()" function outputs? that's the first thing i can see that may be different and thus handled differently or just thrown away because of the difference in data type...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9148
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Unknown Error in MP

Postby wlbragg » Sun Nov 06, 2022 5:38 pm

Not only no, but I am beyond the parsing and encoding because it is successful. The only thing I change to make it successful is
var msg_channel_mpp = "environment/cargo/data";
to
var msg_channel_mpp = "environment/wildfire/data";

and the only reference to that property starts with

var Binary = mp_broadcast.Binary;
broadcast = mp_broadcast.BroadcastChannel.new(msg_channel_mpp, parse_msg);

and is used with the coding

return Binary.encodeInt(seq) ~ Binary.encodeByte(1) ~ Binary.encodeCoord(pos) ~ Binary.encodeDouble(aic);

and the decoding

var pos = Binary.decodeCoord(substr(msg, 6));
var aicVal = Binary.decodeDouble(substr(msg, 36));

and the broadcasting
broadcast.start();
broadcast.send(drop_msg(num(aicVal[0]), click_pos));

But it only works if I use ...
var msg_channel_mpp = "environment/wildfire/data";
instead of
var msg_channel_mpp = "environment/cargo/data";

and the wildfire code/addon does not even exist, it is not even loaded. So it is something to do with environment/wildfire/data, it's like it is hard coded in the nasal broadcast code, which I am pretty sure it is not.

It's not that it is not working at all, it is that it only works because of one user defined property having to be environment/wildfire/data which does not make sense in any reality unless there is something I am missing. Maybe something hardcoded in fgdata because that is where the original wildfire code came from. but I looked and there is nothing there as of my testing yesterday when I moved the init code from fgdata/Environment/environment.xml to the wildfire addon.

<environment>
<wildfire>
<enabled type="bool" userarchive="y">false</enabled>
<share-events type="bool" userarchive="y">false</share-events>
<save-on-exit type="bool" userarchive="y">false</save-on-exit>
<restore-on-startup type="bool" userarchive="y">false</restore-on-startup>
<fire-on-crash type="bool" userarchive="y">false</fire-on-crash>
<report-score type="bool" userarchive="y">false</report-score>

<data type="string"/>
</wildfire>
</environment>

We're talking about only this property "<data type="string"/>" that is relative to the discussion.

I've spent hours testing to get this far and to this level of understanding, but I am still missing a very important piece.

My last test, just now, was to add
<environment>
<cargo>
<data type="string"/>
</cargo>
</environment>
into fgdata/Environment/environment.xml, just in case it had to be initialized from there. Nope, not the issue. Which I really already knew because I took the original wildfire init out of that file and moved it to the wildfire addon space and it still works.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Unknown Error in MP

Postby AndersG » Sun Nov 06, 2022 7:28 pm

Hi,

The property itself needs to be sent over MP which at least in the FG versions I have used is defined in the C++ source code (if I recall correctly).

Cheers,
Anders
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2525
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Next

Return to Multiplayer

Who is online

Users browsing this forum: No registered users and 3 guests