Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_simdatum Warning log message #12

Open
mjfrisby opened this issue Oct 8, 2023 · 5 comments
Open

set_simdatum Warning log message #12

mjfrisby opened this issue Oct 8, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@mjfrisby
Copy link

mjfrisby commented Oct 8, 2023

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.

@patricksurry
Copy link
Owner

Interesting, i definitely haven't explored a lot of the non-float simvars.

But it looks like that message comes from here

logging.warning(warn + "; using float64 as fallback")

So the easiest fix would be to add 'position' to the list of std units that resolve to INT32 in the pysimconnect code here:

if u['name_std'] in ('Bool', 'Boolean', 'Enum', 'BCO16', 'mask', 'flags'):

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.

@patricksurry patricksurry added the bug Something isn't working label Oct 10, 2023
@mfrisby-extreme
Copy link

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.

@patricksurry
Copy link
Owner

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.

@patricksurry
Copy link
Owner

patricksurry commented Oct 14, 2023

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 :)

@mfrisby-extreme
Copy link

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants