Closed brentru closed 7 months ago
Is there a reason you are making it MCP2221 specific instead of a more generic board that we can use to CI test all of the functions?
I was thinking more about this and thought it might be better to adding a way to force a board and then remembered, I had added a feature like this a while back and completely forgotten about it. There are a couple of environment variables BLINKA_FORCEBOARD and BLINKA_FORCECHIP that can be set with the constant of the board/chip you are trying to set.
Is there a reason you are making it MCP2221 specific instead of a more generic board that we can use to CI test all of the functions?
I was using the MCP2221 to test WipperSnapper Python. Open to suggestions for using a generic target.
I was thinking more about this and thought it might be better to adding a way to force a board and then remembered, I had added a feature like this a while back and completely forgotten about it. There are a couple of environment variables BLINKA_FORCEBOARD and BLINKA_FORCECHIP that can be set with the constant of the board/chip you are trying to set.
I don't really understand how the FORCEBOARD/FORCECHIP env. variables come into play for the purpose of this PR, could you explain more about them?
Sure. Since the MCP2221a is already a board, to force Platform detect to return the correct board IDs, you could use something like those environment variables. For instance, in the detect script, it you added:
os.environ["BLINKA_FORCEBOARD"] = "MICROCHIP_MCP2221"
os.environ["BLINKA_ FORCECHIP"] = "MCP2221"
Then it should return that it detected those. Likewise, in your Python Wipper script, you could set those before calling Blinka. Now in the Blinka code, you would probably want to check if those variables are set in order to know that it's actually a fake board rather than a real one. This way, you wouldn't need to modify PlatformDetect at all.
Closing this conditionally in favor of the forcechip approach
Adding a fake Microchip MCP2221A board and chip for use with stubbing the blinka API for usage with no hardware attached.
Test result after setting environment variable to
BLINKA_FAKE_MCP2221
and runningpython3 bin/detect.py