sharpbrick / powered-up

.NET implementation of the LEGO PoweredUp Protocol
MIT License
98 stars 19 forks source link

Refactor DiscoverPort to procedural awaitable code #152

Closed tthiery closed 3 years ago

tthiery commented 3 years ago

Closes #148 non-breaking

tthiery commented 3 years ago

@dkurok Can you review and test this with your implementation? c&p the discoveryport.cs should work

tthiery commented 3 years ago

Code Quality improved significantly (readability wise)

dkurok commented 3 years ago

@tthiery I tried the new version of DiscoverPorts.cs with the BlueGiga-adapter. With Technic-Medium Hub and 3 attached motors and the 88007 colorDistance-sensor (VisionSensor 0x0025) it takes 30 to 35 seconds. TwoPortHub with one motor and 88007 <20secs. No hanging, no waiting, perfect! Just one question: Any reason why you store the result of _protocol.SendMessageReceiveResultAsync in variables in RequestPortProperties() whereas in RequestPortModePropertiesAsync() you're giving them directly into KnowledgeManager.ApplyStaticProtocolKnowledge(...)?

But again: This works perfectly now with BlueGiga-adapter!

tthiery commented 3 years ago

No specific reason. I thought I would need the messages more. And for the later, i just did not want to create seven meaningless variables.