Jump to content

[MOD] DCS-to-GPS


Holton181

Recommended Posts

!!! CURRENT VERSION IS 1.4 !!!

 

~~~~~ NOW WITH AHRS SUPPORT!!! ~~~~~

That means native suport for:

ForeFlight

SkyDemon

WingX Pro

FltPlan Go

and possibly may more!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

Hi there,

For anyone interested I put together a script to export GPS NMEA or AHRS sentences to be used with any application or device capable of using them.

UDP or Serial Port export is available.

 

https://www.digitalcombatsimulator.com/en/files/3303310/

 

In Nevada the game and reality correlate almost perfectly, more or less spot on for all outer most airdromes. Normandy was a bit tricky due to being a -44 map, but using pronounced land features like docks and some characteristic buildings, the correlation is within 50m (165ft), often less. I now own PG and have tested it a bit but not extensively, it looks good so far. Not very correct positioning on real world maps for Caucasus though. If I ever find good DCS to Real world coordinate converting formulas for Caucasus I might update this with it. Another possibility is that the airdromes I have tested with isn't placed 100% correctly in DCS Caucasus relative real world, but nothing I can know for sure.

 

 

************** A little Heads up! *************

If you use SRS (DCS-SimpleRadioStandalone), make sure the line in Export.lua related to SRS comes AFTER the one for DCS-to-GPS. It won't work otherwise.

Thanks to Drakoz for this solution (post #71). Have been verified by myself.

*****************************************

 

 

Here is an excellent tutorial video by Roman_Actual (aka "Basic to Final" @ YT)

(in the video both NMEA and AHRS over UDP are activated. For ForeFlight and similar applications handling AHRS, only the AHRS over UDP is needed. The NMEA is used for real GPS devises or spoofing the GPS on a phone/tablet. The NMEA over serial port (COM) is the same as for over UDP, just another protocol option)

 

An example of ILS approach with ForeFlight, using DCS-to-GPS, same creator as above

 

 

Thanks Roman_Actual for these excellent videos!

 

 

Have fun!

/H


Edited by Holton181
new version

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

I already asked you the question on the other thread but this would work with Foreflight on iPad?

Also, I would have though that the new maps are actually more accurate vs IRL than Caucasus. Do you see a massive difference in position? Is it usable for helicopter operations?

 

And I have given you an answer there too now. But for others, yes I believe it would work for any maping tool on any iPhone, iPad, Android, Windows Mobile e.t.c. As long as you have an app to receive the information and feed it to the GPS, overriding real positioning.

 

I actually haven't tested it thoroughly on Nevada and Normandy (I don't own PG). I fly mainly helicopters myself, and unfortunately I believe it's to rough to be really usable. I started this project long ago but didn't put it in a shareable state until now. And I actually haven't start using it much myself yet.

But try it out and make up your own mind. Please share your experience here. I would be happy to see whether anyone find it useful or not.

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

I could just imagine how cool it would be to buzz around DCS in the Huey with my iPad/kneeboard strapped to my leg, running Foreflight, just like I do in P3D. Pardon the pun but I think you are on to a game changer here. I can see this really helping with SA as it gets more and more fleshed out. Keep up the good work!

i7-7700K @ 5.2Ghz

SLI 1080Ti

64GB GSkill Trident Z RGB 4133

Asus Maximus IX Extreme

Custom Water Cooling Loop

TM Warthog/ MFG Crosswind

Link to comment
Share on other sites

Hi,

 

Prob to connect with UDP method :

 

Android 7.0

Windows 7 64bit

Mock location is active for GPSBridge in developpement setting

DCS OB 2.5.4

No prob with my firewall, have open UDP 8080 port on my router

Connection method : wifi

 

 

DCS_NMEA.lua

 

UDP Part 1

 

my_init = socket.protect(function()
	host2, port2 = "192.168.1.11", 8080 --4353 -- replace IP with android device ip 
	udp = socket.try(socket.udp())	
end)
my_init()	

 

UDP Part 2

 

my_send = socket.protect(function()
	local json = string.format("$%s*%x\r\n$%s*%x\r\n", GGA,csGGA,RMC,csRMC)
	socket.try(udp:sendto(json, host2, port2))
	end)
my_send()

 

UDP Part 3

 

my_close = socket.protect(function()
	socket.try(udp:close())
end)
my_close()

 

 

Export.lua (at the bottom)

 

userprofile = os.getenv ("userprofile"):gsub("\\","/")
dofile(userprofile .. "/Saved Games/DCS/Scripts/DCS_NMEA.lua")

 

 

GPSBridge setting

 

Protocol : UDP

TCP/UDP port : 8080

TCP adress : will attempt to connect to

 

 

 

Thank's again for your help.

 

++


Edited by Ex Machina
Link to comment
Share on other sites

DCS OB 2.5.4

...

Export.lua (at the bottom)

userprofile = os.getenv ("userprofile"):gsub("\\","/")
dofile(userprofile .. "/Saved Games/DCS/Scripts/DCS_NMEA.lua")

