Having the strangest issue here.
Setup:
I have an Arduino UNO connected to my Air Manager laptop (Linux Mint 19) over USB.
I am connected to FS2020 over the network, using the stock Cessna172 for testing.
The thing I wanted to do is: read the NAV1 Standby Frequency and display that on an OLED display on the Arduino UNO.
AirManager connects to my Sim alright.
I can get the right data from the sim and get it to show in the AM console.
The Arduino receives the data correctly -most of the time-, and here is where the problem is.
It seems to skip certain values consistently and I can't figure out why....
I am using SoftwareSerial on the Arduino for now for debugging, as I obviously cannot use the built-in Serial that is used by AM.
Code: Select all
Arduino UNO code:
----------------------------------------------------
#include <si_message_port.hpp>
SiMessagePort* messagePort;
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 6); // Using SoftwareSerial for debugging
void setup() {
messagePort = new SiMessagePort(SI_MESSAGE_PORT_DEVICE_ARDUINO_UNO, SI_MESSAGE_PORT_CHANNEL_A, new_message_callback);
mySerial.begin(115200);
}
void loop() {
messagePort->Tick();
}
static void new_message_callback(uint16_t message_id, struct SiMessagePortPayload* payload) {
if (message_id == 1){
int x = payload->data_int[0];
mySerial.println(x);
}
}
Air Manager code:
----------------------------------------------------
my_message_port = hw_message_port_add("ARDUINO_UNO_A", new_message)
function NAV1_callback(freq)
freq=freq*100 -- do this to make data an integer (no decimals)
hw_message_port_send(my_message_port, 1, "INT", freq)
print(freq) -- Print to Console for debugging
end
fs2020_variable_subscribe("NAV STANDBY FREQUENCY:1", "Mhz", NAV1_callback)
Now, when changing the NAV1 Standby Frequency in the aircraft, I get the following results:
Output from AM Console:
-----------------------
11400,0
11405,0
11410,0
11415,0
11420,0
11425,0
11430,0
11435,0
11440,0
11445,0
11450,0
11455,0
11460,0
11465,0
11470,0
11475,0
11480,0
11485,0
11490,0
11495,0
11400,0
Output from Arduino SoftwareSerial:
-----------------------------------
11400
11405
11410
11415
0
11425
11430
11435
11440
0
11450
11455
11460
11465
0
11475
11480
11485
11490
0
11400
11405
What's with the zero' s??
Can anyone please help me out here?
Thanks all in advance, I must be overlooking something...
Greetings,
Jacco