Archived

This topic is now archived and is closed to further replies.

sikorsky77

button change not detected

Recommended Posts

After a battle with initializing the Pokey Dll device on which i made a post, i found the solution

 

now the lua script loading the dll card seems working

 

the script stored in path .\\modules\linda\libs is called lib-Zpokey56U01  and is loaded with standard libs of Linda

 

here the log 

  2055204 LUA.1: POKEY56U01 Able to create PoKeys Device object
  2055220 LUA.1: POKEY56U01 Start connection in USB mode
  2055251 LUA.1: POKEY56U01 Device number is
  2055282 LUA.1: 1
  2055314 LUA.1: POKEY56U01 mounted and ready to use
  2055360 LUA.1: POKEY56U01 Panel_P5601U Lua Script Called
  2055392 LUA.1: POKEY56U01 Panel_P5601U Script started
  2055438 LUA.1: POKEY56U01 End of Panel_P5601U Main Program
 
i associated Pin 10 of the card to the Battery Switch but nothing change to P3D plane battery Status
moving my toggle switch OFF to ON or ON to OFF has no impact on the aircraft itself
i made a check with the Pokey 56U Software to see if toggle switch react when i move it from OFF to ON and ON to OFF  (to verify Cabling connection) and it is the case 
the software detect OFF/ON position of the switch
 
the Fuction section Panel_P5601U_Script is executed , but the If Test_button did not detect anything
did somebody used Pokey card with lua associated script as this and could help me to understand what are my errors or what i am missing ?
 
below my simple script 
 

thanks for your help and/or ideas

Thierry

-- =================================================================================
-- Initial Setup
-- =================================================================================
require "luacom"
poKeys = luacom.CreateObject('PoKeysDevice_DLL.PoKeysDevice')
 
if poKeys == nil then
  ipc.log("POKEY56U01 Unable to create PoKeys Device object")
  ipc.display("POKEY56U01 Unable to create PoKeys Device object")
  ipc.exit()
else
  ipc.log("POKEY56U01 Able to create PoKeys Device object")
  ipc.display("POKEY56U01 Able to create PoKeys Device object")
end
-- =================================================================================
-- check current physical switch setting and update FSX software switch to match
-- =================================================================================
 
function Panel_P5601U_Script()
  ipc.log("POKEY56U01 Panel_P5601U Script started")
  ipc.display("POKEY56U01 Panel_P5601U Script started")
-- Check pin 10----------------------------------------------------------------------
  if ipc.testbutton(1,10) == true then
    ipc.log("POKEY56U01 Button 10 Battery ON !!")
    ipc.display("POKEY56U01 Button 10 Battery ON !!")
    ipc.writeUD(0x281C, 1) -- toggle switch Battery is ON
   end
  if ipc.testbutton(1,10) == true then
  -- physical switch in ON
    if ipc.readUD(0x281C) == 1 then -- toggle switch Battery is ON
      ipc.control(66241)  -- toggle switch Battery is ON
      ipc.log("POKEY56U01 Button 10 Switch Battery is ON")
      ipc.display("POKEY56U01 Button 10 Switch Battery is ON")
    end
  end
 
  chk_pin_10 = false
  chk_pin_10, onoff_pin_10 = poKeys:GetInput(10)
  if (chk_pin_10 == false) then
    -- GetInput Failed... Most likely not configured properly
    -- Put code here to perform for failure
  else
    -- We got results from the switch GetInput Function
    if (onoff_pin_10 == true) then
      -- Switch at Pin 10 is ON
      -- Put code here you wish FSX to perform
      ipc.writeUD(0x281C, 1) -- set Battery to ON
      ipc.log("POKEY56U01 Button 10 Battery ON !!")
      ipc.display("POKEY56U01 Button 10 Battery ON !!")
    else
      if (onoff_pin_10 == false) then
        -- Switch at Pin 10 is OFF
        -- Put code here you wish FSX to perform
        ipc.writeUD(0x281C, 0) -- set Battery OFF
        ipc.log("POKEY56U01 Button 10 Battery OFF !!")
        ipc.display("POKEY56U01 Button 10 Battery OFF !!")
      else
        -- Could not determine status of Switch at Pin 10
        -- Put code here you wish FSX to perform
      end
    end
  end -- chk_pin_10
 
  ipc.log("POKEY56U01 End of Panel_P5601U Main Program")
  ipc.display("POKEY56U01 End of Panel_P5601U Main Program")
end -- check_switches
 
-- =================================================================================
-- Initial Script Startup
-- =================================================================================
connect_usb = true    -- true = USB  /  false = ethernet
 
if (connect_usb == true) then
  -- Get Number of poKeys Devices Found
  ipc.log("POKEY56U01 Start connection in USB mode")
  ipc.Display("POKEY56U01 Start connection in USB mode")
  no_devices = poKeys:EnumerateDevices()
  ipc.log("POKEY56U01 Device number is")
  ipc.Display("POKEY56U01 Device number is")
  ipc.log(no_devices)
  ipc.display(no_devices)
 
  -- Connect to Device
  if (no_devices ~= 0) then
    connect_flag = poKeys:ConnectToDevice(0)
-- ipc.log(connect_flag)
-- ipc.display(connect_flag)
    if (connect_flag == true) then
      ipc.log("POKEY56U01 mounted and ready to use")
      ipc.display("POKEY56U01 mounted and ready to use")
    else  -- code to perform if ConnectToDevice fails
      ipc.log("POKEY56U01 Unable to connect poKeys USB Device 1")
      ipc.Display("POKEY56U01 Unable to connect poKeys USB Device 1")
 ipc.exit()
end
  else
    ipc.log("POKEY56U01 Device not enumerated")
    ipc.Display("POKEY56U01 Device not enumerated")
    ipc.exit()
  end
 else
  connect_to_ethernet()
  ipc.log("POKEY56U01 Connected in ethernet")
  ipc.Display("POKEY56U01 Connected in ethernet")
  ipc.exit()
end
ipc.log("POKEY56U01 Panel_P5601U Lua Script Called")
ipc.display("POKEY56U01 Panel_P5601U Lua Script Called")
Panel_P5601U_Script()     -- check physical switch and configure fsx software switch
 
-- =================================================================================
-- Event Section
-- =================================================================================
 

 

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!