-
Notifications
You must be signed in to change notification settings - Fork 0
Sabertooth packetized serial #18
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
base: main
Are you sure you want to change the base?
Conversation
fix mollies mistake
include/Sabertooth.hpp
Outdated
|
|
||
| speed = constrain(speed, 0, 127); | ||
|
|
||
| int address = 130; |
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 shouldnt be a hardcoded value
include/Sabertooth.hpp
Outdated
| byte command; | ||
|
|
||
| if (motor != 0 || motor != 1) { | ||
| printf("invalid motor"); |
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.
As of now, debug statements are completely ignored by the Raspberry Pi and if we do implement logging it will have to be a custom solution (we will have to make our own print function, not printf). For now you can remove the print statement and simply do nothing if the function receives bad input data. Definitely still perform the validation though
include/Sabertooth.hpp
Outdated
| this->baudrate = baudrate; | ||
| this->serial->begin(baudrate); | ||
|
|
||
| serial->write(0b10101010); |
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 is a quite mysterious line of code without immediate access to the datasheet. A short explanation would help a lot here
| return; | ||
| } | ||
|
|
||
| this->serial = serial; |
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.
Instead of beginning the serial port when the Sabertooth object is created, add an init function which does this stuff. This is mainly cleanup for my previous mistakes but should be included in this review anyways
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.
Rename this class to SabertoothDriver. This is much more clear about what the purpose of the class is. Again, cleanup for my mistakes but is relevant to this review
Changed