Export Data to from DCSW:FC3 to UDP socket - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 12-04-2015, 12:03 AM   #1
GreyEcho
Junior Member
 
GreyEcho's Avatar
 
Join Date: Dec 2015
Location: Paris, France
Posts: 28
Reputation power: 0
GreyEcho is on a distinguished road
Default Export Data to from DCSW:FC3 to UDP socket

Hello ! Newcomer here !
I own a G940 HOTAS, which I quite like. It does have some leds on the throttle, and I'd love to see them switch on and off depending on what's going on in the simulation.
I play FC3, and the Su27 primarily.

I saw this thread : http://forums.eagle.ru/showthread.ph...highlight=G940
It is a program which listen on UDP port 33331, waiting for some specific commends, and switches the leds accordingly (Red, Green, Amber or Off). The program does work, I tested it with the udp_sender program (which sends strings on UDP localhost 33331)
But the Export.lua provided is old and is designed to work with Black Shark 2.

So I'm trying to write my own Export.lua, and I spent way too much time on it for no result

For the beginning, I'm just trying to have the P6 light green if the left engine RPM is higher than 0, otherwise, light it Amber.

The commends I send to G940leds.exe on UDP localhost 33331 are :
Code:
SetAll=;
SetOneGreen=;
SetOneAmber=;
Hello=
Bye=
My Export.lua so far:
Code:
local default_output_file = nil

function LuaExportStart()
	package.path  = package.path..";"..lfs.currentdir().."/LuaSocket/?.lua"
	package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
	socket = require("socket")
	host = "localhost"
	dstport = "33331"
	c = socket.udp()
	c.setpeername(host,dstport)

	c:send("Hello=DCS WORLD is sending data")
	c:send("SetAll=o;")
end

function LuaExportBeforeNextFrame()
end

function LuaExportAfterNextFrame()
	local EngineInfo = LoGetEngineInfo()
	local MechInfo = LoGetMechInfo()
	local AP = LoGetNavigationInfo()
	local State = LoGetMCPState()

	if(EngineInfo.RPM.left > 65) then c:send("SetOneGreen=6;") else c:send("SetOneAmber=6;") end
end

function LuaExportStop()
	if default_output_file then
		default_output_file:close()
		default_output_file = nil
	end
	c:send("SetAll=o;")
	c:send("Bye=DCS World has stop sending data")
	c:close()
end

function LuaExportActivityNextEvent(t)
	local tNext = t

	return tNext
end
And here are the relevant part of the dcs.log file :
Code:
[...]
00019.960 ERROR   Lua::Config: Call error LuaExportStart:[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:61: bad argument #1 to 'setpeername' (udp{any} expected)
stack traceback:
	[C]: ?
	[C]: in function 'setpeername'
	[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:61: in function <[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:22>.
[...]
00038.082 ERROR   Lua::Config: Call error LuaExportStop:[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:119: calling 'send' on bad self (udp{connected} expected, got userdata)
stack traceback:
	[C]: ?
	[C]: in function 'send'
	[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:119: in function <[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:111>.
[...]
Obviously the lines number don't correspond, but the first problem is this line :
c.setpeername(host,dstport)
and the second one is this one :
c:send("SetAll=o;")

Thank you very much for taking the time to read me and help me !

- GreyEcho
GreyEcho is offline   Reply With Quote
Old 12-10-2015, 12:02 AM   #2
GreyEcho
Junior Member
 
GreyEcho's Avatar
 
Join Date: Dec 2015
Location: Paris, France
Posts: 28
Reputation power: 0
GreyEcho is on a distinguished road
Default

So, for those who are interrested, I solved the problem by changing this line
Code:
c.setpeername(host,dstport)
into this
Code:
c:setpeername(host,dstport)
It seems to work so far, I'll post my full Export.lua when I am done.
__________________
Intel i5-2500k - Gigabyte P67X-UD3-B3 - AMD HD7950 - RAM 12Go - SSD 250Go - Acer FHD Screen - Logitech G940 - TIR5 - FC3 - M-2000C - A-10C


GreyEcho is offline   Reply With Quote
Old 12-10-2015, 06:21 AM   #3
f4l0
Senior Member
 
f4l0's Avatar
 
Join Date: Sep 2014
Location: Germany
Posts: 1,086
Reputation power: 8
f4l0 is a jewel in the roughf4l0 is a jewel in the roughf4l0 is a jewel in the roughf4l0 is a jewel in the roughf4l0 is a jewel in the roughf4l0 is a jewel in the roughf4l0 is a jewel in the rough
Default

Check out https://github.com/jboecker/dcs-export-core . It's a universal interface to access data from DCS!
__________________
f4l0
Developer of Simshaker for Aviators

Feel the brrrrttt:
[Official] SimShaker for Aviators Forums thread at ED forums
SimShaker blog - transfer game effects into the real world
SimShaker Soundmodule with Voicemeeter Banana Setup: http://forums.eagle.ru/showthread.php?p=2469416

DCS Toggle Switches

System specs: Intel Xeon E1231v3@3.4GHz, 32 GB RAM, Nvidia 1070 GTX, lots of SSDs
Flightgear: Oculus Rift, Warthog, MFG Crosswind, Cougar MFDs, Jetseat, Bass shaker
f4l0 is offline   Reply With Quote
Old 12-10-2015, 11:35 AM   #4
GreyEcho
Junior Member
 
GreyEcho's Avatar
 
Join Date: Dec 2015
Location: Paris, France
Posts: 28
Reputation power: 0
GreyEcho is on a distinguished road
Default

This is cool, but I'm gonna have to modify it heavily if I want to use it, cause G940Leds.exe waits for very precise instructions, and not JSON datas.

Or I could write my own program to interface with my G940 Throttle.

Anyway, thanks for the link !
__________________
Intel i5-2500k - Gigabyte P67X-UD3-B3 - AMD HD7950 - RAM 12Go - SSD 250Go - Acer FHD Screen - Logitech G940 - TIR5 - FC3 - M-2000C - A-10C


GreyEcho is offline   Reply With Quote
Old 02-22-2017, 09:52 AM   #5
PVI_Eagle
Member
 
PVI_Eagle's Avatar
 
Join Date: Feb 2010
Location: Italy
Posts: 115
Reputation power: 8
PVI_Eagle is on a distinguished road
Default

This is my export.lua and works fine for G940leds...
Attached Files
File Type: lua Export.lua (17.7 KB, 41 views)
__________________
PVI_Eagle is offline   Reply With Quote
Old 10-15-2017, 10:25 PM   #6
Brainstormer
Junior Member
 
Join Date: Jun 2009
Posts: 12
Reputation power: 0
Brainstormer has a spectacular aura aboutBrainstormer has a spectacular aura aboutBrainstormer has a spectacular aura aboutBrainstormer has a spectacular aura about
Default

Hi,

I just reactivated my G940 after a few years and managed already to get the LED's work for my KA-50. unfortunately it is not exporting the datas while im flying my SU-27. Can someone help me withbit? It would be awesome to use it for the Gear Indicators and maybe AP.

Oh im using DCS 2 mainly atm.

thanks in advance!

Cheers
Brainstormer is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 03:44 AM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.