Go to the documentation of this file.
27 #ifndef CO_GATEWAY_ASCII_H
28 #define CO_GATEWAY_ASCII_H
39 #define CO_CONFIG_GTW (0)
42 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII) || defined CO_DOXYGEN
150 #ifndef CO_GTWA_RESP_BUF_SIZE
151 #define CO_GTWA_RESP_BUF_SIZE 200
156 #ifndef CO_GTWA_STATE_TIMEOUT_TIME_US
157 #define CO_GTWA_STATE_TIMEOUT_TIME_US 1200000
265 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO) || defined CO_DOXYGEN
289 } CO_GTWA_dataType_t;
307 size_t (*readCallback)(
void *object,
345 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO) || defined CO_DOXYGEN
359 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_NMT) || defined CO_DOXYGEN
363 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LSS) || defined CO_DOXYGEN
385 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LOG) || defined CO_DOXYGEN
391 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_PRINT_HELP) || defined CO_DOXYGEN
394 size_t helpStringOffset;
396 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_PRINT_LEDS) || defined CO_DOXYGEN
399 uint8_t ledStringPreviousIndex;
419 #
if ((
CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO) || defined CO_DOXYGEN
422 bool_t SDOclientBlockTransfer,
424 #
if ((
CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_NMT) || defined CO_DOXYGEN
427 #
if ((
CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LSS) || defined CO_DOXYGEN
430 #
if ((
CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_PRINT_LEDS) || defined CO_DOXYGEN
451 size_t (*readCallback)(
void *
object,
455 void *readCallbackObject);
493 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LOG) || defined CO_DOXYGEN
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition: CO_driver.h:155
CO_fifo_t commFifo
CO_fifo_t object for command (not pointer)
Definition: CO_gateway_ascii.h:325
Interface between CAN hardware and CANopenNode.
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.
CO_NMT_t * NMT
NMT object from CO_GTWA_init()
Definition: CO_gateway_ascii.h:361
uint16_t lssBitrate
LSS bitrate parameter.
Definition: CO_gateway_ascii.h:371
@ CO_GTWA_respErrorLSSmanufacturer
501 - LSS implementation- / manufacturer-specific error
Definition: CO_gateway_ascii.h:211
LEDs object, initialized by CO_LEDs_init()
Definition: CO_LEDs.h:93
uint8_t node
Current CANopen Node ID.
Definition: CO_gateway_ascii.h:323
SDO client object.
Definition: CO_SDOclient.h:67
uint32_t sequence
Sequence number of the command.
Definition: CO_gateway_ascii.h:315
static size_t CO_GTWA_write(CO_GTWA_t *gtwa, const char *buf, size_t count)
Write command into CO_GTWA_t object.
Definition: CO_gateway_ascii.h:485
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition: CO_driver.h:153
uint8_t lssNodeCount
LSS allnodes node count parameter.
Definition: CO_gateway_ascii.h:379
CANopen Service Data Object - client protocol.
@ CO_GTWA_ST_LSS_INQUIRE
LSS 'lss_inquire_addr' or 'lss_get_node'.
Definition: CO_gateway_ascii.h:249
CO_ReturnError_t
Return values of some CANopen functions.
Definition: CO_driver.h:488
@ CO_GTWA_ST_IDLE
Gateway is idle, no command is processing.
Definition: CO_gateway_ascii.h:231
@ CO_GTWA_ST__LSS_FASTSCAN
LSS '_lss_fastscan'.
Definition: CO_gateway_ascii.h:253
const char * helpString
Offset, when printing help text.
Definition: CO_gateway_ascii.h:393
unsigned char bool_t
Boolean data type for general use.
Definition: CO_driver.h:141
uint8_t lssSubState
LSS allnodes sub state parameter.
Definition: CO_gateway_ascii.h:377
CO_LSS_cs_t lssInquireCs
LSS inquire parameter.
Definition: CO_gateway_ascii.h:373
CO_LSS_cs_t
LSS protocol command specifiers.
Definition: CO_LSS.h:86
CANopen Layer Setting Service - master protocol.
CO_LSSmaster_fastscan_t lssFastscan
LSS fastscan parameter.
Definition: CO_gateway_ascii.h:375
signed long int int32_t
INTEGER32 in CANopen (0004h), 32-bit signed integer.
Definition: CO_driver.h:147
bool_t respHold
See respBufOffset above.
Definition: CO_gateway_ascii.h:338
@ CO_GTWA_ST_WRITE
SDO 'write' (download)
Definition: CO_gateway_ascii.h:235
@ CO_GTWA_respErrorHeartbeatStarted
202 - Heartbeat started
Definition: CO_gateway_ascii.h:189
@ CO_GTWA_respErrorPDOlengthExceeded
401 - PDO length exceeded
Definition: CO_gateway_ascii.h:209
void * readCallbackObject
Pointer to object, which will be used inside readCallback, from CO_GTWA_init()
Definition: CO_gateway_ascii.h:313
CO_LSS_address_t lssAddress
128 bit number, uniquely identifying each node
Definition: CO_gateway_ascii.h:367
@ CO_GTWA_respErrorBusOff
301 - Bus off
Definition: CO_gateway_ascii.h:199
NMT consumer and Heartbeat producer object.
Definition: CO_NMT_Heartbeat.h:162
@ CO_GTWA_respErrorLSSnodeIdNotSupported
502 - LSS node-ID not supported
Definition: CO_gateway_ascii.h:213
bool_t lssStore
LSS allnodes store parameter.
Definition: CO_gateway_ascii.h:381
@ CO_GTWA_ST_LSS_CONF_BITRATE
LSS 'lss_conf_bitrate'.
Definition: CO_gateway_ascii.h:245
static size_t CO_GTWA_write_getSpace(CO_GTWA_t *gtwa)
Get free write buffer space.
Definition: CO_gateway_ascii.h:465
CO_LEDs_t * LEDs
CO_LEDs_t object for CANopen status LEDs imitation from CO_GTWA_init()
Definition: CO_gateway_ascii.h:398
@ CO_GTWA_respErrorLostGuardingMessage
200 - Lost guarding message
Definition: CO_gateway_ascii.h:185
#define CO_GTWA_RESP_BUF_SIZE
Size of response string buffer.
Definition: CO_gateway_ascii.h:151
CO_SDOclient_t * SDO_C
SDO client object from CO_GTWA_init()
Definition: CO_gateway_ascii.h:347
@ CO_GTWA_respErrorLSSmediaError
505 - LSS command failed because of media error
Definition: CO_gateway_ascii.h:219
@ CO_GTWA_respErrorWrongNMTstate
204 - Wrong NMT state
Definition: CO_gateway_ascii.h:193
uint16_t net
Current CANopen Net number.
Definition: CO_gateway_ascii.h:321
@ CO_GTWA_respErrorLostConnection
201 - Lost connection
Definition: CO_gateway_ascii.h:187
#define CO_CONFIG_GTW
Configuration of Gateway ASCII mapping.
Definition: CO_config.h:595
CO_LSSmaster_t * LSSmaster
LSSmaster object from CO_GTWA_init()
Definition: CO_gateway_ascii.h:365
uint8_t lssNID
LSS Node-ID parameter.
Definition: CO_gateway_ascii.h:369
CO_GTWA_state_t
Internal states of the Gateway-ascii state machine.
Definition: CO_gateway_ascii.h:228
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.
@ CO_GTWA_respErrorNoDefaultNodeSet
105 - No default node set
Definition: CO_gateway_ascii.h:179
uint16_t lssTimeout_ms
LSS allnodes timeout parameter.
Definition: CO_gateway_ascii.h:383
@ CO_GTWA_respErrorCANinit
304 - CAN init
Definition: CO_gateway_ascii.h:203
const CO_GTWA_dataType_t * SDOdataType
Data type of variable in current SDO communication.
Definition: CO_gateway_ascii.h:357
@ CO_GTWA_respErrorSyntax
101 - Syntax error
Definition: CO_gateway_ascii.h:171
CO_fifo_st
Bitfields for status argument from CO_fifo_cpyTok2U8 function and similar.
Definition: CO_fifo.h:472
Parameters for LSS fastscan CO_LSSmaster_IdentifyFastscan.
Definition: CO_LSSmaster.h:407
LSS master object.
Definition: CO_LSSmaster.h:108
@ CO_GTWA_respErrorNone
0 - No error or idle
Definition: CO_gateway_ascii.h:167
uint16_t SDOtimeoutTime
Timeout time for SDO transfer in milliseconds, if no response.
Definition: CO_gateway_ascii.h:349
@ CO_GTWA_respErrorTimeOut
103 - Time-out (where applicable)
Definition: CO_gateway_ascii.h:175
@ CO_GTWA_respErrorLSSparameterStoringFailed
504 - LSS parameter storing failed
Definition: CO_gateway_ascii.h:217
Fifo object.
Definition: CO_fifo.h:60
@ CO_GTWA_respErrorErrorPassive
300 - Error passive
Definition: CO_gateway_ascii.h:197
@ CO_GTWA_ST_LSS_SWITCH_GLOB
LSS 'lss_switch_glob'.
Definition: CO_gateway_ascii.h:239
@ CO_GTWA_ST_LSS_STORE
LSS 'lss_store'.
Definition: CO_gateway_ascii.h:247
int16_t node_default
Default CANopen Node ID number is undefined (-1) at startup.
Definition: CO_gateway_ascii.h:319
@ CO_GTWA_ST_LSS_INQUIRE_ADDR_ALL
LSS 'lss_inquire_addr', all parameters.
Definition: CO_gateway_ascii.h:251
@ CO_GTWA_respErrorUnsupportedNet
106 - Unsupported net
Definition: CO_gateway_ascii.h:181
CANopen Network management and Heartbeat producer protocol.
size_t CO_fifo_write(CO_fifo_t *fifo, const char *buf, size_t count, uint16_t *crc)
Write data into CO_fifo_t object.
signed int int16_t
INTEGER16 in CANopen (0003h), 16-bit signed integer.
Definition: CO_driver.h:145
void CO_GTWA_process(CO_GTWA_t *gtwa, bool_t enable, uint32_t timeDifference_us, uint32_t *timerNext_us)
Process Gateway-ascii object.
@ CO_GTWA_ST_LED
print 'status' of the node
Definition: CO_gateway_ascii.h:261
@ CO_GTWA_respErrorUnsupportedNode
107 - Unsupported node
Definition: CO_gateway_ascii.h:183
uint32_t stateTimeoutTmr
Timeout timer for the current state.
Definition: CO_gateway_ascii.h:344
CO_GTWA_respErrorCode_t
Response error codes as specified by CiA 309-3.
Definition: CO_gateway_ascii.h:165
@ CO_GTWA_respErrorReqNotSupported
100 - Request not supported
Definition: CO_gateway_ascii.h:169
@ CO_GTWA_respErrorPDOalreadyUsed
400 - PDO already used
Definition: CO_gateway_ascii.h:207
@ CO_GTWA_respErrorCANactive
305 - CAN active (at init or start-up)
Definition: CO_gateway_ascii.h:205
@ CO_GTWA_respErrorInternalState
102 - Request not processed due to internal state
Definition: CO_gateway_ascii.h:173
#define NULL
NULL, for general usage.
Definition: CO_driver.h:135
@ CO_GTWA_ST_LOG
print message 'log'
Definition: CO_gateway_ascii.h:257
#define CO_CONFIG_GTWA_LOG_BUF_SIZE
Size of message log buffer in ASCII gateway object.
Definition: CO_config.h:632
#define CO_CONFIG_GTWA_COMM_BUF_SIZE
Size of command buffer in ASCII gateway object.
Definition: CO_config.h:625
@ CO_GTWA_ST_WRITE_ABORTED
SDO 'write' (download) - aborted, purging remaining data.
Definition: CO_gateway_ascii.h:237
@ CO_GTWA_respErrorNoDefaultNetSet
104 - No default net set
Definition: CO_gateway_ascii.h:177
size_t respBufOffset
If only part of data has been successfully written into external application (with readCallback()),...
Definition: CO_gateway_ascii.h:336
CO_fifo_t logFifo
CO_fifo_t object for message log (not pointer)
Definition: CO_gateway_ascii.h:389
@ CO_GTWA_ST_LSS_SWITCH_SEL
LSS 'lss_switch_sel'.
Definition: CO_gateway_ascii.h:241
@ CO_GTWA_respErrorRunningOutOfMemory
600 - Running out of memory
Definition: CO_gateway_ascii.h:221
CANopen Indicator specification (CiA 303-3 v1.4.0)
@ CO_GTWA_ST_LSS_ALLNODES
LSS 'lss_allnodes'.
Definition: CO_gateway_ascii.h:255
int32_t net_default
Default CANopen Net number is undefined (-1) at startup.
Definition: CO_gateway_ascii.h:317
bool_t SDOdataCopyStatus
Indicate status of data copy from / to SDO buffer.
Definition: CO_gateway_ascii.h:355
bool_t SDOblockTransferEnable
SDO block transfer enabled?
Definition: CO_gateway_ascii.h:351
CO_GTWA_state_t state
Current state of the gateway object.
Definition: CO_gateway_ascii.h:342
The LSS address is a 128 bit number, uniquely identifying each node.
Definition: CO_LSS.h:162
@ CO_GTWA_respErrorCANbufferOverflow
303 - CAN buffer overflow
Definition: CO_gateway_ascii.h:201
uint32_t timeDifference_us_cumulative
Sum of time difference from CO_GTWA_process() in case of respHold.
Definition: CO_gateway_ascii.h:340
@ CO_GTWA_ST_READ
SDO 'read' (upload)
Definition: CO_gateway_ascii.h:233
@ CO_GTWA_respErrorHeartbeatLost
203 - Heartbeat lost
Definition: CO_gateway_ascii.h:191
void CO_GTWA_log_print(CO_GTWA_t *gtwa, const char *message)
Print message log string into fifo buffer.
@ CO_GTWA_ST_HELP
print 'help' text
Definition: CO_gateway_ascii.h:259
static size_t CO_fifo_getSpace(CO_fifo_t *fifo)
Get free buffer space in CO_fifo_t object.
Definition: CO_fifo.h:138
CANopen Gateway-ascii object.
Definition: CO_gateway_ascii.h:296
unsigned char uint8_t
UNSIGNED8 in CANopen (0005h), 8-bit unsigned integer.
Definition: CO_driver.h:151
@ CO_GTWA_ST_LSS_SET_NODE
LSS 'lss_set_node'.
Definition: CO_gateway_ascii.h:243
size_t respBufCount
Actual size of data in respBuf.
Definition: CO_gateway_ascii.h:331
@ CO_GTWA_respErrorBootUp
205 - Boot-up
Definition: CO_gateway_ascii.h:195
@ CO_GTWA_respErrorLSSbitRateNotSupported
503 - LSS bit-rate not supported
Definition: CO_gateway_ascii.h:215