...

You say you have OB, but your path in the Export.lua i /DCS/. Is that correct? you don't have /DCS.openbeta/?

Can you please provide your entire DCS_NMEA.lua, thanks.

 

Have you tried the file writing part? Starting at line 71, 216 and 252, check path on line 73. Try it an see if you get anything in it just to rule it out.

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

I have done some more testing in Nevada and Normandy. In Nevada the game and reality correlate almost perfectly, more or less spot on for all outer most airdromes. Normandy was a bit tricky due to being a -44 map, but using pronounced land features like docks and some characteristic buildings, the correlation is within 50m (165ft), often less. I don't own PG so I can't test it, for anyone getting this MOD to work and owning the PG please feel free to test the correlation for some locations close to the outer edges of the detailed area and report below.

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

Hello Holton,

 

Originally it is a "realease" version that I modified in open beta via the DOS command, the name of the folder is DCS. Thank you again for your help.

 

My complet DCS_NMEA.lua

 

---------------------------------------------------------------------------------------------------
-- Export start 
---------------------------------------------------------------------------------------------------

dofile("./Config/World/World.lua")				-- Required to get mission date


DCS_NMEA =
{
Start=function(self) 
package.path = package.path..";.\\LuaSocket\\?.lua"
package.cpath = package.cpath..";.\\LuaSocket\\?.dll"
socket = require("socket")

----------------------------------------------------------------------------------------------------------------------------------------------
-- COMMUNICATIONS - Part 1
----------------------------------------------------------------------------------------------------------------------------------------------

-- For UDP and Serial Port there are three sections each to activate or deactivate depending on what method you like to use to connect.
-- One here in the Start() function, below. The second in the end of ActivityNextEvent() function. The third in the Stop() function.

-- UDP -----------------------------------------------------------------------------------------------------------------------------------
-- Use this to connect via UDP. Change IP to the devise you want to use. Alternatively the port too. Use the same port in your GPS device.

---[[To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
my_init = socket.protect(function()
	host2, port2 = "192.168.1.11", 8080 --4353 -- replace IP with android device ip 
	udp = socket.try(socket.udp())	
end)
my_init()	
	
--]]

-- Serial Port ---------------------------------------------------------------------------------------------------------------------------
-- Use this to connect via Serial Port. Change COM Nr to the port you want to use.
-- One way to use this is by Bluetooth Virtual Serial Port to connect to a Bluetooth compatible device.
-- If Bluetooth is used, be aware that DCS will freeze as long as the used device isn't listening to the port. As soon as it listen, DCS will un-freeze.
-- I do not know if this freezing behavior exist when a physical serial port is used, since I one have one to test.
-- Remember to comment out the "dofile" line related to this MOD in Export.lua or all Serial Port sections in this file if you are not going to use it to avoid freezing.

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
sPort = "COM1"
com = io.open(sPort,"w+b")
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------

-- Create a TXT file for debugging or a NMEA log or whatever
-- Same as for the communication options, need to be activated or de-activated at three locations, all located below corresponding communication section.
-- Remember to adjust the path below to DCS or DCS.openbeta or whatever path you have to your Saved Games section.

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
Test_file = os.getenv ("userprofile"):gsub("\\","/") .. "/Saved Games/DCS/Scripts/NMEA_Test.txt"
--Test_file = os.getenv ("userprofile"):gsub("\\","/") .. "/Saved Games/DCS.openbeta/Scripts/NMEA_Test.txt"
file = io.open(Test_file, "w")
--file:write(string.format("%s\r\n",Test_file))
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------

xortbl = {
       { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, },
       { 1,  0,  3,  2,  5,  4,  7,  6,  9,  8, 11, 10, 13, 12, 15, 14, },
       { 2,  3,  0,  1,  6,  7,  4,  5, 10, 11,  8,  9, 14, 15, 12, 13, },
       { 3,  2,  1,  0,  7,  6,  5,  4, 11, 10,  9,  8, 15, 14, 13, 12, },
       { 4,  5,  6,  7,  0,  1,  2,  3, 12, 13, 14, 15,  8,  9, 10, 11, },
       { 5,  4,  7,  6,  1,  0,  3,  2, 13, 12, 15, 14,  9,  8, 11, 10, },
       { 6,  7,  4,  5,  2,  3,  0,  1, 14, 15, 12, 13, 10, 11,  8,  9, },
       { 7,  6,  5,  4,  3,  2,  1,  0, 15, 14, 13, 12, 11, 10,  9,  8, },
       { 8,  9, 10, 11, 12, 13, 14, 15,  0,  1,  2,  3,  4,  5,  6,  7, },
       { 9,  8, 11, 10, 13, 12, 15, 14,  1,  0,  3,  2,  5,  4,  7,  6, },
       {10, 11,  8,  9, 14, 15, 12, 13,  2,  3,  0,  1,  6,  7,  4,  5, },
       {11, 10,  9,  8, 15, 14, 13, 12,  3,  2,  1,  0,  7,  6,  5,  4, },
       {12, 13, 14, 15,  8,  9, 10, 11,  4,  5,  6,  7,  0,  1,  2,  3, },
       {13, 12, 15, 14,  9,  8, 11, 10,  5,  4,  7,  6,  1,  0,  3,  2, },
       {14, 15, 12, 13, 10, 11,  8,  9,  6,  7,  4,  5,  2,  3,  0,  1, },
       {15, 14, 13, 12, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1,  0, },
   }
	
end,

ActivityNextEvent=function(self,t)
--LoGetSelfData return the same result as LoGetObjectById but only for your aircraft and not depended on anti-cheat setting in Export/Config.lua
--Returned object table structure:
--{ 
	--Name = 
	--Type =  {level1,level2,level3,level4},  ( see Scripts/database/wsTypes.lua) Subtype is absent  now
	--Country   =   number ( see Scripts/database/db_countries.lua
	--Coalition = 
	--CoalitionID = number ( 1 or 2 )
	--LatLongAlt = { Lat = , Long = , Alt = }
	--Heading =   radians
	--Pitch      =   radians
	--Bank      =  radians
	--Position = {x,y,z} -- in internal DCS coordinate system ( see convertion routnes below)
	-- only for units ( Planes,Hellicopters,Tanks etc)
	--UnitName    = unit name from mission (UTF8)  
	--GroupName = unit name from mission (UTF8)	
--}
local tNext = t
local year = MissionDate.Year
local month = MissionDate.Month
local day = MissionDate.Day
local pt = LoGetMissionStartTime()+LoGetModelTime()
local h = pt/3600
local hh = math.floor(h)
local m = (h-hh)*60
local mm = math.floor(m)
local s = (m-mm)*60

local SD = LoGetSelfData
local Lat = SD().LatLongAlt.Lat
local Long = SD().LatLongAlt.Long
local Alt = SD().LatLongAlt.Alt
local Velocity = LoGetVectorVelocity()  --{x,y,z}
local VX = Velocity.x
local VY = Velocity.y
local VZ = Velocity.z
local Speed = math.sqrt(VX*VX+VZ*VZ)*1.9438444924574 -- Speed from m/s to knot 

-- Course calculations 
if VX==0 and VZ==0 then
	radTC = 0
else
	radTC = math.atan2(VZ,VX)
	if radTC < 0 then
		radTC = 2*math.pi + radTC
	end
end
TC = radTC*180/math.pi

-- Coordinates from decimal degrees to degrees and decimal minutes
local dLat = math.floor(math.abs(Lat))
local dLong = math.floor(math.abs(Long))
local mLat = (math.abs(Lat)-dLat)*60
local mLong = (math.abs(Long)-dLong)*60

-- Cardinal directions
local sigLat = Lat/math.abs(Lat)
local sigLong = Long/math.abs(Long)

if sigLat<0 then NS='S'
else NS='N'
end

if sigLong<0 then EW='W'
else EW='E'
end

-- Various unimportant GPS values for the GGA sentence not derivable from game
local Q = 1
local nSat = 5
local HDOP = 1.3
local GeoSep = 00.0

-- GGA sentence
local GGA = string.format("GPGGA,%02d%02d%05.2f,%02d%010.7f,%s,%03d%0010.7f,%s,%1d,%02d,%03.1f,%06.1f,M,%04.0f,M,,", hh,mm,s,dLat,mLat,NS,dLong,mLong,EW,Q,nSat,HDOP,Alt,GeoSep)
local csGGA = 0
for c in string.gmatch(GGA,".") do
	csGGA = bxor(csGGA, string.byte(c))
end

-- RMC sentence
local RMC = string.format("GPRMC,%02d%02d%05.2f,A,%02d%010.7f,%s,%03d%0010.7f,%s,%05.1f,%05.1f,%02d%02d%02d,0,E,A", hh,mm,s,dLat,mLat,NS,dLong,mLong,EW,Speed,TC,day,month,string.sub(year,3,4))
local csRMC = 0
for c in string.gmatch(RMC,".") do
	csRMC = bxor(csRMC, string.byte(c))
end


----------------------------------------------------------------------------------------------------------------------------------------------
-- COMMUNICATIONS - Part 2
----------------------------------------------------------------------------------------------------------------------------------------------

-- UDP -----------------------------------------------------------------------------------------------------------------------------------

---[[		To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.	
my_send = socket.protect(function()
	local json = string.format("$%s*%x\r\n$%s*%x\r\n", GGA,csGGA,RMC,csRMC)
	socket.try(udp:sendto(json, host2, port2))
	end)
my_send()

--]]

-- Serial Port ---------------------------------------------------------------------------------------------------------------------------

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
com:write(string.format("$%s*%x\r\n$%s*%x\r\n", GGA,csGGA,RMC,csRMC)) -- fills the serial buffer
com:flush() -- send the serial buffer
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
file:write(string.format("$%s*%x\t$%s*%x\r\n", GGA,csGGA,RMC,csRMC))
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------
	
-- Repeat every 0.5s
return tNext + 0.5
end,

Stop=function(self)

----------------------------------------------------------------------------------------------------------------------------------------------
-- COMMUNICATIONS - Part 3
----------------------------------------------------------------------------------------------------------------------------------------------

-- UDP -----------------------------------------------------------------------------------------------------------------------------------

---[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
my_close = socket.protect(function()
	socket.try(udp:close())
end)
my_close()

--]]

-- Serial Port ---------------------------------------------------------------------------------------------------------------------------

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
com:close(sPort)
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
file:close()

--]]
----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------
	
