CANopenNode
CANopen protocol stack
|
CANopen access from other networks - ASCII mapping (CiA 309-3 DSP v3.0.0) More...
Topics | |
Command syntax | |
ASCII command syntax. | |
Files | |
file | CO_gateway_ascii.h |
CANopen access from other networks - ASCII mapping (CiA 309-3 DS v3.0.0) | |
Data Structures | |
struct | CO_GTWA_t |
CANopen Gateway-ascii object. More... | |
Macros | |
#define | CO_GTWA_RESP_BUF_SIZE 200U |
Size of response string buffer. | |
#define | CO_GTWA_STATE_TIMEOUT_TIME_US 1200000U |
Timeout time in microseconds for some internal states. | |
Functions | |
CO_ReturnError_t | CO_GTWA_init (CO_GTWA_t *gtwa, CO_SDOclient_t *SDO_C, uint16_t SDOclientTimeoutTime_ms, bool_t SDOclientBlockTransfer, CO_NMT_t *NMT, CO_LSSmaster_t *LSSmaster, CO_LEDs_t *LEDs, uint8_t dummy) |
Initialize Gateway-ascii object. | |
void | CO_GTWA_initRead (CO_GTWA_t *gtwa, size_t(*readCallback)(void *object, const char *buf, size_t count, uint8_t *connectionOK), void *readCallbackObject) |
Initialize read callback in Gateway-ascii object. | |
static size_t | CO_GTWA_write_getSpace (CO_GTWA_t *gtwa) |
Get free write buffer space. | |
static size_t | CO_GTWA_write (CO_GTWA_t *gtwa, const char *buf, size_t count) |
Write command into CO_GTWA_t object. | |
void | CO_GTWA_log_print (CO_GTWA_t *gtwa, const char *message) |
Print message log string into fifo buffer. | |
void | CO_GTWA_process (CO_GTWA_t *gtwa, bool_t enable, uint32_t timeDifference_us, uint32_t *timerNext_us) |
Process Gateway-ascii object. | |
CANopen access from other networks - ASCII mapping (CiA 309-3 DSP v3.0.0)
This module enables ascii command interface (CAN gateway), which can be used for master interaction with CANopen network. Some sort of string input/output stream can be used, for example serial port + terminal on microcontroller or stdio in OS or sockets, etc.
For example, one wants to read 'Heartbeat producer time' parameter (0x1017,0) on remote node (with id=4). Parameter is 16-bit integer. He can can enter command string: [1] 4 read 0x1017 0 i16
. CANopenNode will use SDO client, send request to remote node via CAN, wait for response via CAN and prints [1] OK
to output stream on success.
This module is usually initialized and processed in CANopen.c file. Application should register own callback function for reading the output stream. Application writes new commands with CO_GTWA_write().
#define CO_GTWA_RESP_BUF_SIZE 200U |
Size of response string buffer.
This is intermediate buffer. If there is larger amount of data to transfer, then multiple transfers will occur.
Response error codes as specified by CiA 309-3.
Values less or equal to 0 are used for control for some functions and are not part of the standard.
enum CO_GTWA_state_t |
Internal states of the Gateway-ascii state machine.
CO_ReturnError_t CO_GTWA_init | ( | CO_GTWA_t * | gtwa, |
CO_SDOclient_t * | SDO_C, | ||
uint16_t | SDOclientTimeoutTime_ms, | ||
bool_t | SDOclientBlockTransfer, | ||
CO_NMT_t * | NMT, | ||
CO_LSSmaster_t * | LSSmaster, | ||
CO_LEDs_t * | LEDs, | ||
uint8_t | dummy ) |
Initialize Gateway-ascii object.
gtwa | This object will be initialized |
SDO_C | SDO client object |
SDOclientTimeoutTime_ms | Default timeout in milliseconds, 500 typically |
SDOclientBlockTransfer | If true, block transfer will be set by default |
NMT | NMT object |
LSSmaster | LSS master object |
LEDs | LEDs object |
dummy | dummy argument, set to 0 |
void CO_GTWA_initRead | ( | CO_GTWA_t * | gtwa, |
size_t(* | readCallback )(void *object, const char *buf, size_t count, uint8_t *connectionOK), | ||
void * | readCallbackObject ) |
Initialize read callback in Gateway-ascii object.
Callback will be used for transfer data to output stream of the application. It will be called from CO_GTWA_process() zero or multiple times, depending on the data available. If readCallback is uninitialized or NULL, then output data will be purged.
gtwa | This object will be initialized |
readCallback | Pointer to external function for reading response from Gateway-ascii object. See CO_GTWA_t for parameters. |
readCallbackObject | Pointer to object, which will be used inside readCallback |
|
inlinestatic |
Get free write buffer space.
gtwa | This object |
|
inlinestatic |
Write command into CO_GTWA_t object.
This function copies ascii command from buf into internal fifo buffer. Command must be closed with '
' character. Function returns number of bytes successfully copied. If there is not enough space in destination, not all bytes will be copied and data can be refilled later (in case of large SDO download).
gtwa | This object |
buf | Buffer which will be copied |
count | Number of bytes in buf |
void CO_GTWA_log_print | ( | CO_GTWA_t * | gtwa, |
const char * | message ) |
Print message log string into fifo buffer.
This function enables recording of system log messages including CANopen events. Function can be called by application for recording any message. Message is copied to internal fifo buffer. In case fifo is full, old messages will be owerwritten. Message log fifo can be read with non-standard command "log". After log is read, it is emptied.
gtwa | This object |
message | Null terminated string |
void CO_GTWA_process | ( | CO_GTWA_t * | gtwa, |
bool_t | enable, | ||
uint32_t | timeDifference_us, | ||
uint32_t * | timerNext_us ) |
Process Gateway-ascii object.
This is non-blocking function and must be called cyclically
gtwa | This object will be initialized. | |
enable | If true, gateway operates normally. If false, gateway is completely disabled and no command interaction is possible. Can be connected to hardware switch, for example. | |
timeDifference_us | Time difference from previous function call in [microseconds]. | |
[out] | timerNext_us | info to OS - see CO_process(). |