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

"System.NullReferenceException: Object reference not set to an instance of an object." during "Discover Ports. Receiving Messages ..." when using CLI #188

Open
voomdoon opened this issue Apr 20, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@voomdoon
Copy link

There is a NullReferenceException during Discover Ports. Receiving Messages ... using latest master branch

>poweredup device list
Scan Started. Please select the Hub (using a number keys or 'q' to terminate):
1: DuploTrainBase (with address <ADDRESS>)
1
Selected DuploTrainBase with key 1
Discover Ports. Receiving Messages ...
System.NullReferenceException: Object reference not set to an instance of an object.
   at SharpBrick.PoweredUp.Bluetooth.BluetoothKernel.ConnectAsync() in /home/runner/work/powered-up/powered-up/src/SharpBrick.PoweredUp/Bluetooth/BluetoothKernel.cs:line 29
   at SharpBrick.PoweredUp.Protocol.LegoWirelessProtocol.ConnectAsync(SystemType knownSystemType) in /home/runner/work/powered-up/powered-up/src/SharpBrick.PoweredUp/Protocol/LegoWirelessProtocol.cs:line 49
   at SharpBrick.PoweredUp.Cli.DevicesList.ExecuteAsync(SystemType knownSystemType) in /home/runner/work/powered-up/powered-up/src/SharpBrick.PoweredUp.Cli/Commands/DevicesList.cs:line 29
   at SharpBrick.PoweredUp.Cli.Program.<>c__DisplayClass4_2.<<Main>b__6>d.MoveNext() in /home/runner/work/powered-up/powered-up/src/SharpBrick.PoweredUp.Cli/Program.cs:line 78

Environment:

@voomdoon
Copy link
Author

on second attempt its working, not sure how to reproduce

@tthiery
Copy link
Member

tthiery commented Apr 20, 2022

hah ... probably the device switched or just did not do what it should or the data was gliberrish in the air of during the wireless connection .... which is all fine. The code deserves some more love at

https://github.com/sharpbrick/powered-up/blob/master/src/SharpBrick.PoweredUp/Bluetooth/BluetoothKernel.cs#L29

Basically we do three calls to external resources and follow the happy path ... pretty stupid and not very defensively programmed.

I am a bit tired right now due to private stuff .... do you want to take a shot at improving this function?

@tthiery tthiery added the bug Something isn't working label Apr 20, 2022
@tthiery tthiery added this to the v5.0 (breaking) milestone Apr 20, 2022
@voomdoon
Copy link
Author

I am just doing my first steps with C#, so would need some time...

@tthiery
Copy link
Member

tthiery commented Apr 20, 2022

no worries. I have time ;) and can review code ;)

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

2 participants