pysimconnect
pysimconnect copied to clipboard
set_simdatum Warning log message
Working on a script to send joystick x/y position via simconnect. Works just fine, however, no matter what unit type I specify, I get a warning logged
unrecognized Miscellaneous Unit in typefor(POSITION); using float64 as fallback
The relevant code is quite simple:
self.sim_connect.set_simdatum("YOKE X POSITION", x)
self.sim_connect.set_simdatum("YOKE Y POSITION", y)
I have tried without specifying units (as in above example), I have tried units=None and units="Position" (as well as others like `DATATYPE_FLOAT64 which result in errors.)
How can I call the simdatum method without generating these warnings? Like I said, it works fine, but it sure muddies up my log.
Interesting, i definitely haven't explored a lot of the non-float simvars.
But it looks like that message comes from here https://github.com/patricksurry/pysimconnect/blob/fc6b73e401d27517ca8b45a8af1c3ee85bed5b2d/simconnect/scvars.py#L78
So the easiest fix would be to add 'position' to the list of std units that resolve to INT32 in the pysimconnect code here: https://github.com/patricksurry/pysimconnect/blob/fc6b73e401d27517ca8b45a8af1c3ee85bed5b2d/simconnect/scvars.py#L65
It's possible that a hack of passing one of the recognized int32 types like units='mask' to set_simdatum() would work too but i'm not sure.
Interesting, i definitely haven't explored a lot of the non-float simvars.
Thanks for the reply.
What's interesting is that even though the simvar(s) are defined as "position", which according to the documentation should be a value 0-16K... in practice, the sim very much wants to receive a float value between -1 and 1. Trying to send a value of '100' for example, just results in full deflection of the stick/yoke. This is true if I set via my script or another simconnect capable tool like SPAD.neXt.
With that being said, using one of the int32 types does suppress the warning log if you pass a integer value, but since the sim seems to want a float, it does not work.
yes, the documentation does not seem entirely reliable in a lot of respects. but that explains why it was working with the default float value. so then I guess the right fix would be to add another case in scvars that checks `... elif u['name_std'] in ('position', ...) and return the float64 result before falling thru to the generic warning.
as a short-term fix you could also build off the suggestion in the README and use set LOGLEVEL=ERROR to just suppress all the warning messages :)
Thanks. As I am just importing the simconnect library, I can't easily modify the type_for_unit function and the logging level is dependent on my own logger setup.
For now, I have just added a filter to my logger to suppress this specific warning message.
I thought about using a local copy of the package, but the log filter seemed easier :)