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