-
Notifications
You must be signed in to change notification settings - Fork 1
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
FWT-146 Start Drinking On (SDO) company time #112
base: main
Are you sure you want to change the base?
Conversation
…re/diegolhendrix/sdo-sample
…re/diegolhendrix/sdo-sample
…re/diegolhendrix/sdo-sample
…re/diegolhendrix/sdo-sample
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.
Just a few changes, mostly should make a method to register a callback that is used by the sdo.
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.
A good start
include/core/io/CANopen.hpp
Outdated
* @param node[in] The SDO node | ||
* @param sampleDataArray[in] The value to set sample data to | ||
*/ | ||
CO_ERR SDOTransfer(CO_NODE &node, uint8_t *data, uint8_t size, uint32_t entry); |
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.
@mjh9585 Do you think it's worth converting the error to a different type? That's what we do for the HAL and ThreadX
{ | ||
/* Communication Object SDO Server */ | ||
.Key = CO_KEY(0x1280, 0x00, CO_OBJ_D___R_), | ||
.Type = CO_TUNSIGNED32, | ||
.Data = (CO_DATA) 0x03, | ||
}, | ||
{ | ||
/* SDO Server Request COBID */ | ||
.Key = CO_KEY(0x1280, 0x01, CO_OBJ_D___R_), | ||
.Type = CO_TUNSIGNED32, | ||
.Data = (CO_DATA) CO_COBID_SDO_REQUEST(), | ||
}, | ||
{ | ||
/* SDO Server Response COBID */ | ||
.Key = CO_KEY(0x1280, 0x02, CO_OBJ_D___R_), | ||
.Type = CO_TUNSIGNED32, | ||
.Data = (CO_DATA) CO_COBID_SDO_RESPONSE(), | ||
}, | ||
{ | ||
/* Node ID of Server */ | ||
.Key = CO_KEY(0x1280, 0x03, CO_OBJ_D___R_), | ||
.Type = CO_TUNSIGNED8, | ||
.Data = (CO_DATA) 1, |
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.
It would be great to have macros for these
|
||
while (1) { | ||
if ((HAL_GetTick() - lastUpdate1) >= 1000) { // If 1000ms have passed receive CAN message. | ||
testCanNode.receiveData(canNode); // Receive data from server |
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.
I really do not like that you have to pass the CO_NODE in every time you call this function. I think it might be better to store the CO_NODE in SDOCanNode, but I'm not sure because you'd have to make a function to get a pointer to pass into io::processCANopenNode
. @mjh9585 what do you think?
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.
I think it is fine as you still have to pass it into io::processCANopenNode
and an extra method to access CO_NODE from SDOCanNode would make it harder to follow. Perhaps a better approach would be to pass a pointer to CO_NODE into the constructor instead.
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.
Just a couple of changes. Make sure to clean up leftover code from the unresolved comments.
uint8_t* data = message.getPayload(); | ||
for (int i = 0; i < message.getDataLength(); i++) { | ||
uart.printf("%X ", *data); | ||
log::LOGGER.log(log::Logger::LogLevel::INFO, "%X ", *data); |
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 logging each byte, build a string of the data and print 1 log message.
*/ | ||
CO_CSDO* csdo = COCSdoFind(&(node), 0); | ||
|
||
core::io::registerCallBack(AppCallback, reinterpret_cast<void*>(csdo)); // Register callback function |
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.
If you are registering a global callback you should probably not be registering it in this method.
void registerCallBack(void (*AppCallback)(CO_CSDO* csdo, uint16_t index, uint8_t sub, uint32_t code), | ||
void* AppContext) { | ||
callback = AppCallback; | ||
context = AppContext; |
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.
How are you passing this context into the callback? You need some other method to apply the context to your callback.
No description provided.