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

Fixed bug that caused the initialization to hang #2

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

SkibbleBip
Copy link
Contributor

If the chip had already been started from a previous run, then initialization hangs. Fixed by sending a RESET command as the first thing it does on initialize to the chip which soft-resets.

@mjbogusz
Copy link
Owner

mjbogusz commented Nov 1, 2023

Thanks for the contribution! I've pushed the branch to gitlab for CI, as that's the project's main repo (github is just a mirror I've added for discoverability) - here's the pipeline: https://gitlab.com/mjbogusz/vl53l1x-linux/-/pipelines/1057760762

If that passes, I'm happy to merge - and then I have to remember to put a PR template into the repo redirecting future contributors to gitlab ;)

@mjbogusz mjbogusz changed the base branch from master to main_nodeps November 1, 2023 15:28
…ady been started from a previous run. This is fixed by soft-restarting the chip.
@mjbogusz
Copy link
Owner

mjbogusz commented Nov 1, 2023

I've amended the comment to make uncrustify happy.

Additionally I've found that this patch has been kinda-already-done, see here: https://gitlab.com/mjbogusz/vl53l1x-linux/-/commit/1530dbf9cbe81fe9673eee2fa60782094b6e21b9 but as I've mentioned above - this mirror was not kept up-to-date... and if I remember correctly that patch of mine did not resolve all my issues, that's why it wasn't merged into master/main.

Could you please test my version? I don't have access to the sensors right now and this definitely requires testing with hardware.

@SkibbleBip
Copy link
Contributor Author

SkibbleBip commented Nov 1, 2023

Could you please test my version? I don't have access to the sensors right now and this definitely requires testing with hardware.

I have tested your version, including the original commit of 1530dbf9cbe81fe9673eee2fa60782094b6e21b9 as well as the master branch on gitlab with the .cpp file from the original commit copied over, and can confirm that it does not work. I have tested my commit and confirm that it mine still works.

Edit: would like to include, it's very particular that your commit didn't work, as it appears your commit is doing something very similar to what mine is attempting.

@mjbogusz
Copy link
Owner

mjbogusz commented Jan 3, 2024

I finally got around to analyzing this a bit... but looking at the code, mine (branch dev) should do exactly the same as yours minus the sleeps.

I'm afraid that the issue is such a low-level one that it might require hooking a scope (or at least a logic analyzer) to the communication lines and dissecting the difference. As I've mentioned I don't have the hardware on hand, but I'll see if I can find an excuse to buy 2-3 of these sensors ;)

In the meantime, if possible, could you test my code with sleeps a) disabled and b) extended to large values like 1s?

@SkibbleBip
Copy link
Contributor Author

SkibbleBip commented Jan 30, 2024

Hello once again,
Finally got back to looking at your code (1530dbf9)

I recently pulled and compiled directly from what main branch has on github, and manually added what was in the dev branch. IT SEEMS for some strange reason, with the newer up-to-date version of main, with the added changes that you had, allows it to work again. Maybe some change added somewhere else is allowing it to work, I don't know. But it seems your code with write8Reg16 is working, with or without the thread timeouts.

Edit: Wanted to also add, the newer main branch that was merged from gitlab, includes libsbc-linux-interfaces.so, which from my understanding is what handles all the actual i2c "touching", possibly features or patches in that handle better i2c communication that allow the resets to be perform without it choking. I am running the getDistance binary, both linked to the .so's that are compiled by make, as well as statically linking my .a archive and linked to the libsbc-linux-interfaces.so on my embedded system, in which it works for both of them. One thing to add, I did notice that when running with no thread sleeping, it hung ONCE and then never again. No clue if this is a coincidence on my end, or thread sleeping does take care of fringe cases of it hanging. Without the sleeps, it seems to "stumble" on the first few runs and with sleep it immediately takes off fine.
I would say with confidence then, that the devel patches most likely work now.

@mjbogusz mjbogusz changed the base branch from main_nodeps to main February 12, 2024 18:29
@mjbogusz mjbogusz changed the base branch from main to dev February 12, 2024 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants