Jump to content

Recommended Posts

Posted

Hello all, so i have been successful in getting data sent via export lua to an external program written in python. However having difficulty in getting information sent to dcs.

 

 

The sends work ok, but it hangs with any attempt to receive.

Been whacking my head against this wall for a few days.

I've set timeouts to 0, tried no blocking, whatever i do i cannot seem to get data sent to dcs.

 

Any tips or pointers appreciated.

 

Afaik a call of accept() turns the socket into receive mode.

 

 

 

[start Function]
local socket = require("socket")

TcpSocket= socket.try(socket.connect(IPAddress, Port))
TcpSocket:setoption("tcp-nodelay", true)
socket.try(TcpSocket:send("FirstSocketCreated"))



[update]
    socket.try(TcpSocket:send("Ping"))
    
    local client = TcpSock:accept()
    
    client.settimeout(10)
    local data, error = client:receive()
  

Posted
function LuaExportBeforeNextFrame()
rs, err = mysocket:receive('*l')
if (rs ~= nil) then
	_, _, pitch, bank = string.find(rs, "(.+) (.+)")
	LoSetCommand(2001, pitch)
       	LoSetCommand(2002, bank)
       end
end

Posted

Thank's got it working.

For anyone else who may struggle, this is working;

Very simple after all.

 

 

 

 

 

function LuaExportStart()
 
 socket = require("socket")
    
 Sock = socket.try(socket.connect(IPAddress, Port ))
 Sock:setoption("tcp-nodelay", true)
 
 Sock:setoption("keepalive", true)  
 
end


function LuaExportActivityNextEvent(t)
 local tNext = t
 socket.try(Sock:send("Ping"))

 data,err = Sock:receive()
 if data then socket.try(Sock:send(data))
 end
 
 
 tNext = tNext + 5.0
 return tNext
 
 
end


function LuaExportStop()
 
 if Sock then
   Sock.close()
 end

end

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...