RavenTech Posted April 5, 2015 Report Posted April 5, 2015 I'm trying to create an app that will eventually read my tablet inclinometer and control the aircraft using that but in order to do so I have to compile as a Universal App in windows. When I run the code it fails to open the connection and returns error 12. Im using the C# SDK class file and VS2013 for windows. When I run similar code using C# in a console windows program it works fine so am I missing a fundamental difference that exsists between how regular .net for window will interact versus Universal Apps .net? Thank you. Im using Windows 8.1 on a Surface Pro 3 This is the code for the main program window using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 namespace FSMotionControl { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { // Call FSUIPC Fsuipc f = new Fsuipc(); // Error code result int dwResult = -1; int token = 0; int ElevatorPosition = 0; public MainPage() { this.InitializeComponent(); } private void ConnectButton_Click(object sender, RoutedEventArgs e) { // initialize fsuipc f.FSUIPC_Initialization(); // open FSUIPC DisplaySurfacePitch.Text = f.FSUIPC_Open(0, ref dwResult).ToString() + "," +dwResult; f.FSUIPC_Close(); } private void ReadData() { } private void GetDataButton_Click(object sender, RoutedEventArgs e) { ReadData(); } } } This is the code from the program that did work using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SourceFSUIPCTest { class Program { static void Main(string[] args) { // Create Object FsuipcSdk.Fsuipc f = new FsuipcSdk.Fsuipc(); // Result Variable int dwResult = 0; bool result; int token = 0; // Initialize f.FSUIPC_Initialization(); // Open Console.WriteLine("Open Connection: " + f.FSUIPC_Open(0, ref dwResult).ToString()); // Read Console.WriteLine("Read Variable: " + f.FSUIPC_Read(0x0BB2, 2, ref token, ref dwResult)); // Process Console.WriteLine("Process Connection: " + f.FSUIPC_Process(ref dwResult)); // Get Variable Console.WriteLine("Get Variable: " + f.FSUIPC_Get(ref token, ref dwResult)); // Show Results Console.WriteLine("Results: " + dwResult); f.FSUIPC_Close(); Console.ReadLine(); } } }
Pete Dowson Posted April 5, 2015 Report Posted April 5, 2015 I'm trying to create an app that will eventually read my tablet inclinometer and control the aircraft using that but in order to do so I have to compile as a Universal App in windows. When I run the code it fails to open the connection and returns error 12. Im using the C# SDK class file and VS2013 for windows. When I run similar code using C# in a console windows program it works fine so am I missing a fundamental difference that exsists between how regular .net for window will interact versus Universal Apps .net? Sorry, I don't know what a "Universal App" is. However, if you look at the Header file to see what error 12 is you'll see it shows: #define FSUIPC_ERR_SENDMSG 12 // IPC sendmessage failed all retries (That's from the C ZIP. I don't know C# so I can't advise on that, but it will be the same error). You could have located that using your VS2013 debugger. The most likely reason is that there's some protection or wall between your "Universal App" type of process and the FS process in which FSUIPC is running. One example of such protection is when FSX and the application are running at different privilege levels, e.g.one "as administrator" and the other not. This is the sort of area you will need to look into. Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now