-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
AP_RangeFinder:add support for RDS02UF radar driver on serial #21646
Conversation
parameter RNGFND1_TYPE is 36
AP_RangeFinder_RDS02UF::AP_RangeFinder_RDS02UF( | ||
RangeFinder::RangeFinder_State &_state, | ||
AP_RangeFinder_Params &_params): | ||
AP_RangeFinder_Backend_Serial(_state, _params) | ||
{ | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be able to do a
use AP_RangeFinder_Backend_Serial::AP_RangeFinder_Backend_Serial;
in the header instead of this empty constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the directions. I will make some changes before submitting them.
uint16_t count = 0; | ||
int16_t nbytes = uart->available(); | ||
while (nbytes-- > 0) { | ||
uint8_t c = uart->read(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't the return type of read
. Need to check for read failure here.
uint8_t parserbuf_index; | ||
uint8_t rev_buffer[RDS02_BUFFER_SIZE]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should have similar names.
*/ | ||
|
||
/** | ||
* RDS02UF Note: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a reference to the datasheet up in here somewhere.
if((data_fc & 0xf0f) == RDS02_TARGET_INFO){ // data_fc = 0x70C + ID * 0x10, ID: 0~0xF | ||
float distance = (rev_buffer[RDS02_DATA_Y_INDEX_H] * 256 + rev_buffer[RDS02_DATA_Y_INDEX_L]) / 100.0f; | ||
_distance_m = distance; | ||
_distance_m = MIN(MAX(RDS02UF_DIST_MIN_CM, uint16_t(_distance_m*100)), RDS02UF_DIST_MAX_CM) * 0.01f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be constrained - this should be used to set the rangefinder as out-of-range-low or out-of-range-high
I created a simulator for this device over here: #21647 |
2758d48
to
5930afc
Compare
|
||
bool decode(uint8_t c); | ||
|
||
const uint8_t crc8_table[256] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitwise operations eliminate the need for tables.
This saves 256 bytes of flash memory.
using namespace SITL; | ||
|
||
|
||
const uint8_t crc8_table[256] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitwise operations eliminate the need for tables.
This saves 256 bytes of flash memory.
We merged a different PR here, also by @zebulon-86 : #23056 @zebulon-86 next time, perhaps, force-push branches rather than opening new PRs :-) Thanks! |
AP_RangeFinder:add support for RDS02UF radar driver on serial
parameter RNGFND1_TYPE is 36
RDS02UF features: