-
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
Communicating Failure in Updated Protocol #68
Comments
Thanks for flagging this. Thinking a bit about a clean API here what if we split the
The motor speed adjust function can assert for Another option would be to hide the stabilization from the user completely: if the speed is still stabilizing we simply return a scan with less / zero samples in the get scan function. The adjust motor speed function could return an error when the speed is still stabilizing. Is there a way to figure out how long we have to wait for the speed to stabilize? I would prefer the simplest and most effective solution here. If that means we can e.g. simply block for a second in the constructor and adjust motor speed function, I would do so. |
Is there a particular reason, why it is not possible to change the motor speed before it has stabilized? Regarding If you decide to implement a blocking Interface, please allow for a (maybe user configurable) timeout. |
@daniel-j-h Are you proposing the addition of a new set of functions for stopping/starting the motor, separate from adjusting the motor speed? This set of functions would toggle the motor between motor speed setting 0Hz and whatever speed setting it was last using? This would require us to store the most recent motor speed... which means we'd have to query the motor speed on device creation as well. This would also necessitate that the This would handle the failure case for
I can see this setup being possible, but I'm wondering if abstracting motor speeds 0:10Hz into 2 separate concepts is necessary. ie:
Or.... are you proposing that the device be stationary at all times, unless it is scanning. This would remove some control from the user, but would make the logic more simple. All calls to
This removes the need to store any motor speed information, as the parameter is always passed into
@daniel-j-h and @MikeGitb When the motor speed is changed, the sensor also performs a calibration on the encoder ticks to account for variation in plastics on each device. This routine takes ~6 seconds. After changing the motor speed or when the device is powering on, this time window is a grace period where the device will not handle certain tasks related to motor speed. We hope to add more optimized control in the future, where the grace period might decrease but currently this is what we have to work with.
@MikeGitb I agree that we definitely want timeouts, but I think these should be based on the maximum possible duration for a motor speed stabilization, and not a user config. If you look at the sweep_device_wait_until_motor_ready() function, you can see that there is a timeout in there. Currently its set to something high like 10 seconds, but this could be dialed back to just longer than the maximum time set by the firmware ie: >6seconds. |
@dcyoung: Ok, sorry I was again thinking too much in terms of running this lib on a microcontroller/embedded system. Calling a function that might block for 6-10 seconds would be an absolute no-go for me (although it is probably fine for most other systems). But I think I'll just write my own library for my specific needs. Regarding the grace period: I don't know how you control the motor, but I find it strange that you can't just change the setpoint before you reached the previous one. |
@MikeGitb i edited the original response with more details. Its really due to a calibration routine that runs when the motor speed is adjusted. As for using the library without blocking. I see no reason why we couldn't break the functions down into base units, and provide them as well. For example, the sweep_device_wait_until_motor_ready() makes use of the sweep_device_get_motor_ready() function which does not block. |
What if we implemented all of the base (non-blocking) functions similar to the current fashion. Ie: the methods populate an error in the event of a status failure. The user would have access to these methods, but we would also provide simple abstractions that block. Do NOT maintain that the device be stationary when not scanning. Ie: device is allowed to be at any speed when not scanning.
High level user code could then look like:
A user looking for non-blocking functions could simply write their own logic, being careful not to call the
|
I pushed a status-codes branch with these changes that seems to be working well. Let me know what you think or if you have questions. PR is up #70 |
Is there any reason the device should ever not be scanning? Can it be always outputting scans? |
@dheera There are quite a few reasons. The most important reason is that the device cannot communicate or process commands (other than STOP) while scanning. Additionally, unlike the rest of the communication protocol, data packets are not delimited. This is meant to keep the data stream compact and efficient. The packets are parsed by expected size and then validated. So even if the device could process and respond to other commands while streaming, the responses would be lost in the stream. These kinds of discussions are related more to the device's firmware and communication protocol, to which this SDK conforms. In the future, Scanse may offer other platforms for providing feedback about the device firmware. But for now, if you have suggestions or feedback regarding the device's firmware or the communication protocol, always feel free to send a support message directly via the Scanse website. |
Resolved in b867c37 |
Scanse will start shipping devices shortly. The latest firmware that will come installed on the devices is using an updated communication protocol. The updated protocol is outlined in the docs on the motor-ready branch.
The relevant additions for this issue are...
Data Start - DS
will NOT trigger data acquisition unless the motor is spinning ( > 0Hz) and the speed has stabilized.DS
command with a normal header ('DS00P\n'
... ie: status bytes =='00'
) and data acquisition will commence.DS
command with a modified header and data acquisition will NOT commence. This modified header will use the status bytes to indicate the type of failure. For example'DS12S\n'
(status bytes =='12'
) indicates that the motor speed has not yet stabilized, while'DS13T\n'
(status bytes =='13'
) indicates that the motor is stationary/0Hz. In either case the data acquisition will not commence.Adjust Motor Speed - MS
will not trigger an adjustment if the motor speed has not yet stabilized. Similar to above, the response message will use status bytes to indicate the failure.'00'
indicate normal processing (ie: not issue)'11'
indicate the original command was sent with an invalid parameter'12'
indicate that the motor speed has not yet stabilizedWe need a way to communicate these failures to the user without exiting or destroying the sweep. At the very least, the high level functions in sweep.cc need to be able to handle these conditions. I'm wondering about the following options. @daniel-j-h I am very open to suggestions, but need to get this going ASAP.
sweep_device_start_scanning()
could return false or an int capable of representing success + multiple failure conditions).Ie:
Internal functions could opt to handle some of this logic. For example:
sweep_device_set_motor_speed()
might encounter an error because the motor speed is still adjusting from a previous command. The function could witness the error, wait for the motor speed to stabilize and then try again. All of this could happen without requiring any user code. However, some conditions like invalid parameters or a stationary motor will require user handling.The text was updated successfully, but these errors were encountered: