Kent Posted February 10, 2017 Report Posted February 10, 2017 Hey Pete, I have a C# application interfacing with WideClient. I'm able to read data just fine, however I am running into some problems reading traffic data. Setup: Prepar3d 3 with Ultimate Traffic 2 installed & running. FSUIPC installed running WideServer. Seperate computer runs WideClient & C# application. When running the simulator with UT2 there are maybe 50 or more AI aircraft loaded. The TCAS data I read seems unusable, no field is coming through as useful. I wonder if AI traffic is not transmitted to WideClient. When I view the raw bytes, for example, the first 8 or so are all 0. As I scroll through the raw data there are occasional bytes with values - however I can't find any 40-byte block that does not contains enough data to decode to anything useful. If you need I can reply with a screenshot of the raw byte data. My test method is as follows: private Offset<byte[]> airborneTraffic = new Offset<byte[]>(0x3840, 3840); // AI airborne aircraft traffic data (same format as the entry for E080) private void ProcessTraffic() { var t = airborneTraffic.Value; // (96x 40 byte array) for (int i = 0; i < 3840; i += 0) { // TCAS DATA var id = BitConverter.ToInt32(t, i); i += 4; // 0 = empty, otherwise this is an FSgenerated ID.FSUIPC makes this negative to distinguish FS entries from user added ones var lat = BitConverter.ToSingle(t, i); i += 4; var lon = BitConverter.ToSingle(t, i); i += 4; var alt = BitConverter.ToSingle(t, i); i += 4; var hdg = BitConverter.ToInt16(t, i); i += 2; var gs = BitConverter.ToInt16(t, i); i += 2; var vs = BitConverter.ToInt16(t, i); i += 2; var idAtc = Encoding.ASCII.GetString(t, i, 15).ToString(); i += 15; var bState = BitConverter.ToBoolean(t, i); i += 1; var com1 = BitConverter.ToInt16(t, i); i += 2; } } So question is, is my test method way off base, or is AI traffic not transmitted to WideClient? Thank you! Kent
Pete Dowson Posted February 10, 2017 Report Posted February 10, 2017 11 minutes ago, Kent said: The TCAS data I read seems unusable, no field is coming through as useful. I wonder if AI traffic is not transmitted to WideClient It most certainly is. Please try my TrafficLook utility on your Client PC. That will show you! (Get it from Dlownload Links subforum, useful programs). 12 minutes ago, Kent said: f you need I can reply with a screenshot of the raw byte data. No thanks. Use FSInterrogate to both read and display raw data. If that looks different to yours you know you are doing something wrong. I'm afraid I cannot help with C# at all. I only know ASM and C (with C++ extensions, but not OOM). However, in your code fragment i only see one place where an offset might be specified, and that is: new Offset<byte[]>(0x3840, 3840) If this sets offset 3840, then that is actually in the middle or a load of offsets containing engine data! Where are you addressing the traffic data? Doesn't C# support something like structures? Your code seems very awkward. The whole point in defining structres is for ease of data access. Pete
Kent Posted February 10, 2017 Author Report Posted February 10, 2017 Wow I feel dumb. Apparently I copied the length into the offset name by accident and was reading the entirely wrong data! Figured it out right before I saw your post. Yes C# supports structures. My code is a simple test method to read/parse the data. It's very easy to convert it to assigning variables on a structure. The style of tracking the index as an iterator after each read is so that if I make a mistake in the length of any one field I don't have to rewrite the offsets manually. Perfect for when reading data sequentially. Code is cleaner (and way faster) in than using a binary stream reader. private Offset<byte[]> airborneTraffic = new Offset<byte[]>(0x3840, 3840); // AI airborne aircraft traffic data (same format as the entry for E080) should have been: private Offset<byte[]> airborneTraffic = new Offset<byte[]>(0xF080, 3840); // AI airborne aircraft traffic data (same format as the entry for E080) Thanks!
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