Jump to content
The simFlight Network Forums

dru5412

Members
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About dru5412

  • Rank
    Newbie

Profile Information

  • Gender
    Male
  • Location
    UK
  1. To be frank, im starting to ask myself that same question.... This is as much a learning exercise for me as it is to build next cockpit panel. Reading now the Com library, i am thinking I might switch to that rather than ethernet and sockets... Anyway, will keep going just to prove to myself it works... And thanks for the tips, i will rethink the way the socket waits for the connection. and also receives data. either via timer or poll or something else i find on google...
  2. dru5412

    Lua Socket 64 FSUIPC 5

    Yeap, User Error. My fault...
  3. Thanks Pete. Knew it was going to be obvious! I had worked my way through the code, but resorted to posting here 1 step too early! p.s. The register event is only called once from the Arduino at time of the client socket registration. Done this so that I can have multiple boards, each one with its only set of offsets/lvars associated. Just need to work out how to trigger a function when client:receive(); event.com wont work as i am talking to the arduino over TCPIP via sockets not a com port. (if i understand this correctly) Thanks for the help will go and learn some more lua! Regards Andrew
  4. Hmmm ok. So I hardcoded 023A offset to test, and nothing seems to be happening. function OnOffsetModified(offset, value) local cmd = string.format("EVENT_OFFSET %x %d", offset, value) print(string.format("ArduPilot Offset:OBS_OFFSET ",cmd)) assert(client:send(cmd .. ack)); end local function ProcessObserveOffset( offset, oft) print(string.format("ArduPilot Register:OBS_OFFSET 0x%x:%s", offset, oft)) -- event.offset(offset, oft, "OnOffsetModified") event.offset(0x023A, "UB", "OnOffsetModified") print("logged") end From this I would expect to see the log showing ArduPilot Offset:OBS_OFFSET EVENT_OFFSET 0x023A <sec> But it just stops after the print "logged", which i added just to debug to make sure it wasnt getting stuck on the event.offset line above. Just a thought, as im no Lua expert at all.. (in fact a beginner) I have a while 1 routine running at the bottom of the lua code, which is listening and then parsing the incoming data, this wouldnt be blocking would it? while 1 do print("ArduPilot: waiting for client connection..."); local client = server:accept(); client:setoption("tcp-nodelay", true); if client ~= nil then print("ArduPilot: client connected!"); while 1 do local command, err = client:receive(); if not err then if command == bye then print("ArduPilot: client disconnected"); client:close(); break; elseif command == hello then print ("ArduPilot: replying Hello"); assert(client:send(hello .. ack)); else print("ArduPilot: Received: "); print(command); OnDataReceived(command); assert(client:send(ack)); end else print("ArduPilot: client error, probably disconnected"); client:close(); break; end end end end onDataReceived(command) is the data parser as described before. May just try stripping this back to simple lua test. event.offset callback that just has print function and remove the local socket = require("socket"); just in case its something strange happening there Below is the Log extract. 4094 LUA.2: AruPilot: waiting for client connection... 8797 C:\Program Files\Lockheed Martin\Prepar3D v4\SimObjects\Airplanes\PMDG 737-800NGX WL\B737-800WL.air 8797 PMDG 737 offsets enabled 55109 Aircraft loaded: running normally now ... 55125 User Aircraft ID 1 supplied, now being used 55938 System time = 20/11/2017 15:48:30, Simulator time = 15:47:40 (15:47Z) 55938 Aircraft="PMDG 737-800NGX PMDG House Winglets" 62938 Starting everything now ... 64109 Advanced Weather Interface Enabled 74609 LUA.2: AruPilot: client connected! 74625 LUA.2: AruPilot: replying Hello 74625 LUA.2: AruPilot: Received: 74625 LUA.2: OBS_OFFSET 0x023A:UB 74625 LUA.2: ArduPilot Register:OBS_OFFSET 0x23a:UB 74625 LUA.2: logged
  5. dru5412

    Lua Socket 64 FSUIPC 5

    Well all i can say is for me, i downloaded the lua and core.dll as described and seemed to work without needing any other change.. When I say worked ( i can open socket and communicate over it) but have the other issue with event.offset, but hopefully totally unrelated.
  6. 64-bit, I downloaded the core.dll shown on another topic on this forum. Seems to remove all the Lua error on loading, and can open a valid socket to talk to my ethernet arduino. No, but will try that now. and report back. I tried with offset for "battery master" on default p3d model (non pdmg) but will try 023A as suggested It comes another function, which is parsing what it receives over the socket from the arduino. Extract below: local cmd, offset, len = string.match(data, "(OBS_OFFSET) (0x%x+):(%a+)") if cmd then return { action = cmd, offset = tonumber(offset, 16), length = len } end Basically i am trying to program some common functions so that the arduino can do 4 main things 1. Register and open a socket connect 2. Register which Offset or Lvars to be updated on 3. Receive updates from event.offset call back (or event.lvars callback) 4. all linked to hardware items. (buttons, switches, rotary, lcd, led, etc) So there is data posted from the arduino in the format "OBS_OFFSET 0x64F6:UW" This is then pattern matched with the above parse code, to write the event.offset function. OK, then this might just be User Error on the offset or something, again let me test this and get the log if it is relevant, but suspect it was typo in my code... Post again shortly after testing 023A:UB thanks
  7. dru5412

    Lua Socket 64 FSUIPC 5

    I just used local socket = require("socket"); and it seems to be working for me.
  8. Hello, Hoping this is something simple but i am now stuck after several days trying to work this out.. So... I have registered version of FSUIPC5 installed, with the updated socket/core.dll for 64 bit. (all working) Created the Lua script to set up the server connection (working), can register my client and send "hello" ack back to the client. As the socket client I have an ethernet arduino connected to my lan, this calls the server and registers an "event.offset" But... No matter what offset I listen to, i do not seem to be getting anything sent to the call back function on the offset change. Airplane is the PDMG 737, but as a test I tried a simple offset to check updates were working. and they are not. So in Lua, via a socket read function, executes: local function ProcessObserveOffset( offset, oft) print(string.format("ArduPilot Register:OBS_OFFSET %x:%s", offset, oft)) event.offset(offset, oft, "OnOffsetModified") print("logged") end even tried just hardcode line in Lua to register the event. event.offset(0x64f6, "UW", "OnOffsetModified") I get no response in the logging window when this is run, but also don't see any errors, I changed the UW to SB to check and do get an error telling me type or size is wrong. So assuming it is processing the event.offset command. But callbackfunc is never called. If i Monitor this using the FSUIPC addon logging to Sim Connect Window in P3D, i can see the value changing 0:1 when I flip the switch in the cockpit. But again the event.offset callbackfunc is not run. So either the event.offset registration is not working correctly or the event.offset is not triggered and calling the callbackfunc... Any advice welcome to save the last of my hair being pulled out... Thanks Andrew
×

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.