end
}

--[[ Perform a bitwise Exclusive OR (XOR) ]]--
function bxor(a,b)
   local res, mult = 0, 1
   while a > 0 and b > 0 do
       local a2, b2 = a % 16, b % 16
       res = res + xortbl[a2+1][b2+1] * mult
       a = (a-a2) / 16
       b = (b-b2) / 16
       mult = mult * 16
   end
   res = res + (a+b) * mult
   return res
end

-- =============
-- Overload
-- =============
do
local PrevLuaExportStart=LuaExportStart
LuaExportStart=function()
	DCS_NMEA:Start()
	if PrevLuaExportStart then
		PrevLuaExportStart()
	end
end
end

do
local PrevLuaExportActivityNextEvent=LuaExportActivityNextEvent
LuaExportActivityNextEvent=function(t)
	local tNext = t
	tNext = DCS_NMEA:ActivityNextEvent(t)
	if PrevLuaExportActivityNextEvent then
		PrevLuaExportActivityNextEvent()
	end
	return tNext
end
end

do
local PrevLuaExportStop=LuaExportStop
LuaExportStop=function()
	DCS_NMEA:Stop()
	if PrevLuaExportStop then
		PrevLuaExportStop()
	end
end
end

 

 

DCS.log

 

2019-02-03 20:00:04.100 ERROR   Lua::Config: Call error LuaExportActivityNextEvent:[string "C:/Users/Stef/Saved Games/DCS/Scripts/DCS_NMEA.lua"]:132: attempt to index a nil value
stack traceback:
[C]: ?
[string "C:/Users/Stef/Saved Games/DCS/Scripts/DCS_NMEA.lua"]:132: in function 'ActivityNextEvent'
[string "C:/Users/Stef/Saved Games/DCS/Scripts/DCS_NMEA.lua"]:293: in function <[string "C:/Users/Stef/Saved Games/DCS/Scripts/DCS_NMEA.lua"]:291>.
2019-02-03 20:00:04.645 ERROR   Lua::Config: Call error LuaExportAfterNextFrame:[string "C:\Users\Stef\Saved Games\DCS\Scripts\Export.lua"]:39: attempt to index local 'myData' (a nil value)
stack traceback:
[C]: ?
[string "C:\Users\Stef\Saved Games\DCS\Scripts\Export.lua"]:39: in function 'LuaExportAfterNextFrame'
[string "C:\Users\Stef\Saved Games\DCS\Scripts\DCS-BIOS\BIOS.lua"]:81: in function 'PrevLuaExportAfterNextFrame'


