Results 1 to 10 of 10
  1. #1
    25+ Posting Member Demon's Avatar
    Join Date
    Feb 2011
    Location
    Quebec, Canada
    Posts
    42
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    How to read data properly in VB6?

    Hi,

    I can't figure out how to read the captain flight director properly, it's always 0. I tried all kinds of data types and conversions but nothing worked.

    • Win 7 64bit
    • VB6
    • FS-X sp2
    • FSUIPC v4.53 licensed
    • Lekseeson v8.2 (running in FSX\Modules folder)
    • my program (also running in FSX\Modules folder)


    I've added a 2nd timer that runs at a different interval than FS clock (used FSUIPC VB sample). A counter on the form shows that it's running properly and I can read Zulu time. Everything on the Lekseecon GUI is green, FS-X is running and I toggle the capt FD switch with the mouse.

    Log:
    lekseecon_f version 8.2
    C:\Users\Robert\Documents\lekseecon_f.ini found
    Number of lekseecon variable(-s) detected: 1
    939
    SDK connected.
    FSUIPC connected.
    Running...
    Code:
    Code:
    Public dwCounter As Long
    
    Private Sub ReadData_Timer()
      Dim dwResult As Long
      Dim bytData() As Byte
      dwCounter = dwCounter + 1
      
      ReDim bytData(1)
      If FSUIPC_Read(&H93AB, 1, VarPtr(bytData(1)), dwResult) Then
        If FSUIPC_Process(dwResult) Then
          lblFlightDirCPT.Caption = bytData(1)
        Else
          lblFlightDirCPT.Caption = "Processing Capt Flight Dir: " & ResultText(dwResult)
        End If
      Else
        lblFlightDirCPT.Caption = "Reading Capt Flight Dir: " & ResultText(dwResult)
      End If
      
      ReDim bytData(2)
      If FSUIPC_Read(&H23B, 2, VarPtr(bytData(1)), dwResult) Then
        If FSUIPC_Process(dwResult) Then
          lblZulu.Caption = Format(bytData(1), "00") & ":" & _
                            Format(bytData(2), "00")
        Else
          lblZulu.Caption = "Processing Zulu time: " & ResultText(dwResult)
        End If
      Else
        lblZulu.Caption = "Reading Zulu time: " & ResultText(dwResult)
      End If
      
      lblCounter.Caption = dwCounter
    End Sub
    I checked that Captain Flight Director is #939, offset 0x93ab. I'm out of ideas.

    Robert
    Last edited by Demon; 08-11-2012 at 04:21 PM. Reason: spelling, added source was FSUIPC VB sample

  2. #2
    25+ Posting Member Demon's Avatar
    Join Date
    Feb 2011
    Location
    Quebec, Canada
    Posts
    42
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How to read data properly in VB6?

    I'll post this in case someone spots the error in my code.

    I started the FSUIPC log and noticed something unusual:

    137860 READ0 F93AB, 1 bytes: 00
    137860 READ0 023B, 2 bytes: 17 12
    137860 READ0 0238, 3 bytes: 13 12 3A


    The offset for Zulu ( 023b ) and FS clock ( 0238 )are normal, but Captain's Flight Director ( 93ab ) has an F prefixed to it?

    I'm guessing the parameter is overflowing or something similar, checking...

    (keep in mind I have basic VB knowledge)


    EDIT: I thought that a hex parameter somehow generated an integer variable and DEC 37803 ( 93ab ) overflowed. So I used a long variable but I still have an F prefix in the FSUIPC IPC read/write log.
    Last edited by Demon; 08-11-2012 at 05:38 PM. Reason: results of using dwOffset as long

  3. #3
    25+ Posting Member Demon's Avatar
    Join Date
    Feb 2011
    Location
    Quebec, Canada
    Posts
    42
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How to read data properly in VB6?

    Cause of problem:

    Computer Number Systems

    lngX = &HFFFF
    The result that is displayed is:FFFFFFFF
    Even though you only assigned a four digit hex value to the variable, Visual Basic extends the hex F digits to the entire variable because it is interpreted at a negative number.


    And that's why FS offsets worked fine but Lekseecon offsets didn't.


    EDIT: Solution, simply use DEC value directly in READ, no need to use an array for single byte variables.

    Code:
    '   &H93AB 37803 Captain Flight Director '
      If FSUIPC_Read(37803, 1, VarPtr(bytData), dwResult) Then
        If FSUIPC_Process(dwResult) Then
          lblFlightDirCPT.Caption = bytData
    ...
    Last edited by Demon; 08-12-2012 at 01:20 AM. Reason: Solution

  4. #4
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,202
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How to read data properly in VB6?

    Quote Originally Posted by Demon View Post
    And that's why FS offsets worked fine but Lekseecon offsets didn't.
    No, no, no, there are no lekseecon offsets... Lekseecon offsets are FSUIPC offsets.

    Note that FSUIPC_Read can read 1, 2, 3, 4 or N bytes, depending on parameter 2. That was the difference in the examples you took (by accident).
    The 'lekseecon FSUIPC offset' you took was just 1 byte while the Zulu and Clock offsets were more then 1 byte. If you read 1 byte you should point to a 1 byte variable, if you read 2 bytes you can point to a WORD variable and so on. Arrays are needed if you read more then 4 bytes.


    I really don't think DEC or HEX had anything to do with it. 37803 (DEC) is exactly the same as &H93AB ...
    Just to be sure it would be good to try: FSUIPC_Read(&H93AB, 1, VarPtr(bytData), dwResult)
    If it fails, I'd forget VB6 forever and switch to C

    But good to see you have it working.

    Question:
    Why did you install lekseecon in FSX/Modules? Note that lekseecon is not a FSX module (and neither is your program). Lekseecon is a separate program running in its own memory space (and not inside FSX). You better uninstall lekseecon and install it in its default installation directory or in DRIVE LETTER:\lekseecon, as indicated in the Manual.
    I'm not sure about the side effects that may happen if you run lekseecon in FSX\Modules. Note that lekseecon loads the LVLDSDK.DLL (being in the lekseecon folder) as it starts. That file should certainly NOT be loaded by FSX...
    Last edited by kiek; 08-12-2012 at 04:40 AM.

  5. #5
    25+ Posting Member Demon's Avatar
    Join Date
    Feb 2011
    Location
    Quebec, Canada
    Posts
    42
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How to read data properly in VB6?

    Ok, I misexplained myself. I meant the new FSUIPC offsets that Pete added for the Level-D SDK that Lekseecon updates. How's that?

    Hex DOES have something to do with it. I was using
    FSUIPC_Read(&H93AB, 1, VarPtr(bytData), dwResult)
    the whole time, assuming any problem was either me not using Lekseecon_f properly, or missing something else in VB6.

    Switching to
    FSUIPC_Read(37803, 1, VarPtr(bytData), dwResult)

    worked right away. You owe me a cookie.

    The FSUIPC log was clear, using a hex offset added a F prefix, using a DEC offset did not (I just double-checked). Read the link I supplied in previous post, the guy explains why an F gets prefixed in VB. It's not about overflowing, it's about negative something something.

    I put Lekseecon and my program in Modules folder because nothing worked (desperation). I have since removed Lekseecon and execute it from it's own installation folder without problems.

    I have to execute my program from within Modules or else IPC cannot connect even if I copy every DLL from FS-X root folder and Module folder into my folder. You probably point to the FS-X module folder in your C++ application, or have it in your PATH, I don't know how to do the equivalent in VB.

    By the way, Yaw dampers and Flight Directors can be read individually:
    Code:
      If FSUIPC_Read(37803, 1, VarPtr(bytData1), dwResult) Then
        If FSUIPC_Read(37804, 1, VarPtr(bytData2), dwResult) Then
          If FSUIPC_Read(37740, 1, VarPtr(bytData3), dwResult) Then
            If FSUIPC_Read(37741, 1, VarPtr(bytData4), dwResult) Then
              If FSUIPC_Process(dwResult) Then
                lblYawDamper.Caption = bytData1 & bytData2 & bytData3 & bytData4
    Or they can be read as consecutive pairs (it might more efficient when accessing a LOT of variables, I don't know, Pete probably would):
    Code:
      If FSUIPC_Read(37803, 2, VarPtr(bytData1(1)), dwResult) Then
        If FSUIPC_Read(37740, 2, VarPtr(bytData2(1)), dwResult) Then
          If FSUIPC_Process(dwResult) Then
            lblYawDamper.Caption = bytData1(1) & bytData1(2) & bytData2(1) & bytData2(2)
    Robert

  6. #6
    25+ Posting Member Demon's Avatar
    Join Date
    Feb 2011
    Location
    Quebec, Canada
    Posts
    42
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How to read data properly in VB6?

    WOOT!

    Phase 1 complete.


  7. #7
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,202
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How to read data properly in VB6?

    Quote Originally Posted by Demon View Post
    Ok, I misexplained myself. I meant the new FSUIPC offsets that Pete added for the Level-D SDK that Lekseecon updates. How's that? t
    Still not completely right Pete has nothing to do with it, except reserving an address space for lekseecon. It is lekseecon that uses these offsets as a sort of mailboxes.

  8. #8
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,202
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How to read data properly in VB6?

    Quote Originally Posted by Demon View Post
    Hex DOES have something to do with it. I was using
    FSUIPC_Read(&H93AB, 1, VarPtr(bytData), dwResult)
    the whole time, assuming any problem was either me not using Lekseecon_f properly, or missing something else in VB6.

    Switching to
    FSUIPC_Read(37803, 1, VarPtr(bytData), dwResult)

    worked right away. You owe me a cookie.
    Unbelievable, what a strange language, I'd certainly stop using VB6

  9. #9
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,202
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How to read data properly in VB6?

    Quote Originally Posted by Demon View Post
    You probably point to the FS-X module folder in your C++ application, or have it in your PATH, I don't know how to do the equivalent in VB.
    Negative. lekseecon only communicates with the Level-D SDK, not with FSX. It looks like the SDK is able to find a FSX or FS9 installation with a Level-D 767.

  10. #10
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,202
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How to read data properly in VB6?

    Quote Originally Posted by Demon View Post
    WOOT!
    Phase 1 complete.
    Congratulations!. You learn fast

    regards,
    Nico