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

tap_esc cleanup #9313

Merged
merged 11 commits into from
Apr 18, 2018
Merged

tap_esc cleanup #9313

merged 11 commits into from
Apr 18, 2018

Conversation

potaito
Copy link
Contributor

@potaito potaito commented Apr 16, 2018

  • Converted tap_esc driver to a px4_module
  • Moved more common functionality to tap_esc_common
  • Removed lots of unused code and variables

@bkueng Do you have time to review? It's low priority, and maybe you'll have to to through the individual commits in order to make sense of it.

The PR has been bench-tested on the Aero.

Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup & refactoring


int enable_flow_control(int uart_fd, bool enabled);

int send_packet(int uart_fd, EscPacket &packet, int responder);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const EscPacket &packet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it would make more sense. However, send_packet will calculate and fill in the CRC checksum. That's why it cannot be const at this point. We could of course take the CRC calculation out of send_packet, but I'm not sure if that's more intuitive :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I did not see that. It's fine then.


// clean up the alternate device node
//unregister_class_devname(PWM_OUTPUT_BASE_DEVICE_PATH, _class_instance);
if (tap_esc->init() != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a nullptr check before dereferencing tap_esc

SCHED_PRIORITY_ACTUATOR_OUTPUTS,
1100,
(px4_main_t)&run_trampoline,
nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass argv here, you can do the argument parsing in instantiate and _channels_count, _device don't need to be static (the static variables will occupy the RAM even if the driver is not started).

@@ -84,19 +84,6 @@
class TAP_ESC : public device::CDev, public ModuleBase<TAP_ESC>, public ModuleParams
{
public:
enum Mode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see this gone

uint16_t rpm[TAP_ESC_MAX_MOTOR_NUM];
memset(rpm, 0, sizeof(rpm));
uint8_t motor_cnt = num_pwm;
static uint8_t which_to_respone = 0;
static uint8_t responder = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a class member instead of static?

@potaito
Copy link
Contributor Author

potaito commented Apr 17, 2018

@bkueng Thanks for the review. I addressed your comments in a new commit: f0e4d74

Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bkueng bkueng merged commit 5ebe762 into master Apr 18, 2018
@bkueng bkueng deleted the tap-esc-cleanup branch April 18, 2018 05:48
bkueng pushed a commit that referenced this pull request Apr 18, 2018
MaEtUgR pushed a commit that referenced this pull request Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants