Jump to content
The simFlight Network Forums

To get full AI Traffic identity strings by VB


Recommended Posts

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

====

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.