-
Notifications
You must be signed in to change notification settings - Fork 85
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
Examples Error on alternating runs without device reset #23
Comments
No, this should not happen. I never use the reset command in my examples and playground work (except for testing it once while implementing it). But I also used some older device versions. The
When we initialize a new Sweep device in I remember talking to @kent-williams about this but back then this was what we were supposed to do. |
Just tried to reproduce this issue with the device I have here (note this is a old version, the new ones will hopefully arrive next week). But I was unable to. What I tried:
All the viewer examples does is starting the scanning and receiving responses here. As soon as the new units arrive I can test and try to reproduce again. Any hints from your side what could happen here? cc @kent-williams @dcyoung |
Odd that the behavior was not reproduce-able. I'll double check on my end again in a bit.
Sorry for the confusion... When i said "reset", I was actually referring to resetting the device manually (unplugging it and plugging it back in), not sending the reset command over serial.
I'm aware that the stop command is transmitted in the referenced method, but I'm still unable to find where the method
Am I missing where the Edit: I missed the bit in your original response regarding the behavior of
In Destroying a device would obviously occur in multiple circumstances, some of which might not even permit data transmission (ie: disconnected device). We want destroy the device gracefully in all situations. So, perhaps we should consider a Edit 2: Given that |
Good catch, this could be done here before shutdown. Not sure if the
Oh? This is good to know! If so we should do this in the destruct function here where we still have access to the serial port. Check the serial interface for a flush function. To summarize:
|
The new units just arrived and I could reproduce the issue there! I created a pull request fixing this issue and could confirm it working now on the recent units I have here. |
Looks good, I was using the same internal fix myself. This resolves issues with subsequent runs. This issue can be effectively closed when the PR is merged. The
However, this is being thrown on program exit, not startup. From some early debugging, it looks like this is because the sleep duration in the |
Running the examples
./example-c
,./example-c++
or./example-viewer
works the first time, but unless the sensor is reset between each run, the example will error on subsequent attempts in an alternating pattern. Ie: the 2nd attempt will fail, but the 3rd will succeed, 4th will fail, etcIn the case of
./example-c
the stated error is:In the case of
./example-c++
the stated error is:And in the case of
./example-viewer
the stated error is:Has this always been the behavior or is it a new issue? I don't believe any changes were made to the protocol for
DS
orDX
receipts. I haven't started tracking down the origin of the issue yet, but I'm assuming the device is not being shutdown properly. Whether its a logical error in the example itself, or an error withlibsweep
is unclear.Edit: Looking at the example code, I don't see where we send a
DX
stop command to the sensor. However, after the example runs the device does stop transmitting serial data (judging from the TX led on the USB Serial adapter which stops blinking). It was my understanding that the device would continue to transmit data regardless of the state of the host port.... so somehow the device is getting that stop command. Is it hidden somewhere I might have overlooked?If the example does trigger the host to send a
DX
stop data command before or during the process of shutting down, are the still incomingData Block
receipts handled properly? Recall that after sending aDX
command, the host should still expect to receiveData Block
receipts until theDX
receipt is received, which indicates no furtherData Block
receipts are coming. Is it possible that the host sends theDX
and then immediately shuts down? This might be leaving incoming bytes in the serial buffer that are misinterpreted at the beginning of the example's next execution... producing the observed alternating errors.The text was updated successfully, but these errors were encountered: