Telly Posted March 10, 2011 Report Posted March 10, 2011 Dear colleagues and Peter, I want to obtain the full AI Traffic identity strings under the VB (Access-VBA). I described below function in VB, but I could not obtain the "Final Result String". I've checked some results in each steps. (1) No error at Step 1. (2) I could get the "Time_stamp". (Step2) (3) No error at Step3. (4) No error at Step4. (5) I could escape this loop because time stamp value had been changed in this STEP. (6) No error at Step5. Then the result is blank. In addition, ID_Long was quoted from the "TCAS table ID". The ID was confirmed by the compareing the ID in the "Traffic Toolbox (FS2004 SDK)". As the "Command_Type_Long", I substituted a value 1 (=Tail Number). Thanks, Regards, Telly ========= Function AI_Detail_Read(Command_Type_Long As Long, ID_Long As Long) Dim Result_Str As String Dim signature As Long Dim Time_Stamp As Long Dim Time_Stamp2 As Long signature = 0 '////////////////////////////////////////////////////////////////////////// ' (1) Write the selected command, from list below, to D004 (32-bit DWORD) '////////////////////////////////////////////////////////////////////////// booResult = FSUIPC_Write(&HD004&, 4, VarPtr(Command_Type_Long), dwResult) booResult = FSUIPC_Process(dwResult) '/////////////////////////////////////////////////// ' (2) Read the timestamp at D008 (32-bit DWORD) '/////////////////////////////////////////////////// booResult = FSUIPC_Read(&HD008&, 4, VarPtr(Time_Stamp), dwResult) booResult = FSUIPC_Process(dwResult) '///////////////////////////////////////////////////////////////////////////////// ' (3) Write the AI id (from the TCAS table, see earlier) to D00C (32-bit DWORD) '///////////////////////////////////////////////////////////////////////////////// booResult = FSUIPC_Write(&HD00C&, 4, VarPtr(ID_Long), dwResult) booResult = FSUIPC_Process(dwResult) '//////////////////////////////////////////////// ' (4) Write a signature to D000 (32-bit DWORD) '///////////////////////////////////////////////// booResult = FSUIPC_Write(&HD000&, 4, VarPtr(signature), dwResult) booResult = FSUIPC_Process(dwResult) '/////////////////////////////////////////////////// ' (5) Wait till the timestamp in D008 changes. '/////////////////////////////////////////////////// Time_Stamp2 = Time_Stamp Do Until Time_Stamp <> Time_Stamp2 booResult = FSUIPC_Read(&HD008&, 4, VarPtr(Time_Stamp2), dwResult) booResult = FSUIPC_Process(dwResult) Debug.Print "Timestamp2=" & Time_Stamp2 & " " & Now() Loop '////////////////////////////////////////////////////////////////////////////// ' (6) Read string result (up to 48 bytes including terminating zero) from D010 '////////////////////////////////////////////////////////////////////////////// booResult = FSUIPC_Read(&HD010&, 48, VarPtr(Result_Str), dwResult) booResult = FSUIPC_Process(dwResult) '///////////////////////// ' Final Result Display '///////////////////////// MsgBox "Final Result= " & Result_Str AI_Detail_Read = Result_Str End Function ====
Pete Dowson Posted March 14, 2011 Report Posted March 14, 2011 I want to obtain the full AI Traffic identity strings under the VB (Access-VBA). I described below function in VB, but I could not obtain the "Final Result String". I can't help a lot with VB, except to say that I think VB uses 16-bit character codes, so trying to read strings as strings probably doesn't work, You may need to read them into a BYTE array, then go into a look converting each byte into a VB character and concatenating it to the string built so far. But two points do arise: 1. Your code would be much more efficient and foolproof if the first 4 steps are accomplished with only one call to FSUIPC_Process, as suggested in the documentation, and 2. You can always see what your program is accomplishing by using FSUIPC IPC logging -- the two options in the FSUIPC Logging tab. Regards Pete
Telly Posted March 17, 2011 Author Report Posted March 17, 2011 Dear Peter, Thank you for your reply. I tried to change my VB program and logged the FSUIPC result. But, the strings of detail information about AI did not obtained. My changed program and log are below: If you can find the reasons, please tell me. Thank you. ===== Public AI_airborne_AC_Detail_AI(48) As Byte STEP (1) - (5) abbreviation '////////////////////////////////////////////////////////////////////////////// ' (6) Read string result (up to 48 bytes including terminating zero) from D010 '////////////////////////////////////////////////////////////////////////////// booResult = FSUIPC_Read(&HD010&, 48, VarPtr(AI_ground_AC_Detail(1)), dwResult) booResult = FSUIPC_Process(dwResult) rem ==> Strings had been read by "Byte" type Variable LOG: 19373719 WRITE0 D004, 4 bytes: 01 00 00 00 19373719 READ0 D008, 4 bytes: BA FB 8D 01 19373719 WRITE0 D00C, 4 bytes: 25 00 00 00 19373719 WRITE0 D000, 4 bytes: 00 00 00 00 19373719 READ0 D008, 4 bytes: 07 CC 92 01 19373781 READ0 D010, 48 bytes: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19373781 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19373781 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Pete Dowson Posted March 17, 2011 Report Posted March 17, 2011 I tried to change my VB program and logged the FSUIPC result. But, the strings of detail information about AI did not obtained. My changed program and log are below: Okay. Let's see what could be wrong: 19373719 WRITE0 D004, 4 bytes: 01 00 00 00 This says you want the Tail Number ... right? 19373719 READ0 D008, 4 bytes: BA FB 8D 01 19373719 WRITE0 D00C, 4 bytes: 25 00 00 00 This doesn't really look right to me. Unless the traffic is being injected into FSUIPC from another program (like Squawkbox), all of the FS traffic IDs are negative numbers (or, in an unsigned variable, very large numbers like 0xFFFFFC28). How are you reading the Traffic IDs? I suspect the error lies there. You can use my TrafficLook utility to view details including the ID but bear in mind that the program NEGATES the ID so that it displays neatly as a number. So, for instance, FFFFFFC28 shows there as 928 (0xFFFFFC28 = -928 in decimal). If you read details for a non-existent AI aircraft you get zeroes. Regards Pete
Telly Posted March 17, 2011 Author Report Posted March 17, 2011 Dear Peter, Thank you for adequate advice. I BELIEVED the ID should be Positive number. Indeed, Microsoft Traffic Tool in SDK showed the ID (key) as the positive number. I was able to obtain registration number information safely by reversing the sign after ID had been converted into the decimal number. Regards Telly
Pete Dowson Posted March 17, 2011 Report Posted March 17, 2011 I BELIEVED the ID should be Positive number. Indeed, Microsoft Traffic Tool in SDK showed the ID (key) as the positive number. Yes, but I think that was a change between FS9 and FSX. By then I had already settled on the convention of assigning positive IDs to aircraft injected by external programs, such as that done by AIBridge and SquawkBox, and I had to maintain compatibility rather than force programs to be re-written. I was able to obtain registration number information safely by reversing the sign after ID had been converted into the decimal number. Good, but the normal way of programming it would be to use the ID from the TCAS table offsets, exactly as it is with no conversion. Then it would work for injected aircraft too. Regards 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