Edited by Ex Machina
Link to comment
Share on other sites

2019-02-03 20:00:04.100 ERROR   Lua::Config: Call error LuaExportActivityNextEvent:[string "C:/Users/Stef/Saved Games/DCS/Scripts/DCS_NMEA.lua"]:132: attempt to index a nil value
stack traceback:
   [C]: ?
   [string "C:/Users/Stef/Saved Games/DCS/Scripts/DCS_NMEA.lua"]:132: in function 'ActivityNextEvent'
   [string "C:/Users/Stef/Saved Games/DCS/Scripts/DCS_NMEA.lua"]:293: in function <[string "C:/Users/Stef/Saved Games/DCS/Scripts/DCS_NMEA.lua"]:291>.
2019-02-03 20:00:04.645 ERROR   Lua::Config: Call error LuaExportAfterNextFrame:[string "C:\Users\Stef\Saved Games\DCS\Scripts\Export.lua"]:39: attempt to index local 'myData' (a nil value)
stack traceback:
   [C]: ?
   [string "C:\Users\Stef\Saved Games\DCS\Scripts\Export.lua"]:39: in function 'LuaExportAfterNextFrame'
   [string "C:\Users\Stef\Saved Games\DCS\Scripts\DCS-BIOS\BIOS.lua"]:81: in function 'PrevLuaExportAfterNextFrame'

This I hope did the trick!

Thanks.

 

I did not take care of how LoGetSelfData was handled when returning nil, like when playing as "client" instead of as "player". I am an exclusive SP player and didn't face this problem during the last part of development (did however face it long ago but didn't remember it).

 

Please download v1.1 and try again.

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

Hello Holton,

 

I tried version 1.1, solo player, it still does not work. I will try via a Bluetooth connection.

 

thanks again

Strange. Any additional errors in the logg?

Have you got GPSBrige to work with other applications than DCS? Like X-plane or P3D?

