Sign in to follow this  
jazzmanPL

Lua error SLX_G1000.lua

Recommended Posts

Helo Maarten,

 

There's some coding error in SL_G1000.lua in line 26 (missing bracket ')' ):

 

-- "Slave Server" example LUA plug-in, by Pete Dowson, October 2009
-- To make the Server FS act as a slave, following the Client FS acting as Master
 
-- The SOCKET module is built into FSUIPC, but is not active until "required"
local socket = require("socket")
 
-- Set the host name to the name of the PC running this Server
local host = "localhost"
 
-- The port must match the port selected in the client and not clash with others.
local port = "34568"
 
 
local function processdata(data)
-- decode string, format is lvarname,lvarvalue,isstring (0 or 1)
local index1 = 1
local index2 = string.find(data, ",")
local lvarname = string.sub(data, index1, index2 - 1)
index1 = index2 + 1
index2 = string.find(data, ",", index1)
local lvarvalue = string.sub(data, index1, index2 - 1)
local lvarisstring = string.sub(data, index2 + 1)
 
if lvarisstring == "1" then
for i = 1, 6 do
if (string.len(lvarvalue) >= i then             ////here exactly - error when parsing///
ipc.writeLvar("SLX_StringValue" .. i, string.byte(lvarvalue, i)
else
ipc.writeLvar("SLX_StringValue" .. i, 0)
end
end
else
ipc.writeLvar("SLX_" .. lvarname, tonumber(lvarvalue))
end
ipc.writeLvar("SLX_" .. lvarname .. "_Set", 1)
end
 
local server = assert(socket.bind(host, port))
local ack = "<EOF>"
while 1 do
    print("slx_fs9gps_server: waiting for client connection...")
    local control
if (server ~= nil)
control = server:accept()
else
control = nil
    if control ~= nil then
print("slx_fs9gps_server: client connected!")
while 1 do 
local data = control:receive()
if data == nil then
print("slx_fs9gps_server: client disconnected")
-- ipc.control(65794) -- Pause FS
break
end
else
local index = string.find(data, "<EOF>")
if index ~= nill then 
data = string.sub(data, 1, index - 1)
if data == "ping" then
assert(control:send("ping<EOF>"))
else
assert(control:send(ack))      
processdata(data)
end
end
end
end
    end
end
 

Best wishes,

Darek

 

Share this post


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

Hi Darek,

 

Well spotted! Fortunately this .lua file is not yet used. Some GPS variables are missing in the SimConnect API and I will use this .lua file (together with the SLX_G1000.CAB gauge) to workaround this issue when I have made some more progress with the implementation of the G1000 PFD and MFD.

 

thanks, Maarten

Share this post


Link to post
Share on other sites

Sounds clear for me :)

 

You're doing a fantastic job. Thanks for Your tremendous work, I really appreciate that a lot.

 

All the best,

Darek 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this