Using 'static_data_load' produces false ERROR log messages

Discuss suspected bugs with other users and Sim Innovations Staff

Moderators: russ, Ralph

Post Reply
Message
Author
Tetrachromat
Posts: 236
Joined: Sun Feb 14, 2021 6:55 pm

Using 'static_data_load' produces false ERROR log messages

#1 Post by Tetrachromat »

Lately I have observed that AM (v4.1.1 as well as v4.1 Beta 39) is logging false ERRORS when using the AM function 'static_data_load' with JSON data files.

It is not dependent on my specific code. It occurs as well when using the sample code from yourWIKI for the 'static_data_load' function.

This are the log messages created from that sample code:

a single log entry on startup of AM

Code: Select all

2022-03-17 11:56:38 ERROR InstrumentScanner - *Test - Instrument Scanner ERROR: Error loading instrument script: [string "logic.lua"]:6: attempt to index a nil value (global 'data')
and multiple log entries when running the instrument from 'Create/Edit' tab

Code: Select all

2022-03-17 11:58:38 ERROR InstrumentScanner - *Test - Instrument Scanner ERROR: Error loading instrument script: [string "logic.lua"]:6: attempt to index a nil value (global 'data')
2022-03-17 11:58:38 ERROR InstrumentScanner - *Test - Instrument Scanner ERROR: Error loading instrument script: [string "logic.lua"]:6: attempt to index a nil value (global 'data')
2022-03-17 11:58:38 ERROR InstrumentScanner - *Test - Instrument Scanner ERROR: Error loading instrument script: [string "logic.lua"]:6: attempt to index a nil value (global 'data')
2022-03-17 11:58:38 ERROR InstrumentScanner - *Test - Instrument Scanner ERROR: Error loading instrument script: [string "logic.lua"]:6: attempt to index a nil value (global 'data')
These ar all false ERROR messages as the instrument is behaving properly and producing the correct results. There are no runtime errors.

I question the value of such scanning when the messages are not correct. The scanner should ignore indexing of such dynamically loaded data.

Paul

User avatar
Corjan
Posts: 2939
Joined: Thu Nov 19, 2015 9:04 am

Re: Using 'static_data_load' produces false ERROR log messages

#2 Post by Corjan »

Hi,


You should check if data returned is not equal to nil.

This was not very clear in the wiki examples, I have added it.


Corjan

Tetrachromat
Posts: 236
Joined: Sun Feb 14, 2021 6:55 pm

Re: Using 'static_data_load' produces false ERROR log messages

#3 Post by Tetrachromat »

Corjan wrote: Thu Mar 17, 2022 1:51 pm You should check if data returned is not equal to nil.
This was not very clear in the wiki examples, I have added it.
Hi Corjan

The log messages are not runtime errors, they are created before the code is run. When the code runs all is ok, the function returns a valid data structure (lua table). One can check with the debugger.

There is a code scanning process running when AM starts up, scanning the code for every instrument. And a second code scanning process is running just before the code gets executed. This is something AM initiates. I do not have control over that scanning.

Paul

User avatar
Corjan
Posts: 2939
Joined: Thu Nov 19, 2015 9:04 am

Re: Using 'static_data_load' produces false ERROR log messages

#4 Post by Corjan »

Yeah, it does the scanning. And the scanner will not bother loading the static data.
That is why you have to check for nil in the code.

Corjan

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Using 'static_data_load' produces false ERROR log messages

#5 Post by Keith Baxter »

Corjan wrote: Thu Mar 17, 2022 3:40 pm Yeah, it does the scanning. And the scanner will not bother loading the static data.
That is why you have to check for nil in the code.

Corjan
Hi,

Yes I found that some time ago. Never used to be like that. However, just added a nil check in code and the error is no more.

You will find the same thing with the Nav Data. Some fields are nil because there is on data for that particular airport , runway or other NAV type. Just add a nil check and the error is no more.

Corjan might also be worth mentioning that in the wiki as well.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Post Reply