And sorry for asking, don't mean to offend you, but the IP you have entered, 192.168.1.11, it's the IP of your Android device right? Not your PC? And they are on the same network?

 

And I have asked before, and do it again. Can you please try to activate the "write to file" function (below the Bluetooth parts), just to see if the actual export of the information works.

 

I will try to use my wifes phone. It's much newer than my own and has more recent Android version, if that might cause issues.

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

I don't know how many people following this thread, but I am really curious if anyone got it working? Also if not. Feel free to share your experience.

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

Hello,

 

yes it is the good IP, I looked in the advanced settings of my tablet, and it is displayed on GPSBridge and in my router.

 

I tried different ways :

 

-DCS launched, GPSBridge launched, port 8080 open on the router, GPSBridge status "service running"

 

-DCS launched, GPSBridge launched, 8080 port closed on the router, GPSBridge status "can not connect"

 

-DCS stopped, GPSBridge launched, port 8080 open, I get the position info from my PC, GPSBridge status "Provider" GPS "unknown

 

In "export.lua" I deleted all other entries and left only DCS-to-GPS 1.1 command lines:

 

userprofile = os.getenv ("userprofile"): gsub ("\\", "/")
--dofile (userprofile () .. [[scripts / DCS_NMEA.lua]])
dofile (userprofile .. "/ Saved Games / DCS / Scripts / DCS_NMEA.lua")

 

File "NMEA_test.tx" :

 

C:/Users/Stef/Saved Games/DCS/Scripts/NMEA_Test.txt
$GPGGA,080000.00,4212.6092190,N,04240.9303901,E,1,05,1.3,0112.3,M,0000,M,,*4f	$GPRMC,080000.00,A,4212.6092190,N,04240.9303901,E,000.0,000.0,010611,0,E,A*27

 

Thank you.

 

++

Link to comment
Share on other sites

That's it, it works!

 

I opened UDP port 4353 on my router !

 

 

That's it, it works!

 

I just opened UDP port 4353 on my router.

Just open in UDP only, not UDP / TCP protocol.

 

Works perfectly !!!

 

Thanks again for your patience Holton;)

 

++

 

 

WHAT A RELIEF!!! :thumbup:

I assume it's the "Just open in UDP only" that is the key here, I could use port 8080 myself. I share my phones internet connection to my PC so I don't use a router and has therefore not run into this issue. Thanks for reporting back, I might add this information to the instructions. Hopefully others can make it work with this info.

 

 

Have fun!

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

Anyone using apple products here? I'm trying to figure out how to set it up but the two programs recommended are not available. I tried NMEAconnect but I got to admit this stuff is not my forte. My ports are opened,my devices IP entered, and the export file uncommented but it doesn't look like any information is being transmitted.

[sIGPIC][/sIGPIC]

Are you ready to take your chopper flying skills to the next level?

Then check out http://www.blacksharkden.com/ Or visit us on Discord https://discord.gg/kaayJ5z and talk to some of our awesome pilots today.

Link to comment
Share on other sites

Anyone using apple products here? I'm trying to figure out how to set it up but the two programs recommended are not available. I tried NMEAconnect but I got to admit this stuff is not my forte. My ports are opened,my devices IP entered, and the export file uncommented but it doesn't look like any information is being transmitted.

 

Can you please post your DCS_NMEA.lua and Export.lua (those you actually use)?

If you prefer you can sen them as PM.

The file export not showing any information indicate something isn't right with then.

 

Skickat från min D6603 via Tapatalk

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

here you go hopefully this helps

Export.lua

local SimShakerlfs=require('lfs'); dofile(SimShakerlfs.writedir()..'Scripts/SimShaker.lua')

dofile(lfs.writedir()..[[scripts\SimShaker-export-core\ExportCore.lua]])

 local dcsSr=require('lfs');dofile(dcsSr.writedir()..[[scripts\DCS-SimpleRadioStandalone.lua]])
dofile(lfs.writedir()..[[scripts\DCS-BIOS\BIOS.lua]])

local Tacviewlfs=require('lfs');dofile(Tacviewlfs.writedir()..'Scripts/TacviewGameExport.lua')
-- Export of NMEA sentences to be used with any application or device capable of using them.
-- Uncomment only one of the two lines below corresponding to your DCS Saved Games path. You might need to edit the path if different than any of them.
userprofile = os.getenv ("userprofile"):gsub("\\","/")
-- dofile(userprofile .. "/Saved Games/DCS/Scripts/DCS_NMEA.lua")
dofile(userprofile .. "/Saved Games/DCS.openbeta/Scripts/DCS_NMEA.lua")

 

DCS_NMEA.lua

-- Written by Holton181
-- Version 1.0
-- Use this to export GPS NMEA GGA and RMC sentences to be used with any application or device capable of using them.
-- UDP or Serial Port export is available. To activate any of these see the COMMUNICATIONS sections (three of them).
-- REMEMBER!!! The world is flat! ...at least according to Eagle Dynamics. Therefor the position information taken from DCSW
-- does not perfectly correspond to the same in the real world. It gets worse the closer to map boarders you get.
-- Should not cause troubles in MP, but since I'm an exclusive SP myself I can't make any promises.
-- Use, distribute and copy any parts of this script as you like, but please acknowledge your source.
-- Thanks to:
-- * leonpo, who created the telemetry export file upon which this script is based on originally.
-- Not much of the original file is left. His (no longer active) project can be found here:
-- https://forums.eagle.ru/showthread.php?t=97890
-- * BR=55=Sevas, who pointed me in the right direction regarding ground speed and course.
-- * "The Internet" for its vast amount of information required for me to complete this project...




---------------------------------------------------------------------------------------------------
-- Export start 
---------------------------------------------------------------------------------------------------

dofile("./Config/World/World.lua")				-- Required to get mission date


DCS_NMEA =
{
Start=function(self) 
package.path = package.path..";.\\LuaSocket\\?.lua"
package.cpath = package.cpath..";.\\LuaSocket\\?.dll"
socket = require("socket")

----------------------------------------------------------------------------------------------------------------------------------------------
-- COMMUNICATIONS
----------------------------------------------------------------------------------------------------------------------------------------------

-- For UDP and Serial Port there are three sections each to activate or deactivate depending on what method you like to use to connect.
-- One here in the Start() function, below. The second in the end of ActivityNextEvent() function. The third in the Stop() function.

-- UDP -----------------------------------------------------------------------------------------------------------------------------------
-- Use this to connect via UDP. Change IP to the devise you want to use. Alternatively the port too. Use the same port in your GPS device.

---[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
my_init = socket.protect(function()
	host2, port2 = "10.0.0.190", 4353 -- replace IP with android device ip 
	udp = socket.try(socket.udp())	
end)
my_init()	
--]]	


-- Serial Port ---------------------------------------------------------------------------------------------------------------------------
-- Use this to connect via Serial Port. Change COM Nr to the port you want to use.
-- One way to use this is by Bluetooth Virtual Serial Port to connect to a Bluetooth compatible device.
-- If Bluetooth is used, be aware that DCS will freeze as long as the used device isn't listening to the port. As soon as it listen, DCS will un-freeze.
-- I do not know if this freezing behavior exist when a physical serial port is used, since I one have one to test.
-- Remember to comment out the "dofile" line related to this MOD in Export.lua or all Serial Port sections in this file if you are not going to use it to avoid freezing.

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
sPort = "COM3"
com = io.open(sPort,"w+b")
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------

-- Create a TXT file for debugging or a NMEA log or whatever
-- Same as for the communication options, need to be activated or de-activated at three locations, all located below corresponding communication section.
-- Remember to adjust the path below to DCS or DCS.openbeta or whatever path you have to your Saved Games section.

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
--Test_file = os.getenv ("userprofile"):gsub("\\","/") .. "/Saved Games/DCS/Scripts/NMEA_Test.txt"
Test_file = os.getenv ("userprofile"):gsub("\\","/") .. "/Saved Games/DCS.openbeta/Scripts/NMEA_Test.txt"
file = io.open(Test_file, "w")
--file:write(string.format("%s\r\n",Test_file))
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------

xortbl = {
       { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, },
       { 1,  0,  3,  2,  5,  4,  7,  6,  9,  8, 11, 10, 13, 12, 15, 14, },
       { 2,  3,  0,  1,  6,  7,  4,  5, 10, 11,  8,  9, 14, 15, 12, 13, },
       { 3,  2,  1,  0,  7,  6,  5,  4, 11, 10,  9,  8, 15, 14, 13, 12, },
       { 4,  5,  6,  7,  0,  1,  2,  3, 12, 13, 14, 15,  8,  9, 10, 11, },
       { 5,  4,  7,  6,  1,  0,  3,  2, 13, 12, 15, 14,  9,  8, 11, 10, },
       { 6,  7,  4,  5,  2,  3,  0,  1, 14, 15, 12, 13, 10, 11,  8,  9, },
       { 7,  6,  5,  4,  3,  2,  1,  0, 15, 14, 13, 12, 11, 10,  9,  8, },
       { 8,  9, 10, 11, 12, 13, 14, 15,  0,  1,  2,  3,  4,  5,  6,  7, },
       { 9,  8, 11, 10, 13, 12, 15, 14,  1,  0,  3,  2,  5,  4,  7,  6, },
       {10, 11,  8,  9, 14, 15, 12, 13,  2,  3,  0,  1,  6,  7,  4,  5, },
       {11, 10,  9,  8, 15, 14, 13, 12,  3,  2,  1,  0,  7,  6,  5,  4, },
       {12, 13, 14, 15,  8,  9, 10, 11,  4,  5,  6,  7,  0,  1,  2,  3, },
       {13, 12, 15, 14,  9,  8, 11, 10,  5,  4,  7,  6,  1,  0,  3,  2, },
       {14, 15, 12, 13, 10, 11,  8,  9,  6,  7,  4,  5,  2,  3,  0,  1, },
       {15, 14, 13, 12, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1,  0, },
   }
	
