GreyEcho Posted December 4, 2015 Share Posted December 4, 2015 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.php?t=45895&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 : SetAll=; SetOneGreen=; SetOneAmber=; Hello= Bye= My Export.lua so far: 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 : [...] 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 Intel i5-2500k - Gigabyte P67X-UD3-B3 - AMD HD7950 - RAM 12Go - SSD 250Go - Acer FHD Screen - Logitech G940 - TIR5 - FC3 - M-2000C - A-10C [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
GreyEcho Posted December 10, 2015 Author Share Posted December 10, 2015 So, for those who are interrested, I solved the problem by changing this line c.setpeername(host,dstport) into this 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 [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
f4l0 Posted December 10, 2015 Share Posted December 10, 2015 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 https://simshaker-for-aviators.github.io/SimShaker-for-Aviators-Releases/ Link to comment Share on other sites More sharing options...
GreyEcho Posted December 10, 2015 Author Share Posted December 10, 2015 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 [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
PVI_Eagle Posted February 22, 2017 Share Posted February 22, 2017 This is my export.lua and works fine for G940leds...Export.lua [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Brainstormer Posted October 15, 2017 Share Posted October 15, 2017 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 Link to comment Share on other sites More sharing options...
Frostregen Posted November 1, 2020 Share Posted November 1, 2020 I set up a repository for this here: https://gitlab.com/frostregenprojects/dcs-g940-leds I started to add basic configurations from what I found in other forum threads. Hope this keeps it alive :-) Greetings, Frostregen Link to comment Share on other sites More sharing options...
Recommended Posts