You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to configure my node as master and change the operation mode of other nodes in the bus? #97
Hello @michael-hillmann.
Congrats on this project. I've been using it for a couple of months and it is very well done!
Right now I want to configure a node as master.
I need it to reset the communications of all the nodes which listen the bus (ID 0x00, DATA 0x82 0x00), and when I receive the boot up message from each node, send the OPERATIONAL command to each one of them (ID 0x00, DATA 0x01 0x)
I've been reading the NMT API, but I could not find a way to do what I want.
Well, the bad news: as you may read in the documents, this CANopen stack is intended as a "CANopen Slave" only. In the past months, we are going some small steps toward a "CANopen Master". In NMT the feature set reflects 100% Slave only.
On the other hand, the good news: you could solve your network booting by using the callback COIfCanReceive(CO_IF_FRM *frm). This callback function is called for any CAN message in the network, which is not consumed by the CANopen stack. In your callback, you may check the given frm.Identifier to represent a bootup message of an expected CANopen node in your network and send with DrvCanSend(CO_IF_FRM *frm) the network command OPERATIONAL (if one or all expected nodes are received).
I will give a try to your proposition.
I was also thinking to configure my node as a HB consumer and when receiving the boot-up message from the different nodes, send the proper CAN frame with DrvCanSend(CO_IF_FRM *frm).
I think I will try your solution first, which seems easier to implement.
Hey @michael-hillmann.
Sorry to bother you again. But I'm having trouble with sending the command with DrvCanSend(CO_IF_FRM *frm). I cannot access to this function from within the node_callbacks.c file.
Shouldn't I use COIfCanSend(CO_IF *cif, CO_IF_FRM *frm); instead? However, in this case I do not have access to the can interface object either (CO_IF). Which is the proper way to do it?
Thanks again in advance.
Btw.: In case you want to start the nodes according to the simplified NMT startup, which is described in para. 7.3.1: There is a weak definition of "wait for time not specified" before starting all nodes.
This may lead to unstarted nodes when the boot process of these nodes was too slow. I would suggest for a small dedicated network the knowledge of how many nodes must be waiting for the start command:
externCO_NODEClk; /* assume 'CO_NODE Clk' is allocated in global memory */uint8_tnodeCnt=0;
voidCOIfCanReceive(CO_IF_FRM*frm)
{
uint8_tnodeId=0;
if ((frm->Identifier >= 0x701) &&/* see, if a bootup message 1792 + NodeId is received */
(frm->Identifier <= 0x780)) {
nodeId= (uint8_t)(frm->Identifier- (uint32_t)0x700);
nodeCnt++;
if (nodeCnt >= APP_NODES_IN_NETWORK) {
CO_SET_ID(frm, 0x000); /* build NMT protocol frame */CO_SET_BYTE(frm, 0, 0x01); /* 'start remote node' */CO_SET_BYTE(frm, 1, 0x00); /* to all waiting nodes */CO_SET_DLC(frm, 2);
COIfCanSend(&(Clk.If), frm); /* send NMT command */
}
}
}
Thanks for your explanation and recommendations @michael-hillmann. It seems to be working fine. I'll perform some tests and if everything keeps working I'll close the issue.
On the other hand I have another question, but I'll post it on a different issue: #98
Activity
michael-hillmann commentedon Apr 12, 2022
Hi, first: thanks for your kind words.
Well, the bad news: as you may read in the documents, this CANopen stack is intended as a "CANopen Slave" only. In the past months, we are going some small steps toward a "CANopen Master". In NMT the feature set reflects 100% Slave only.
On the other hand, the good news: you could solve your network booting by using the callback
COIfCanReceive(CO_IF_FRM *frm). This callback function is called for any CAN message in the network, which is not consumed by the CANopen stack. In your callback, you may check the givenfrm.Identifierto represent a bootup message of an expected CANopen node in your network and send withDrvCanSend(CO_IF_FRM *frm)the network command OPERATIONAL (if one or all expected nodes are received).guilleherreraf commentedon Apr 12, 2022
Thanks for your quick reply!
I will give a try to your proposition.
I was also thinking to configure my node as a HB consumer and when receiving the boot-up message from the different nodes, send the proper CAN frame with
DrvCanSend(CO_IF_FRM *frm).I think I will try your solution first, which seems easier to implement.
Thank you!
guilleherreraf commentedon Apr 12, 2022
Hey @michael-hillmann.
Sorry to bother you again. But I'm having trouble with sending the command with
DrvCanSend(CO_IF_FRM *frm). I cannot access to this function from within thenode_callbacks.cfile.Shouldn't I use
COIfCanSend(CO_IF *cif, CO_IF_FRM *frm);instead? However, in this case I do not have access to the can interface object either (CO_IF). Which is the proper way to do it?Thanks again in advance.
michael-hillmann commentedon Apr 12, 2022
Ahh, you are absolutely right. The function
DrvCanSend()is not suitable. The functionCOIfCanSend(CO_IF *cif, CO_IF_FRM *frm)is much better:michael-hillmann commentedon Apr 12, 2022
Btw.: In case you want to start the nodes according to the simplified NMT startup, which is described in para. 7.3.1: There is a weak definition of "wait for time not specified" before starting all nodes.
This may lead to unstarted nodes when the boot process of these nodes was too slow. I would suggest for a small dedicated network the knowledge of how many nodes must be waiting for the start command:
guilleherreraf commentedon Apr 13, 2022
Thanks for your explanation and recommendations @michael-hillmann. It seems to be working fine. I'll perform some tests and if everything keeps working I'll close the issue.
On the other hand I have another question, but I'll post it on a different issue: #98
michael-hillmann commentedon Sep 12, 2023
Hi, I guess your system is running fine. Closing this issue. In case of trouble, feel free to reopen it again.