
michielsweb
Members-
Posts
60 -
Joined
-
Last visited
-
Days Won
3
michielsweb last won the day on February 7
michielsweb had the most liked content!
Profile Information
-
Gender
Male
-
Location
dd
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
michielsweb's Achievements
-
encounter FSUIPC_ERR_SIZE. while extracting data
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
odd question is it possible to lvar read out msfs atc ? π -
encounter FSUIPC_ERR_SIZE. while extracting data
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
feel free to add it too the paul henty examples. as it gives a nice structures to program own programs on π -
encounter FSUIPC_ERR_SIZE. while extracting data
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Runtime.InteropServices; using FSUIPC; namespace MSFSVariableServices_CSharp { class Program { private static string[] simdata_lvars; private static double[] simdata_values; private static bool stopSimLoop = false; static async Task Main() { if (!TestFSUIPCConnection()) { return; } InitMSFSServices(); await WaitForMSFSVariableServices(); MSFSVariableServices.Start(); LoadLVarList(); await StartSimInputOutputLoop(); } private static bool TestFSUIPCConnection() { try { FSUIPCConnection.Open(); Console.WriteLine("FSUIPC connection successful."); FSUIPCConnection.Close(); return true; } catch (Exception ex) { Console.WriteLine($"FSUIPC Connection Error: {ex.Message}"); return false; } } private static async Task WaitForMSFSVariableServices() { Console.WriteLine("Waiting for MSFSVariableServices to start..."); int retries = 10; for (int i = 0; i < retries; i++) { if (MSFSVariableServices.IsRunning) { Console.WriteLine("MSFSVariableServices is now running!"); return; } Console.WriteLine($"Attempt {i + 1}/{retries}: Waiting for MSFSVariableServices..."); await Task.Delay(100); } Console.WriteLine("ERROR: MSFSVariableServices did not start. Check MSFS and FSUIPC."); } private static void InitMSFSServices() { Console.WriteLine("Initializing MSFS Variable Services..."); try { MSFSVariableServices.OnLogEntryReceived += VS_OnLogEntryReceived; MSFSVariableServices.OnVariableListChanged += VS_VariableListChanged; MSFSVariableServices.OnValuesChanged += VS_OnValuesChanged; MSFSVariableServices.Init(); MSFSVariableServices.LogLevel = LOGLEVEL.LOG_LEVEL_INFO; Console.WriteLine("MSFSVariableServices initialized successfully!"); } catch (Exception ex) { Console.WriteLine($"MSFSVariableServices Init Failed: {ex.Message}"); } } private static void VS_OnLogEntryReceived(object sender, LogEventArgs e) { } private static void VS_VariableListChanged(object sender, EventArgs e) { } private static void VS_OnValuesChanged(object sender, EventArgs e) { foreach (FsLVar lvar in MSFSVariableServices.LVarsChanged) { } } private static void LoadLVarList() { string filePath = Path.Combine(Directory.GetCurrentDirectory(), "lvars.txt"); if (File.Exists(filePath)) { simdata_lvars = File.ReadAllLines(filePath); simdata_values = new double[simdata_lvars.Length]; } else { simdata_lvars = new string[0]; simdata_values = new double[0]; } } private static async Task StartSimInputOutputLoop() { while (!stopSimLoop) { await ReadSimDataMSFSVariableServices(); await Task.Delay(300); } } private static async Task WriteLVarValue(string lvarName, double value) { FsLVar lvar = MSFSVariableServices.LVars[lvarName]; if (lvar != null) { lvar.SetValue(value); } else { } await Task.CompletedTask; } private static async Task ReadSimDataMSFSVariableServices() { if (simdata_lvars == null || simdata_lvars.Length == 0) { Console.WriteLine("No LVARs found in lvars.txt."); return; } for (int i = 0; i < simdata_lvars.Length; i++) { try { string lvar = simdata_lvars[i].Trim(); FsLVar lvarObj = MSFSVariableServices.LVars[lvar]; if (lvarObj != null) { double newValue = lvarObj.Value; Console.WriteLine($"{lvar} = {newValue}"); if (simdata_values[i] != newValue) { simdata_values[i] = newValue; } } else { } } catch (Exception ex) { } } await Task.CompletedTask; } } } @Paul Henty this allows, to monitor a own set of lvars, and store it in a array. π -
encounter FSUIPC_ERR_SIZE. while extracting data
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
okay, found the issue, @Paul Henty program did not have time to start the service π wil clean up my code and fix the code to read it here -
encounter FSUIPC_ERR_SIZE. while extracting data
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
@Paul Henty, looking into youre c# file. Been trying to adjust your form version, to a backend version. for now using console for debugging. yet i get 0 off the lvars found! even tough in fsuipc them self they are found. is it the way i declare the lvars? tried the following methods. L:FSDT_Deice_Available FSDT_Deice_Available (->L:FSDT_Deice_Available) using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Runtime.InteropServices; using FSUIPC; using System.Deployment.Application; namespace MSFSVariableServices_CSharp { class Program { private static string[] simdata_lvars; private static double[] simdata_values; private static bool stopSimLoop = false; static async Task Main() { OpenConsoleWindow(); Console.WriteLine("π Starting FSUIPC connection test..."); //works if (!TestFSUIPCConnection()) { Console.WriteLine("β FSUIPC connection failed. Make sure MSFS and FSUIPC are running."); // works if sim is off. return; } Console.WriteLine("β FSUIPC connected. Proceeding..."); // works LoadLVarList(); InitMSFSServices(); await StartSimInputOutputLoop(); } private static void OpenConsoleWindow() { bool attached = AttachConsole(-1); if (!attached) { AllocConsole(); Console.WriteLine("π₯ New console created!"); //works } else { Console.WriteLine("π₯ Attached to existing console!"); //works } } [DllImport("kernel32.dll")] private static extern bool AllocConsole(); [DllImport("kernel32.dll")] private static extern bool AttachConsole(int dwProcessId); private static bool TestFSUIPCConnection() { try { FSUIPCConnection.Open(); Console.WriteLine("β FSUIPC connection successful."); // works FSUIPCConnection.Close(); return true; } catch (Exception ex) { Console.WriteLine($"β FSUIPC Connection Error: {ex.Message}"); return false; } } private static void InitMSFSServices() { MSFSVariableServices.OnLogEntryReceived += VS_OnLogEntryReceived; MSFSVariableServices.OnVariableListChanged += VS_VariableListChanged; MSFSVariableServices.OnValuesChanged += VS_OnValuesChanged; MSFSVariableServices.Init(); MSFSVariableServices.LogLevel = LOGLEVEL.LOG_LEVEL_INFO; } private static void VS_OnLogEntryReceived(object sender, LogEventArgs e) { Console.WriteLine($"[LOG] {e.LogEntry}"); } private static void VS_VariableListChanged(object sender, EventArgs e) { Console.WriteLine("[INFO] Variable list updated."); } private static void VS_OnValuesChanged(object sender, EventArgs e) { Console.WriteLine("[INFO] LVAR values changed."); } private static void LoadLVarList() { string filePath = Path.Combine(Directory.GetCurrentDirectory(), "lvars.txt"); if (File.Exists(filePath)) { simdata_lvars = File.ReadAllLines(filePath); simdata_values = new double[simdata_lvars.Length]; Console.WriteLine($"β Loaded {simdata_lvars.Length} LVARs from file."); // works } else { Console.WriteLine($"β Error: LVAR file not found: {filePath}"); simdata_lvars = new string[0]; simdata_values = new double[0]; } } private static async Task StartSimInputOutputLoop() { while (!stopSimLoop) { await ReadSimDataMSFSVariableServices(); await Task.Delay(500); } } private static async Task ReadSimDataMSFSVariableServices() { if (simdata_lvars == null || simdata_lvars.Length == 0) { Console.WriteLine("β οΈ No LVARs found in lvars.txt."); return; } for (int i = 0; i < simdata_lvars.Length; i++) { try { string lvar = simdata_lvars[i].Trim(); if (!lvar.StartsWith("L:")) lvar = "L:" + lvar; FsLVar lvarObj = MSFSVariableServices.LVars[lvar]; if (lvarObj != null) { double newValue = lvarObj.Value; if (simdata_values[i] != newValue) { simdata_values[i] = newValue; Console.WriteLine($"π’ [UPDATED] {lvar}: {newValue}"); } } else { Console.WriteLine($"β ERROR: LVAR {lvar} not found."); // i always end here even if the lvar is in fsuipc self active } } catch (Exception ex) { Console.WriteLine($"β ERROR reading LVAR {simdata_lvars[i]}: {ex.Message}"); } } await Task.CompletedTask; } } } also @Paul Henty i would not mind if we get it too work, if this part is getting added to the sample. as i think is a more common way. to extract the data from the sim, then read a value from the form π -
encounter FSUIPC_ERR_SIZE. while extracting data
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
Hey Gentlemen, first off all sorry for my late reply, work kept me occupied. i just read the replies. i did do wasm interpertation in the mean time. But halfway through the lvar list i entered a 15 again. so i wil attempt to read paul's script tommorow. hopefully i find out where i am going wrong. keep u all updated π -
private static async Task StartSimInputOutputLoop() { Console.WriteLine("Starting Input/Output loop..."); await Task.Run(async () => { try { FSUIPCConnection.Open(); // Open connection ONCE while (!stopSimLoop) { try { Console.WriteLine("Checking FSUIPC data..."); // Process pending inputs (Write to LVARs) if (simdata_input_pending != null) { foreach (string input in simdata_input_pending) { string[] i = input.Split(','); if (i.Length >= 2) { string lvar = i[0].Trim(); if (float.TryParse(i[1].Trim(), out float newValue)) { // Send command to update LVAR Offset<string> setLvar = new Offset<string>(0x0D70, 256); setLvar.Value = $"L:{lvar}={newValue}"; FSUIPCConnection.Process(); Console.WriteLine($"β Updated LVAR: {lvar} = {newValue}"); } } } simdata_input_pending = null; } // Read LVAR values properly if (simdata_lvars != null) { simdata_output = new string[simdata_lvars.Length]; for (int j = 0; j < simdata_lvars.Length; j++) { string lvarName = simdata_lvars[j]; // Send request to get LVAR value Offset<string> getLvarRequest = new Offset<string>(0x0D70, 256); getLvarRequest.Value = $"L:{lvarName}"; FSUIPCConnection.Process(); // Wait a bit for FSUIPC to process the request await Task.Delay(100); // Retrieve the actual LVAR value from offset 0x66C0 (example offset) Offset<float> getLvarResponse = new Offset<float>(0x66C0); FSUIPCConnection.Process(); // Fetch updated value // Store and print result float lvarValue = getLvarResponse.Value; simdata_output[j] = $"{lvarName}: {lvarValue}"; Console.WriteLine($" [TEST] Read LVAR: {lvarName} = {lvarValue}"); // Debugging output } } } catch (Exception ex) { Console.WriteLine($"β FSUIPC Read/Write Error: {ex.Message}"); } await Task.Delay(5000); // Wait 5 seconds before next update } } catch (Exception ex) { Console.WriteLine($"β FSUIPC Connection Error: {ex.Message}"); } finally { FSUIPCConnection.Close(); // Close connection when stopping } }); } i run this task, to read out about 80ish. lvars. " ? FSUIPC Read/Write Error: FSUIPC Error #15: FSUIPC_ERR_SIZE. The amount of data requested exceeded the maximum allowed in one Process()." this is the result. is their a limit to the ammount of lvar data in a procces?? also @Pete Dowson is their anyway we can turn process into a Task? so we can use a await?
-
request simple c# demo script
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
wow great i wil look into it. as soon as i complete the current part of project. wil it come whit a offset list? my fsuipc doc one is seemingly oldπ -
request simple c# demo script
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
oh realy i missed that part!! deeply appologise i wil read into it! Thank you for pointing me too it! @Paul Henty i decided to name the co pilot paul. as a easteregg tribute π found it a nice touch for the long and helpfull help & support π -
request simple c# demo script
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
Hey all its been a long time!! Much RL troubles promotions and job changesπ But by now i am 100% converted to the NGXu π cleaned up te code. and even started the creation of a virtual COPILOT. First voice actor has delivered. GSX voiced and CABINALIVe now speak in 1 tong, and fluently. now for the most exciting news !! yes i made it. a co pilot. is now actively working. his checklists and procederus atleast the first checklists are here!! π i was wondering a minor questions tough!! (can i read a fsuipc joystick input through the fsuipc.net DLL? (i want to dedicate 1 button. to my joystick for a repeat button) or any work arround ideas are welcome!! -
@Paul Henty i downloaded ure demo 1.1 but it seems to be not working from the start into errors? but i read u maked it thread safe (does this mean i can use a seperate thread to just read the offsets?
-
request simple c# demo script
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
small update too all π i recommand too all if u run a larger program π todo this on form startup: Process.GetCurrentProcess().ProcessorAffinity = (System.IntPtr)1; i wil make sure ure app only works on core 0; i do this to make sure that p3d doesnt share his ipc π on my relativly extended script π i gained a lowering of 20% of cpu cores for p3d π -
request simple c# demo script
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
just so happy whit ure DLL it creates a great programming basic to add to p3d π -
request simple c# demo script
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
rodger that paul !! i remove the procces π il wil think for a solutions to "reduce" the amount of send control update to sim have to think about how i am gonna shape this into a better way. maybe i do a timely update. to send a 1 or 2 second update π whit all ticks created at that time at once -
request simple c# demo script
michielsweb replied to michielsweb's topic in FSUIPC Client DLL for .NET
case "CRS1": temp = this.raw_mcpcrs1.Value; if (ser[1] == "1") { temp--; FSUIPCConnection.SendControlToFS(PMDG_737_NGX_Control.EVT_MCP_CRS_L_SET, temp); } // rotate left. else if (ser[1] == "2") { temp++; FSUIPCConnection.SendControlToFS(PMDG_737_NGX_Control.EVT_MCP_CRS_L_SET, temp); } //rotate right else if (ser[1] == "3") { FSUIPCConnection.SendControlToFS(PMDG_737_NGX_Control.EVT_MCP_VNAV_SWITCH, 1); } //short push (APP) else { } // longpush FSUIPCConnection.Process(); break; paul. i push in serial ticks from encoders to c# and proces like this. i miss about 2 or 3 out of 5 ticks. now i do know i can get the ticks around 5/5 into c# so i was wonder is this a slow way to update sim and is there a faster way? π or is this as fast as it gets. it just feels " slow " sorry its just a snippet π but its all same just other value π