Jump to content
The simFlight Network Forums

zuby

Members
  • Posts

    39
  • Joined

  • Last visited

Posts posted by zuby

  1. Thank you very much Paul...it's working...Now I'm initializing offsets like below, and grouped offsets.

    private static Offset<float> _AIR_SPEED;
    
            internal static void InitOffsets()
            {
                _AIR_SPEED = new Offset<float>("PMDG", 0x6524);
            }

    also i have question how do i declare left and right Backcourse for reading?
    below is the list of PMDG offsets mapping from pdf. but declaration not mentioned. could guide me. thanks
    6520 4 WORD x 2 MCP_Course[2]

  2. Hello Paul,

    I'm receiving the error, "Communication With FSUIPC Faild  Group ' ' does not exist.", when FSUIPCConnection.Process is called. when i declare offset into PMDG737MCP then program runs well.

    how do i resolve that issue?
    Here is the code below.

    class PMDGOffset {
            
            private static Offset<float> _AIR_SPEED = new Offset<float>(0x6524);
           
    
            public static float AIR_SPEED
            {
                get
                {
                    return _AIR_SPEED.Value;
                }
                set
                {
                    FSUIPCConnection.SendControlToFS(PMDGEvent.EVT_MCP_IAS_SET, (int)value);
                }
            }
    }
    
    class PMDG737MCP
        {
         
            
            public static void Update()
            {
                FSUIPCConnection.Process();
                txt.Text = PMDGOffset.HEADING.ToString();
                
            }  
    }

     

  3. Thanks Pete

    5 minutes ago, Pete Dowson said:

    Nor do I, but I seem to recall that this was a problem with FS dating way back.

    I did not know about that problem. thanks.

    7 minutes ago, Pete Dowson said:

    tell me, did you Arm the A/T and enable Speed Hold first?

    Yes, I armed A/T First then enable Speed Hold.

    9 minutes ago, Pete Dowson said:

    Have you asked in the AVSIM FSX support forum?

    No, could tell me? is there a solution for that problem?

  4. Thanks Pete for your response.

    On 6/24/2018 at 3:24 PM, Pete Dowson said:

    I'm not sure. did you try using FSUIPC's Logging to find out? (Logging tab, enable Event logging then OK out. Operate the button and see what is logged in the FSUIPC LOG file).

    I enabled logging..now i'm receiving 

    *** EVENT: Cntrl= 65860 (0x00010144), Param= 0 (0x00000000) AUTO_THROTTLE_ARM
    *** EVENT: Cntrl= 65891 (0x00010163), Param= 1 (0x00000001) AP_PANEL_SPEED_HOLD
    *** EVENT: Cntrl= 65918 (0x0001017e), Param= 0 (0x00000000) AP_MACH_HOLD

    as you can see in logged, first i turn on AUTO_THROTTLE_ARM, in 2nd line  i press speed hold switch AP_PANEL_SPEED_HOLD, in 3rd i press C/O button. All I did in virtual cockpit by mouse. or without joystick. also C/O button working fine it's changing airspeed display value into decimal point.

    when i assign AP_MACH_HOLD to a joystick's button it does not change airspeed values into decimal point. I don't know why?

    Quote

    All my use of an MCP with the C/O button for many years has been with add-on systems like Project Magenta and, more recently, ProSim. If you are using an add-on aircraft like one of the PMDG ones they will likely have their own subsystems for this.

    I'm not using PMDG add-on.

    Thanks.

  5. Hello Pete,

    On 3/2/2018 at 11:01 PM, Pete Dowson said:

    The GoFlight rotaries, as on their RP48 module, send back "fast" or "slow" codes -- i.e. effectively 4 buttons for each rotary, fast and slow either way. The fast ones are generally used to do things like increment by 10 whilst the slow increment by 1 (for example).

    Is this dual concentric rotary switch? could you attach that rotary pic?

  6. Thanks Pete for guidance.

    now  buttons are working fine I changed while loop limit to 4 in HIDemo.lua as you said.

    On 3/2/2018 at 11:01 PM, Pete Dowson said:

    You can incread the scan frequency (it's an INI file parameter

    could you tell me? which parameter should i change in ini file? 
     

    On 3/2/2018 at 11:01 PM, Pete Dowson said:

    The fast ones are generally used to do things like increment by 10 whilst the slow increment by 1 (for example).

    Ok. it means i need push button rotary that will change incremental value. will rotary encoder also miss some click?

    On 3/2/2018 at 11:01 PM, Pete Dowson said:

    You might like to try using the Lua example "Rotaries.lua", provided in the Examples ZIP.

    thanks Pete I liked this one its working.

    what would you recommend for trim wheel, rotary switch or multi turn pot?

  7. Thanks Pete your gud response.
    I will check to change while loop. then inform you.

    4 hours ago, Pete Dowson said:

    There are no "values" being skipped because it isn't related to values.

    I mean when i attach Ap Spd Inc, from fs control, to rotary switch then rotate rotary knob air speed values do not increment smoothly...means rotary switch's 1 or two detentes pass without changes air speed values. is it rotary switch problem or programming bug?

  8. Thanks Pete for your response.
     

    41 minutes ago, Pete Dowson said:

    128 buttons? I thought with DirectInput that the maximum was 64. Is it a DirectInput joystick device?


    It is 128 buttons HID joystick.

     

    28 minutes ago, Pete Dowson said:

    Well, they are all the same to FSUIPC, just bits in offsets. You'll need to look at your hardware of whatever program you have writing to FSUIPC.

    Im using hiddemo.lua program. my joystick buttons matrix is 8x16. will the below program work fine with 8x16 matrix.
     

    Vendor = 0x03EB
    Product = 0x2043
    Device = 0 
    Report = 0
    Pollrate = 25
    
    
    dev, rd, wrf, wr, init = com.openhid(Vendor, Product, Device, Report)
    
    if dev == 0 then
       ipc.log("Could not open HID")
       ipc.exit()
    end
    
    buttons = {}
    -- Up to 256 buttons = 8 x 32 bit words
    prevbuttons = { 0, 0, 0, 0, 0, 0, 0, 0 }
    
    
    function Poll(time)
    -- We use "readlast" so the values we use are the most up-to-date
      CurrentData, n, discards = com.readlast(dev, rd)
    -- Extract values we need
      if n ~= 0 then
    -- Now handle the buttons : up to 256 of them!
      	  buttons[1], buttons[2], buttons[3], buttons[4],
      	  buttons[5], buttons[6], buttons[7], buttons[8] = 
      	  	com.GetHidButtons(dev, CurrentData)
      	  	
      	  -- check for changes   
        	i = 1
        	while i <= 8 do
        	    if buttons[i] ~= prevbuttons[i] then
        	        prevbuttons[i] = buttons[i]
        	        -- Send to FSUIPC as a set of 32 virtual buttons
        	        -- i.e. DWORD offsets 3340 onwards
        	        ipc.writeUD(0x3340 + ((i-1) * 4), buttons[i])
        	    end
        	    i = i + 1
    		end
    	end
    end
    
    ------------------------------------------------------------------------
    
    if init then
       -- Deal with initial values, if supplied (some joysticks don't)
       ipc.log("init seen!")
       Poll(0)
    end
    
    if Pollrate == 0 then
       -- Ouch. Mustn't divide by zero!
       Pollrate = 25 
    end
    
    
    event.timer(1000/Pollrate, "Poll")  -- poll values 'Pollrate' times per second
    37 minutes ago, Pete Dowson said:

    Is it an encoding rotary, pulsing one or the other buttons according to direction, or one which pulses both all the time but with different phasing to differentiate the direction?

    it is a rotary switch here its diagram.
    SRBM_C_4.GIF

  9. Hello Pete,
    I made 8 axes and 128 buttons joystick. when i connect joystick it shows joy# 64 to 71 in fsuipc buttons/switches tab. is it normal?
    the joystick 0-31 buttons is working fine. but 32 to 127 is responding very slow. i don't know why?

    and rotary pulse switch is also skipping some values.  i'm connecting a rotary on two buttons. pls guide me.

    thanks 

     

  10. Hello Pete,

    Finally the below lua code is working now :). but "str = string.char(0,49)" char function's first argument must be 0 I dont know why? it does not work when i remove 0. and also guide me where should i use com.close(handle)? because i will use com.write function into offset event. if i use com.close after event then i need to reopen hid device.
    Under of Thanks for your help and time.

    local USB_DEVICE_VID = 0x1234
    local USB_DEVICE_PID = 0x0001
    
    Device = 0  -- Multiple devices of the same name need increasing Device numbers.
    
    
    Logging = false
    
    
    
    Report = 0  -- I *think* all joystick types use Input Report 0
    
    dev, rd, wrf, wr, init = com.openhid(USB_DEVICE_VID, USB_DEVICE_PID, Device, Report)
    if dev == 0 then
       ipc.log("Could not open HID")
       ipc.exit()
    end
    
    
    
    local str = ""
    str = string.char(0,49)
    n = com.write(dev,str)
    ipc.log("return value = " .. n)  	  	  		
    
    
    com.close(dev)

     

  11. it means the code below is right for hid device?
     

    Vendor = 0x1234 
    Product = 0x0001 
    Device = 0 
    Report = 0 
    
    dev, rd, wrf, wr, init = com.openhid(Vendor, Product, Device, Report) 
    
    if dev == 0 then    
    ipc.log("Could not open HID")    
    ipc.exit() 
    end -- Finish HID Connect 
    
    function call_speed (offset, value)              
    com.write(dev,tostring(value), wr)      
    end 
    
    event.offset (0x07E2, "UW", "call_speed") -- aircraft speed

     

  12. 11 hours ago, Pete Dowson said:

    Sorry, why would I want that?

    The purpose to show this library is that you can understand my problem easily...there is a proper documentation for luahidapi.
     
    Whereas how to use com.write with HID, there is no example file or documentation to use that function.
     

    Could you give me HID code example for com.write. or how do i use com.write for HID?

    11 hours ago, Pete Dowson said:

    This site: http://pcidatabase.com/vendors.php?sort=id lists your 0x1234 as being ownded by "Technical Corp". Is that right?

    yes the id ownded by "Technical Corp" but I'm using default HID example program (that has 0x1234 VID) of mikroc.

    Thanks for your reply.

  13. Thanks Pete for your response.
     

    2 hours ago, Pete Dowson said:

    No. HID ports are, like all USB ports, are treated like COM in the Windows API for reading and writing, but the port name is much more complicated than that, and obtained by reference to the PID and VID values you need to program in your Lua when using OpenHID.

    I did not know that. thanks for your information.

    2 hours ago, Pete Dowson said:

    And don't you have to supply such information for that?

    Here is the luahidapi library link: https://github.com/ynezz/luahidapi 

    here is the working code of luahidapi...I copied luahidapi.dll into "Modules/lua", also copied hidapi.dll  and lua51.dll into "Modules/dll" folder

    local hid = require "luahidapi"
    
    
    local sfmt, sbyte, schar, srep = string.format, string.byte, string.char, string.rep
    ------------------------------------------------------------------------
    -- initialize
    ------------------------------------------------------------------------
    
    if not hid.init() then
      print("hid library: init error")
      return
    end
    
    
    --====================================================================--
    --** WARNING: Test uses Microchip's VID and a PID from MPLAB tools'  **
    --** PID range. DO NOT use outside of a laboratory/personal setting. **
    --====================================================================--
    
    local USB_DEVICE_VID = 0x1234
    local USB_DEVICE_PID = 0x0001
    
    local USB_REPORT_SIZE = 64
    
    local dev = hid.open(USB_DEVICE_VID, USB_DEVICE_PID)
    if not dev then
      print("Open: unable to open test device")
      return
    end
    
    function addpadding(str)
       local length = string.len(str)
          
       for i=length, 7 do
    		str = str .. " "	
       end
       return str;
    end 
    
    function call_speed (offset, value)
     
      local tx = ""
      tx = tx .. tostring(value);
      hidwrite(tx)  
    	
    end
    
    function hidwrite (buffer)
      buffer = addpadding(buffer)
      buffer = srep(buffer, USB_REPORT_SIZE / 8)
      local res = dev:write(buffer)
      if not res then
        print("Unable to write()")
        print("Error: "..dev:error())
        return
      end  
    end
    
    
    -- FSX events
    event.offset (0x07E2, "UW", "call_speed") -- aircraft speed

    after that I read that air speed value into joystick code (that i wrote in mikroc) and display that value to 7 segment LED.

    2 hours ago, Pete Dowson said:

    4660 is hex 0x1234 which seems an very unlikely VID. And a PID of 0x0001 is even more unusual. Are you sure you have those correct? Where are you getting them from?

    yes those are correct. getting from to run a program named "hid scanner.exe"

    2 hours ago, Pete Dowson said:

    Why would I need that information?

    I was thinking that com.write works like luahidapi.

    besides above conversation could you guide me?
    How do i display air speed value to 7 segment LED without serial communication?

×
×
  • 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.