#include "timer.h"
#include "data.h"
Go to the source code of this file.
Data Structures | |
struct | struct_s_transfer |
struct | BODY |
struct | struct_s_SDO |
Typedefs | |
typedef void(*) | SDOCallback_t (CO_Data *d, UNS8 nodeId) |
typedef struct_s_transfer | s_transfer |
typedef struct_s_SDO | s_SDO |
Functions | |
void | SDOTimeoutAlarm (CO_Data *d, UNS32 id) |
void | resetSDO (CO_Data *d) |
UNS32 | SDOlineToObjdict (CO_Data *d, UNS8 line) |
UNS32 | objdictToSDOline (CO_Data *d, UNS8 line) |
UNS8 | lineToSDO (CO_Data *d, UNS8 line, UNS8 nbBytes, UNS8 *data) |
UNS8 | SDOtoLine (CO_Data *d, UNS8 line, UNS8 nbBytes, UNS8 *data) |
UNS8 | failedSDO (CO_Data *d, UNS8 nodeId, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 abortCode) |
void | resetSDOline (CO_Data *d, UNS8 line) |
UNS8 | initSDOline (CO_Data *d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state) |
UNS8 | getSDOfreeLine (CO_Data *d, UNS8 whoami, UNS8 *line) |
UNS8 | getSDOlineOnUse (CO_Data *d, UNS8 nodeId, UNS8 whoami, UNS8 *line) |
UNS8 | closeSDOtransfer (CO_Data *d, UNS8 nodeId, UNS8 whoami) |
UNS8 | getSDOlineRestBytes (CO_Data *d, UNS8 line, UNS8 *nbBytes) |
UNS8 | setSDOlineRestBytes (CO_Data *d, UNS8 line, UNS8 nbBytes) |
UNS8 | sendSDO (CO_Data *d, UNS8 whoami, s_SDO sdo) |
UNS8 | sendSDOabort (CO_Data *d, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 abortCode) |
UNS8 | proceedSDO (CO_Data *d, Message *m) |
UNS8 | writeNetworkDict (CO_Data *d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 count, UNS8 dataType, void *data) |
UNS8 | writeNetworkDictCallBack (CO_Data *d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback) |
UNS8 | readNetworkDict (CO_Data *d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType) |
UNS8 | readNetworkDictCallback (CO_Data *d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback) |
UNS8 | getReadResultNetworkDict (CO_Data *d, UNS8 nodeId, void *data, UNS8 *size, UNS32 *abortCode) |
UNS8 | getWriteResultNetworkDict (CO_Data *d, UNS8 nodeId, UNS32 *abortCode) |
typedef struct struct_s_SDO s_SDO |
typedef struct struct_s_transfer s_transfer |
typedef void(*) SDOCallback_t(CO_Data *d, UNS8 nodeId) |
UNS8 closeSDOtransfer | ( | CO_Data * | d, | |
UNS8 | nodeId, | |||
UNS8 | whoami | |||
) |
Close a transmission. nodeId : Node id of the server if both server or client whoami : Line opened as SDO_CLIENT or SDO_SERVER
Definition at line 318 of file sdo.c.
References struct_s_timer_entry::d, getSDOlineOnUse(), MSG_WAR, resetSDOline(), and UNS8.
UNS8 failedSDO | ( | CO_Data * | d, | |
UNS8 | nodeId, | |||
UNS8 | whoami, | |||
UNS16 | index, | |||
UNS8 | subIndex, | |||
UNS32 | abortCode | |||
) |
Called when an internal SDO abort occurs. Release the line * Only if server * If client, the line must be released manually in the core application. The reason of that is to permit the program to read the transfers[][] structure before its reset, because many informations are stored on it : index, subindex, data received or trasmited, ... In all cases, sends a SDO abort. Returns 0
Definition at line 227 of file sdo.c.
References struct_s_timer_entry::d, getSDOlineOnUse(), MSG_WAR, resetSDOline(), SDO_ABORTED_INTERNAL, SDO_CLIENT, SDO_SERVER, sendSDOabort(), struct_s_transfer::state, StopSDO_TIMER, struct_CO_Data::transfers, and UNS8.
UNS8 getReadResultNetworkDict | ( | CO_Data * | d, | |
UNS8 | nodeId, | |||
void * | data, | |||
UNS8 * | size, | |||
UNS32 * | abortCode | |||
) |
Use this function after a readNetworkDict to get the result. Returns : SDO_FINISHED // data is available SDO_ABORTED_RCV // Transfert failed. (abort SDO received) SDO_ABORTED_INTERNAL // Transfert failed. Internal abort. SDO_UPLOAD_IN_PROGRESS // Data not yet available SDO_DOWNLOAD_IN_PROGRESS // Should not arrive !
dataType (defined in objdictdef.h) : type expected. put "visible_string" for strings, 0 for integers or reals. abortCode : 0 = not available. Else : SDO abort code. (received if return SDO_ABORTED_RCV) example : UNS32 data; UNS8 size; readNetworkDict(0, 0x05, 0x1016, 1, 0) // get the data index 1016 subindex 1 of node 5 while (getReadResultNetworkDict (0, 0x05, &data, &size) != SDO_UPLOAD_IN_PROGRESS);
Definition at line 1295 of file sdo.c.
References CANOPEN_BIG_ENDIAN, struct_s_transfer::count, struct_s_timer_entry::d, struct_s_transfer::data, struct_s_transfer::dataType, getSDOlineOnUse(), MSG_ERR, SDO_ABORTED_INTERNAL, SDO_CLIENT, SDO_FINISHED, struct_s_transfer::state, struct_CO_Data::transfers, UNS8, and visible_string.
UNS8 getSDOfreeLine | ( | CO_Data * | d, | |
UNS8 | whoami, | |||
UNS8 * | line | |||
) |
Search for an unused line in the transfers array to store a new SDO. ie a line which value of the field "state" is "SDO_RESET" An unused line have the field "state" at the value SDO_RESET bus_id is hardware dependant whoami : create the line for a SDO_SERVER or SDO_CLIENT. return 0xFF if all the lines are on use. Else, return 0
Definition at line 284 of file sdo.c.
References struct_s_timer_entry::d, SDO_MAX_SIMULTANEOUS_TRANSFERTS, SDO_RESET, struct_s_transfer::state, struct_CO_Data::transfers, UNS8, and struct_s_transfer::whoami.
UNS8 getSDOlineOnUse | ( | CO_Data * | d, | |
UNS8 | nodeId, | |||
UNS8 | whoami, | |||
UNS8 * | line | |||
) |
Search for the line, in the transfers array, which contains the beginning of the reception of a fragmented SDO whoami takes 2 values : look for a line opened as SDO_CLIENT or SDO_SERVER bus_id is hardware dependant nodeId correspond to the message node-id return 0xFF if error. Else, return 0
Definition at line 301 of file sdo.c.
References struct_s_timer_entry::d, struct_s_transfer::nodeId, SDO_MAX_SIMULTANEOUS_TRANSFERTS, SDO_RESET, struct_s_transfer::state, struct_CO_Data::transfers, UNS8, and struct_s_transfer::whoami.
UNS8 getSDOlineRestBytes | ( | CO_Data * | d, | |
UNS8 | line, | |||
UNS8 * | nbBytes | |||
) |
Bytes in the line structure which must be transmited (or received) bus_id is hardware dependant. return 0.
Definition at line 332 of file sdo.c.
References struct_s_transfer::count, struct_s_timer_entry::d, struct_s_transfer::offset, struct_CO_Data::transfers, and UNS8.
UNS8 getWriteResultNetworkDict | ( | CO_Data * | d, | |
UNS8 | nodeId, | |||
UNS32 * | abortCode | |||
) |
Use this function after a writeNetworkDict to get the result of the write It is mandatory to call this function because it is releasing the line used for the transfer. Returns : SDO_FINISHED // data is available SDO_ABORTED_RCV // Transfert failed. (abort SDO received) SDO_ABORTED_INTERNAL // Transfert failed. Internal abort. SDO_DOWNLOAD_IN_PROGRESS // Data not yet available SDO_UPLOAD_IN_PROGRESS // Should not arrive ! abortCode : 0 = not available. Else : SDO abort code. (received if return SDO_ABORTED_RCV) example : UNS32 data = 0x50; UNS8 size; UNS32 abortCode; writeNetworkDict(0, 0x05, 0x1016, 1, size, &data) // write the data index 1016 subindex 1 of node 5 while ( getWriteResultNetworkDict (0, 0x05, &abortCode) != SDO_DOWNLOAD_IN_PROGRESS);
Definition at line 1329 of file sdo.c.
References struct_s_transfer::abortCode, struct_s_timer_entry::d, getSDOlineOnUse(), MSG_ERR, SDO_ABORTED_INTERNAL, SDO_CLIENT, struct_s_transfer::state, struct_CO_Data::transfers, and UNS8.
UNS8 initSDOline | ( | CO_Data * | d, | |
UNS8 | line, | |||
UNS8 | nodeId, | |||
UNS16 | index, | |||
UNS8 | subIndex, | |||
UNS8 | state | |||
) |
Initialize some fields of the structure. Returns 0
Definition at line 263 of file sdo.c.
References struct_s_transfer::Callback, struct_s_transfer::count, struct_s_timer_entry::d, struct_s_transfer::dataType, struct_s_transfer::index, MSG_WAR, struct_s_transfer::nodeId, struct_s_transfer::offset, SDO_DOWNLOAD_IN_PROGRESS, SDO_UPLOAD_IN_PROGRESS, StartSDO_TIMER, struct_s_transfer::state, StopSDO_TIMER, struct_s_transfer::subIndex, struct_s_transfer::toggle, and struct_CO_Data::transfers.
UNS8 lineToSDO | ( | CO_Data * | d, | |
UNS8 | line, | |||
UNS8 | nbBytes, | |||
UNS8 * | data | |||
) |
copy data from an existant line in the argument "* data" Returns 0xFF if error. Else, returns 0;
Definition at line 189 of file sdo.c.
References struct_s_transfer::count, struct_s_timer_entry::d, struct_s_transfer::data, MSG_ERR, struct_s_transfer::offset, SDO_MAX_LENGTH_TRANSFERT, struct_CO_Data::transfers, and UNS8.
UNS32 objdictToSDOline | ( | CO_Data * | d, | |
UNS8 | line | |||
) |
Copy the data from the object dictionary to the SDO line for a network transfert. Returns SDO error code if error. Else, returns 0;
Definition at line 157 of file sdo.c.
References struct_s_transfer::count, struct_s_timer_entry::d, struct_s_transfer::data, getODentry(), struct_s_transfer::index, MSG_WAR, OD_SUCCESSFUL, struct_s_transfer::offset, struct_s_transfer::subIndex, struct_CO_Data::transfers, UNS32, and UNS8.
Treat a SDO frame reception bus_id is hardware dependant call the function sendSDO return 0xFF if error 0x80 if transfert aborted by the server 0x0 ok
Definition at line 447 of file sdo.c.
References struct_s_transfer::abortCode, struct_CO_Data::bDeviceNodeId, struct_s_SDO::body, td_indextable::bSubCount, struct_s_transfer::Callback, struct_s_transfer::count, struct_s_timer_entry::d, BODY::data, Message::data, failedSDO(), struct_CO_Data::firstIndex, getSDOc, getSDOcs, getSDOe, getSDOfreeLine(), getSDOindex, getSDOlineOnUse(), getSDOlineRestBytes(), getSDOn2, getSDOn3, getSDOs, getSDOsubIndex, getSDOt, struct_s_transfer::index, initSDOline(), struct_CO_Data::lastIndex, lineToSDO(), MSG_ERR, MSG_WAR, struct_s_SDO::nodeId, struct_CO_Data::objdict, objdictToSDOline(), td_subindex::pObject, td_indextable::pSubindex, resetSDOline(), RestartSDO_TIMER, SDO_ABORTED_RCV, SDO_CLIENT, s_quick_index::SDO_CLT, SDO_DOWNLOAD_IN_PROGRESS, SDO_FINISHED, SDO_SERVER, s_quick_index::SDO_SVR, SDO_UNKNOWN, SDO_UPLOAD_IN_PROGRESS, SDOABT_GENERAL_ERROR, SDOABT_LOCAL_CTRL_ERROR, SDOABT_TOGGLE_NOT_ALTERNED, SDOlineToObjdict(), SDOtoLine(), sendSDO(), setSDOlineRestBytes(), struct_s_transfer::state, StopSDO_TIMER, struct_s_transfer::subIndex, struct_s_transfer::toggle, struct_CO_Data::transfers, UNS16, UNS32, and UNS8.
UNS8 readNetworkDict | ( | CO_Data * | d, | |
UNS8 | nodeId, | |||
UNS16 | index, | |||
UNS8 | subIndex, | |||
UNS8 | dataType | |||
) |
Used by the application to send a SDO request frame to read in the dictionary of a server node whose node_id is ID at the index and subIndex indicated bus_id is hardware dependant datatype (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. return 0xFF if error, else return 0
Definition at line 1282 of file sdo.c.
References _readNetworkDict(), and struct_s_timer_entry::d.
UNS8 readNetworkDictCallback | ( | CO_Data * | d, | |
UNS8 | nodeId, | |||
UNS16 | index, | |||
UNS8 | subIndex, | |||
UNS8 | dataType, | |||
SDOCallback_t | Callback | |||
) |
Used to send a SDO request frame to read in a distant node dictionnary. The function Callback which must be defined in the user code is called at the end of the exchange. (on succes or abort).
Definition at line 1288 of file sdo.c.
References _readNetworkDict(), and struct_s_timer_entry::d.
void resetSDO | ( | CO_Data * | d | ) |
Reset all sdo buffers
Definition at line 131 of file sdo.c.
References struct_s_timer_entry::d, resetSDOline(), SDO_MAX_SIMULTANEOUS_TRANSFERTS, and UNS8.
void resetSDOline | ( | CO_Data * | d, | |
UNS8 | line | |||
) |
Reset an unused line.
Definition at line 253 of file sdo.c.
References struct_s_timer_entry::d, struct_s_transfer::data, initSDOline(), MSG_WAR, SDO_MAX_LENGTH_TRANSFERT, SDO_RESET, struct_CO_Data::transfers, and UNS8.
UNS32 SDOlineToObjdict | ( | CO_Data * | d, | |
UNS8 | line | |||
) |
Copy the data received from the SDO line transfert to the object dictionary Returns SDO error code if error. Else, returns 0;
Definition at line 141 of file sdo.c.
References struct_s_transfer::count, struct_s_timer_entry::d, struct_s_transfer::data, struct_s_transfer::index, MSG_WAR, OD_SUCCESSFUL, setODentry(), struct_s_transfer::subIndex, struct_CO_Data::transfers, UNS32, and UNS8.
void SDOTimeoutAlarm | ( | CO_Data * | d, | |
UNS32 | id | |||
) |
Reset of a SDO exchange on timeout. Send a SDO abort
Definition at line 93 of file sdo.c.
References struct_s_transfer::abortCode, struct_s_transfer::Callback, struct_s_timer_entry::d, struct_s_transfer::index, MSG_ERR, MSG_WAR, struct_s_transfer::nodeId, resetSDOline(), SDO_ABORTED_INTERNAL, SDO_SERVER, SDOABT_TIMED_OUT, sendSDOabort(), struct_s_transfer::state, struct_s_transfer::subIndex, struct_s_transfer::timer, struct_CO_Data::transfers, UNS8, and struct_s_transfer::whoami.
UNS8 SDOtoLine | ( | CO_Data * | d, | |
UNS8 | line, | |||
UNS8 | nbBytes, | |||
UNS8 * | data | |||
) |
Add data to an existant line Returns 0xFF if error. Else, returns 0;
Definition at line 210 of file sdo.c.
References struct_s_timer_entry::d, struct_s_transfer::data, MSG_ERR, struct_s_transfer::offset, SDO_MAX_LENGTH_TRANSFERT, struct_CO_Data::transfers, and UNS8.
Transmit a SDO frame on the bus bus_id sdo is a structure which contains the sdo to transmit bus_id is hardware dependant whoami takes 2 values : SDO_CLIENT or SDO_SERVER return canSend(bus_id,&m) or 0xFF if error
Definition at line 354 of file sdo.c.
References struct_s_SDO::body, td_indextable::bSubCount, struct_CO_Data::canHandle, canSend(), Message::cob_id, struct_s_timer_entry::d, BODY::data, Message::data, struct_CO_Data::firstIndex, struct_CO_Data::lastIndex, Message::len, MSG_ERR, MSG_WAR, struct_s_SDO::nodeId, struct_CO_Data::nodeState, NOT_A_REQUEST, struct_CO_Data::objdict, Operational, td_subindex::pObject, Pre_operational, td_indextable::pSubindex, Message::rtr, s_quick_index::SDO_CLT, SDO_SERVER, s_quick_index::SDO_SVR, UNS16, UNS32, UNS8, and SHORT_CAN::w.
UNS8 sendSDOabort | ( | CO_Data * | d, | |
UNS8 | whoami, | |||
UNS16 | index, | |||
UNS8 | subIndex, | |||
UNS32 | abortCode | |||
) |
Transmit a SDO error to the client. The reasons may be : Read/Write to a undefined object Read/Write to a undefined subindex Read/write a not valid length object Write a read only object whoami takes 2 values : SDO_CLIENT or SDO_SERVER
Definition at line 424 of file sdo.c.
References struct_CO_Data::bDeviceNodeId, struct_s_SDO::body, struct_s_timer_entry::d, BODY::data, MSG_WAR, struct_s_SDO::nodeId, sendSDO(), and UNS8.
UNS8 setSDOlineRestBytes | ( | CO_Data * | d, | |
UNS8 | line, | |||
UNS8 | nbBytes | |||
) |
Store in the line structure the nb of bytes which must be transmited (or received) bus_id is hardware dependant. return 0 if success, 0xFF if error.
Definition at line 342 of file sdo.c.
References struct_s_transfer::count, struct_s_timer_entry::d, MSG_ERR, SDO_MAX_LENGTH_TRANSFERT, and struct_CO_Data::transfers.
UNS8 writeNetworkDict | ( | CO_Data * | d, | |
UNS8 | nodeId, | |||
UNS16 | index, | |||
UNS8 | subIndex, | |||
UNS8 | count, | |||
UNS8 | dataType, | |||
void * | data | |||
) |
Used by the application to send a SDO request frame to write the data *data at the index and subIndex indicated in the dictionary of the slave whose node_id is nodeId Count : nb of bytes to write in the dictionnary. datatype (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. bus_id is hardware dependant return 0xFF if error, else return 0
Definition at line 1182 of file sdo.c.
References _writeNetworkDict(), and struct_s_timer_entry::d.
UNS8 writeNetworkDictCallBack | ( | CO_Data * | d, | |
UNS8 | nodeId, | |||
UNS16 | index, | |||
UNS8 | subIndex, | |||
UNS8 | count, | |||
UNS8 | dataType, | |||
void * | data, | |||
SDOCallback_t | Callback | |||
) |
Used to send a SDO request frame to write in a distant node dictionnary. The function Callback which must be defined in the user code is called at the end of the exchange. (on succes or abort).
Definition at line 1190 of file sdo.c.
References _writeNetworkDict(), and struct_s_timer_entry::d.