end,

ActivityNextEvent=function(self,t)
--LoGetSelfData return the same result as LoGetObjectById but only for your aircraft and not depended on anti-cheat setting in Export/Config.lua
--Returned object table structure:
--{ 
	--Name = 
	--Type =  {level1,level2,level3,level4},  ( see Scripts/database/wsTypes.lua) Subtype is absent  now
	--Country   =   number ( see Scripts/database/db_countries.lua
	--Coalition = 
	--CoalitionID = number ( 1 or 2 )
	--LatLongAlt = { Lat = , Long = , Alt = }
	--Heading =   radians
	--Pitch      =   radians
	--Bank      =  radians
	--Position = {x,y,z} -- in internal DCS coordinate system ( see convertion routnes below)
	-- only for units ( Planes,Hellicopters,Tanks etc)
	--UnitName    = unit name from mission (UTF8)  
	--GroupName = unit name from mission (UTF8)	
--}
local tNext = t
local year = MissionDate.Year
local month = MissionDate.Month
local day = MissionDate.Day
local pt = LoGetMissionStartTime()+LoGetModelTime()
local h = pt/3600
local hh = math.floor(h)
local m = (h-hh)*60
local mm = math.floor(m)
local s = (m-mm)*60

local SD = LoGetSelfData
local Lat = SD().LatLongAlt.Lat
local Long = SD().LatLongAlt.Long
local Alt = SD().LatLongAlt.Alt
local Velocity = LoGetVectorVelocity()  --{x,y,z}
local VX = Velocity.x
local VY = Velocity.y
local VZ = Velocity.z
local Speed = math.sqrt(VX*VX+VZ*VZ)*1.9438444924574 -- Speed from m/s to knot 

-- Course calculations 
if VX==0 and VZ==0 then
	radTC = 0
else
	radTC = math.atan2(VZ,VX)
	if radTC < 0 then
		radTC = 2*math.pi + radTC
	end
end
TC = radTC*180/math.pi

-- Coordinates from decimal degrees to degrees and decimal minutes
local dLat = math.floor(math.abs(Lat))
local dLong = math.floor(math.abs(Long))
local mLat = (math.abs(Lat)-dLat)*60
local mLong = (math.abs(Long)-dLong)*60

-- Cardinal directions
local sigLat = Lat/math.abs(Lat)
local sigLong = Long/math.abs(Long)

if sigLat<0 then NS='S'
else NS='N'
end

if sigLong<0 then EW='W'
else EW='E'
end

-- Various unimportant GPS values for the GGA sentence not derivable from game
local Q = 1
local nSat = 5
local HDOP = 1.3
local GeoSep = 00.0

-- GGA sentence
local GGA = string.format("GPGGA,%02d%02d%05.2f,%02d%010.7f,%s,%03d%0010.7f,%s,%1d,%02d,%03.1f,%06.1f,M,%04.0f,M,,", hh,mm,s,dLat,mLat,NS,dLong,mLong,EW,Q,nSat,HDOP,Alt,GeoSep)
local csGGA = 0
for c in string.gmatch(GGA,".") do
	csGGA = bxor(csGGA, string.byte(c))
end

-- RMC sentence
local RMC = string.format("GPRMC,%02d%02d%05.2f,A,%02d%010.7f,%s,%03d%0010.7f,%s,%05.1f,%05.1f,%02d%02d%02d,0,E,A", hh,mm,s,dLat,mLat,NS,dLong,mLong,EW,Speed,TC,day,month,string.sub(year,3,4))
local csRMC = 0
for c in string.gmatch(RMC,".") do
	csRMC = bxor(csRMC, string.byte(c))
end


----------------------------------------------------------------------------------------------------------------------------------------------
-- COMMUNICATIONS
----------------------------------------------------------------------------------------------------------------------------------------------

-- UDP -----------------------------------------------------------------------------------------------------------------------------------

---[[		To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.	
my_send = socket.protect(function()
	local json = string.format("$%s*%x\r\n$%s*%x\r\n", GGA,csGGA,RMC,csRMC)
	socket.try(udp:sendto(json, host2, port2))
	end) -- my_send
my_send()
--]]


-- Serial Port ---------------------------------------------------------------------------------------------------------------------------

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
com:write(string.format("$%s*%x\r\n$%s*%x\r\n", GGA,csGGA,RMC,csRMC)) -- fills the serial buffer
com:flush() -- send the serial buffer
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
file:write(string.format("$%s*%x\t$%s*%x\r\n", GGA,csGGA,RMC,csRMC))
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------
	
-- Repeat every 0.5s
return tNext + 0.5
end,

Stop=function(self)

----------------------------------------------------------------------------------------------------------------------------------------------
-- COMMUNICATIONS
----------------------------------------------------------------------------------------------------------------------------------------------

-- UDP -----------------------------------------------------------------------------------------------------------------------------------

---[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
my_close = socket.protect(function()
	socket.try(udp:close())
end)
my_close()
--]]


-- Serial Port ---------------------------------------------------------------------------------------------------------------------------

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
com:close(sPort)
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------

--[[	To activate section, add a "-" among the other two on this row. To deactivate remove one of the tree.
file:close()
--]]

----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------
	
end
}

--[[ Perform a bitwise Exclusive OR (XOR) ]]--
function bxor(a,b)
   local res, mult = 0, 1
   while a > 0 and b > 0 do
       local a2, b2 = a % 16, b % 16
       res = res + xortbl[a2+1][b2+1] * mult
       a = (a-a2) / 16
       b = (b-b2) / 16
       mult = mult * 16
   end
   res = res + (a+b) * mult
   return res
end

-- =============
-- Overload
-- =============
do
local PrevLuaExportStart=LuaExportStart
LuaExportStart=function()
	DCS_NMEA:Start()
	if PrevLuaExportStart then
		PrevLuaExportStart()
	end
end
end

do
local PrevLuaExportActivityNextEvent=LuaExportActivityNextEvent
LuaExportActivityNextEvent=function(t)
	local tNext = t
	tNext = DCS_NMEA:ActivityNextEvent(t)
	if PrevLuaExportActivityNextEvent then
		PrevLuaExportActivityNextEvent()
	end
	return tNext
end
end

do
local PrevLuaExportStop=LuaExportStop
LuaExportStop=function()
	DCS_NMEA:Stop()
	if PrevLuaExportStop then
		PrevLuaExportStop()
	end
end
end

[sIGPIC][/sIGPIC]

Are you ready to take your chopper flying skills to the next level?

Then check out http://www.blacksharkden.com/ Or visit us on Discord https://discord.gg/kaayJ5z and talk to some of our awesome pilots today.

Link to comment
Share on other sites

here you go hopefully this helps

At a first glance every thing seems okay.

A few questions:

You use the beta and it has the saved games folder DCS.openbeta located in the default location in your windows profile? It's actually not important if you use the beta or stable, but that the folder in Export.lua is the one you use. If you use the DCS folder or any othe than DCS.openbeta, you need to correct the path in Export.lua. I trust you that you already know this, but mention it just in case.

 

The functionality to export the NMEA sentences to a file is disabled in the DCS_NMEA.lua. I guess you already tried it and disabled it again, but it has to be activated in the same manner as for the UDP export and it creates and export to the file NMEA_Test.txt. The default path is /Saved Games/DCS.openbeta/Scripts/NMEA_Test.txt and all folders need to exist before it works. Best is to make sure the path is the same as for Export.lus and DCS_NMEA.lua.

 

As I mentioned to you earlier I will try to implement native Foreflight communication as per the link you gave me.

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

  • 3 weeks later...

BUGGER!!!

I discovered now that I actually never updated the version on User Files to 1.1, only the description and change-log.:(

 

If you have problems using this as a client, pleas download it again and make sure the readme.txt and DCS_NMEA.lua says version 1.1.

 

I'm really sorry for any inconvenience.

 

 

I'm also in the process of implementing native ForeFlight support and might need some volunteers for testing, because I don't have access to any Apple products or ForeFlight myself.

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

I already asked you the question on the other thread but this would work with Foreflight on iPad?

Also, I would have though that the new maps are actually more accurate vs IRL than Caucasus. Do you see a massive difference in position? Is it usable for helicopter operations?

 

...

 

So guys, I now have a code that I hope will work with ForeFlight, attached below as 1.2 Beta. I would highly appreciate if you could try it out, since I don't own any Apple products nor ForeFlight. I have implemented it as suggested by the instructions here. Therefor the position only has an accuracy of two decimals at the moment, might try to increase it later on. I also intend to implement the attitude data to the Attitude Indicator when the basic GPS transfer is proven working.

 

The only thing you have to do is to change the IP address of your Apple device at line 82 in DCS_NMEA.lua. Let the port stay as 49002 and open it in any firewall and router as UDP and not TCP/UDP.

 

 

Thanks!

DCS_to_GPS 1.2 Beta.zip


Edited by Holton181

Helicopters and Viggen

DCS 1.5.7 and OpenBeta

Win7 Pro 64bit

i7-3820 3.60GHz

P9X79 Pro

32GB

GTX 670 2GB

VG278H + a Dell

PFT Lynx

TrackIR 5

Link to comment
Share on other sites

I am Foreflight Alpha/Beta team member. I'll be happy to test it out ;)

X-Plane 11.5x / DCS 2.5.6 / P3Dv5 / Aerofly FS 2 / War Thunder

 

Win10-x64 | ASUS Z390 Maximus VI | Intel i7-9700K @3.6GHz | Corsair Vengeance LPX 32 GB DDR4 | 6TB SSD Samsung 850 Pro | 2TB M2 PCI 4x | ASUS GTX 1080 ROG STRIX 8GB DDR5X | TM Hotas Warthog | Saitek Combat Pedals | Oculus Rift S

Link to comment
Share on other sites

  • Recently Browsing   0 members

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