frank Posted November 21, 2012 Posted November 21, 2012 Hi All Anybody can show me a example "how to" send data (ex. master Caution light) to TCP/UDP - Also an example of sending Input through TCP/UDP like "Master Caution push" to the sim ?? How is the sting send to and from look like ?? Regads Frank http://www.dcscockpit.com
BigfootMSR Posted November 21, 2012 Posted November 21, 2012 Take a look at the input/output thread of the forums. THere are several threads in there that talk about how to create external controllers such as external push buttons that work with game. DCS: A10C Warthog JTAC coordinate entry training mission http://www.digitalcombatsimulator.com/en/files/99424/ DCS: Blackshark 2 interactive training missions http://forums.eagle.ru/showthread.php?t=84612
Waxi Posted November 21, 2012 Posted November 21, 2012 Download and install HELIOS and look at the Export.lua it installs in your DCS folder. That's a good starting point.
SparkyOV Posted November 21, 2012 Posted November 21, 2012 Anybody can show me a example "how to" send data (ex. master Caution light) to TCP/UDP - Also an example of sending Input through TCP/UDP like "Master Caution push" to the sim ?? See Gadroc's Export.lua which is what was the key for my understanding how it all works. Also, see my post on a little bit more detail on how to address each switch in sim. Basically, you will have an app that listens on a UDP port for values from the sim sent by the Export.lua script and can act accordingly (e.g. turn on a master caution light). Then conversely, the script listens for UDP packets in a specific format that will press a button or flip a switch. This last bit is from memory so it may not be 100% accurate: For your specific case of the Master Caution, Export.lua will send you a stream of packets indicating the state of the light (blinking on and off). Something like this: 404=1 404=0 404=1 404=0 etc. (there are some other bits in the string you receive but I can't remember the exact format now). To press the Master Caution button and cancel the warning, you would send UDP packets back to the sim in the form of: C24,3001,1.0 C24,3001,0.0 The Export lua parses that and presses (the 1.0) then releases (the 0.0) the MC button by executing the performClickableAction() function.
frank Posted November 22, 2012 Author Posted November 22, 2012 (edited) Thanks for info - helps alot.... I read over the LUA export side on DCS http://www.digitalcombatsimulator.com/en/dev_journal/lua-export/#act I read your post about clickabledata.lua but where du you se the ID 404 and C24,3001,1.0, is this clickabledata.lua the complete list of the IDs ?? all the best Edited November 22, 2012 by frank http://www.dcscockpit.com
frank Posted November 22, 2012 Author Posted November 22, 2012 I think i got it ;) - it's "arg=403" - can you confirm ? Thanks again Frank http://www.dcscockpit.com
SparkyOV Posted November 22, 2012 Posted November 22, 2012 (edited) Those annunciator values come from "DCS World\Mods\aircrafts\A-10C\Cockpit\Scripts\mainpanel_init.lua" snippet: caution_lamp(404,SystemsSignals.flag_MASTER_WARNING_STUB) -- MASTER WARNING caution_lamp(480,SystemsSignals.flag_ENG_START_CYCLE) -- CAUTION LIGHT PANEL caution_lamp(481,SystemsSignals.flag_L_HYD_PRESS) -- CAUTION LIGHT PANEL caution_lamp(482,SystemsSignals.flag_R_HYD_PRESS) -- CAUTION LIGHT PANEL caution_lamp(483,SystemsSignals.flag_GUN_UNSAFE) -- CAUTION LIGHT PANEL caution_lamp(484,SystemsSignals.flag_ANTISKID) -- CAUTION LIGHT PANEL caution_lamp(485,SystemsSignals.flag_L_HYD_RES) -- CAUTION LIGHT PANEL caution_lamp(486,SystemsSignals.flag_R_HYD_RES) -- CAUTION LIGHT PANELIn the Export.lua, there is an array at the beginning where you define which events you're interested in: gArguments = {[404]="%.1f"}The ProcessMainPanel() function will only execute the SendData() function if the event is listed in that array. Edited November 22, 2012 by SparkyOV
frank Posted November 22, 2012 Author Posted November 22, 2012 Cool Thank.... now i just ned to find out to code a Client in Flowstone - - - - I'll Be Back Frank http://www.dcscockpit.com
frank Posted November 22, 2012 Author Posted November 22, 2012 Ohhh.... I can't seem to find the log file to see what export.lua actualy send... is it a hidden file or what ?? /Frank http://www.dcscockpit.com
SparkyOV Posted November 23, 2012 Posted November 23, 2012 I never got the log file working either. I just wrote a simple UDP listener that dumped what it received to the console.
frank Posted November 23, 2012 Author Posted November 23, 2012 Okay, it's not me then ;) - nice to know Could your share that listener - please ? http://www.dcscockpit.com
frank Posted November 23, 2012 Author Posted November 23, 2012 Okay - i'm in great progress of learning this - thanks so fare - SparkyOV, can you share your .lua files - for more understanding in the way you do it compared to "Gadroc" ?? /Frank http://www.dcscockpit.com
SparkyOV Posted November 23, 2012 Posted November 23, 2012 can you share your .lua files Attached. It is essentially Gadroc's version with only some minor things changed. I.e. I only send the Master Caution light from the main panel.Export.lua
frank Posted November 23, 2012 Author Posted November 23, 2012 I GOT IT ALL RUNNING I CAN NOW CODE MY OWN STUFF...... THANKS FOR ALL THE HELP "love you SparkyOV" http://www.dcscockpit.com
frank Posted November 24, 2012 Author Posted November 24, 2012 Ohhh.... one more question.... Can i send SW-STATE (402=1.0) back to A10C via LUA the same way ? /Frank http://www.dcscockpit.com
SparkyOV Posted November 24, 2012 Posted November 24, 2012 I'm not sure I follow your question... are you asking if you can turn on a warning light? To my knowledge, no...you cannot do that. Gauges and indicator lights are read-only.
frank Posted November 24, 2012 Author Posted November 24, 2012 Sorry if i was not clear, no i want to toggle SW in the sim.... ;) Regards Frank http://www.dcscockpit.com
SparkyOV Posted November 24, 2012 Posted November 24, 2012 (edited) Ah, ok. Please re-read my other post. I explain where to find the codes for switches. Basically you will send a UDP packet back to the sim in the form of: C[device ID],[button ID],[value] E.g. if you wanted to "press and release" the FUNC button on the UFC, you would send: C8,3013,1.0 C8,3013,0.0 E.g. to toggle TGP to ON, you would send: C7,3004,1.0 TGP OFF would be: C7,3004,-1.0 Edited November 24, 2012 by SparkyOV
frank Posted November 28, 2012 Author Posted November 28, 2012 Hi Sir Where is the "3000" comming from... ??? I got the "device_commands.Button_2"..... if it was "device_commands.Button_14" it should be "3014".... right ! But the "3000" ?? /Frank http://www.dcscockpit.com
SparkyOV Posted November 28, 2012 Posted November 28, 2012 (edited) I don't remember where it comes from (I read it in another post when I was researching this) but you are correct: 3000 + 14 = 3014. Edit: this is where I read it (from Gadroc): http://forums.eagle.ru/showpost.php?p=1349672&postcount=42 Edited November 28, 2012 by SparkyOV
frank Posted November 28, 2012 Author Posted November 28, 2012 Thanks.... and this code goes to the buttom of the export.lua ???? --get the device... ahcp = GetDevice(7) --the AHCP device ID --set which switch to manipulate gunpac_switch = 3002 --the GUN/PAC switch ID --set the position you want switch_pos_down = 0.0 --switch down for GUNARM switch_pos_mid = 0.1 --switch middle for SAFE switch_pos_up = 0.2 --switch up for GUN/PAC --perform the actual "click" up to GUN/PAC ahcp:performClickableAction(gunpac_switch, switch_pos_up) --or safe... ahcp:performClickableAction(gunpac_switch, switch_pos_mid) --or down for GUNARM... ahcp:performClickableAction(gunpac_switch, switch_pos_down) http://www.dcscockpit.com
SparkyOV Posted November 28, 2012 Posted November 28, 2012 No no...that was a specific example of how to directly control a toggle using "performClickableAction". The export.lua that I attached earlier is the generic way to toggle any switch via a UDP packet.
Recommended Posts