Closed computer-whisperer closed 9 years ago
At some point the DriverStation classes should be refactored so it can catch errors like this. Currently the DS test uses magic mocks, and doesn't use simulated HAL. It is a bit tricky to test, however.
What is magic mock?
Ah, thanks.
We should be able to initialize it to all 0 this way (it's how C++ and Java work, they do NOT call HALGetControlWord). However, this initialization approach is currently broken on the RoboRIO, due to the refactor (82bc781e) which made HALControlWord a pointer rather than the actual structure. We should unbreak this and just make the GetControlWord function definition different on the two HALs (e.g. RoboRIO with POINTER, simulation without--I believe there's a flag to check this?).
Hm. Isn't there a wrapper that fixes this? goes to check...
Oh, I see the problem. Sorry about that. Will fix.
Now Java at least calls HALGetControlWord() at startup. Interesting.
When running the example robot script under examples/test.py, with the workarounds described in #28 , I encounter the following error:
I can't tell what hal.HALControlWord() is supposed to require on hal-roborio, but the implementation in hal-sim appears to require the argument
d
, and seems to pull data from it, as if it were a dictionary.I can resolve the issue by replacing hal.HALControlWord() with hal.GetHALControlWord() in wpilib/wpilib/driverstation.py, but I don't know how this fix affects hal-roborio