odwdinc / Python-SimConnect

Python interface for MSFS2020 SimConnect.dll

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set weather via SimConnect_WeatherSetObservation METAR string?

vamshichittaluri opened this issue · comments

Hello all,

Hope you are all well. I know through SimVars we cannot set the weather for the simulator. However, as seen in the attributes.py and simconnect function, i saw that we should be able to set METAR string weather(c++) implementation.

	# SIMCONNECTAPI SimConnect_WeatherSetObservation(
	#   HANDLE hSimConnect,
	#   DWORD Seconds
	#   const char * szMETAR);
	self.WeatherSetObservation = self.SimConnect.SimConnect_WeatherSetObservation
	self.WeatherSetObservation.restype = HRESULT
	self.WeatherSetObservation.argtypes = [HANDLE, DWORD, c_char_p]

Can anyone guide me how to send the METAR string, i dont mean the actual string format, but synatx etc.

Kind Regards
Vamshi

Sooo I figured out i can access the function through:

sim.dll.WeatherSetObservation(sim.hSimConnect, 2, "CYXU METAR 271700Z 320002KTS 9999M R24R/5203FT R24L/420340 SCT006 OVC019 -02/-03 Q1021")

but i get the following error:
ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type

I am guessing my first argument is wrong? Any idea on where I am loosing it?

Kind Regards
Vamshi

Needs to be byte string aka

sim.dll.WeatherSetObservation(sim.hSimConnect, 2, b"CYXU METAR 271700Z 320002KTS 9999M R24R/5203FT R24L/420340 SCT006 OVC019 -02/-03 Q1021")

or

msg = "CYXU METAR 271700Z 320002KTS 9999M R24R/5203FT R24L/420340 SCT006 OVC019 -02/-03 Q1021"
sim.dll.WeatherSetObservation(sim.hSimConnect, 2, msg.encode())

Ahh! Awesome! Thanks Odwdinc! Works now.