CANopenNode
CO_epoll_interface.h
Go to the documentation of this file.
1 
29 #ifndef CO_EPOLL_INTERFACE_H
30 #define CO_EPOLL_INTERFACE_H
31 
32 #include "CANopen.h"
33 
34 #include <sys/epoll.h>
35 #include <sys/eventfd.h>
36 #include <sys/timerfd.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
89 typedef struct {
91  int epoll_fd;
93  int event_fd;
95  int timer_fd;
109  struct itimerspec tm;
111  struct epoll_event ev;
114 } CO_epoll_t;
115 
130 CO_ReturnError_t CO_epoll_create(CO_epoll_t *ep, uint32_t timerInterval_us);
131 
137 void CO_epoll_close(CO_epoll_t *ep);
138 
148 void CO_epoll_wait(CO_epoll_t *ep);
149 
162 
172 
186  CO_t *co,
187  bool_t enableGateway,
188  CO_NMT_reset_cmd_t *reset);
189 
190 
212  CO_t *co,
213  bool_t realtime);
214 
215 
216 #if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII) || defined CO_DOXYGEN
217 
220 typedef enum {
221  CO_COMMAND_IF_DISABLED = -100,
222  CO_COMMAND_IF_STDIO = -2,
223  CO_COMMAND_IF_LOCAL_SOCKET = -1,
224  CO_COMMAND_IF_TCP_SOCKET_MIN = 0,
225  CO_COMMAND_IF_TCP_SOCKET_MAX = 0xFFFF
227 
231 typedef struct {
233  int epoll_fd;
246  int gtwa_fd;
250 
267  int epoll_fd,
268  int32_t commandInterface,
269  uint32_t socketTimeout_ms,
270  char *localSocketPath);
271 
277 void CO_epoll_closeGtw(CO_epoll_gtw_t *epGtw);
278 
286 
299  CO_t *co,
300  CO_epoll_t *ep);
301 #endif /* (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII */
302 
305 #ifdef __cplusplus
306 }
307 #endif /*__cplusplus*/
308 
309 #endif /* CO_EPOLL_INTERFACE_H */
uint32_t
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition: CO_driver.h:155
CO_epoll_gtw_t::epoll_fd
int epoll_fd
Epoll file descriptor, from CO_epoll_createGtw()
Definition: CO_epoll_interface.h:233
CO_epoll_processRT
void CO_epoll_processRT(CO_epoll_t *ep, CO_t *co, bool_t realtime)
Process CAN receive and realtime functions.
Definition: CO_epoll_interface.c:304
CO_commandInterface_t
CO_commandInterface_t
Command interface type for gateway-ascii.
Definition: CO_epoll_interface.h:220
CO_epoll_gtw_t
Object for gateway.
Definition: CO_epoll_interface.h:231
CO_ReturnError_t
CO_ReturnError_t
Return values of some CANopen functions.
Definition: CO_driver.h:488
CO_epoll_gtw_t::localSocketPath
char * localSocketPath
Path in case of local socket.
Definition: CO_epoll_interface.h:242
CO_epoll_gtw_t::gtwa_fd
int gtwa_fd
Gateway io stream file descriptor.
Definition: CO_epoll_interface.h:246
bool_t
unsigned char bool_t
Boolean data type for general use.
Definition: CO_driver.h:141
CO_epoll_processGtw
void CO_epoll_processGtw(CO_epoll_gtw_t *epGtw, CO_t *co, CO_epoll_t *ep)
Process CANopen gateway functions.
int32_t
signed long int int32_t
INTEGER32 in CANopen (0004h), 32-bit signed integer.
Definition: CO_driver.h:147
CO_NMT_reset_cmd_t
CO_NMT_reset_cmd_t
Return code from CO_NMT_process() that tells application code what to reset.
Definition: CO_NMT_Heartbeat.h:112
uint64_t
unsigned long long int uint64_t
UNSIGNED64 in CANopen (001Bh), 64-bit unsigned integer.
Definition: CO_driver.h:157
CO_epoll_wait
void CO_epoll_wait(CO_epoll_t *ep)
Wait for an epoll event.
Definition: CO_epoll_interface.c:138
CO_epoll_processMain
void CO_epoll_processMain(CO_epoll_t *ep, CO_t *co, bool_t enableGateway, CO_NMT_reset_cmd_t *reset)
Process CANopen mainline functions.
Definition: CO_epoll_interface.c:286
CO_epoll_t::timer_fd
int timer_fd
Interval timer file descriptor.
Definition: CO_epoll_interface.h:95
CO_epoll_gtw_t::commandInterface
int32_t commandInterface
Command interface type or tcp port number, see CO_commandInterface_t.
Definition: CO_epoll_interface.h:236
CO_epoll_initCANopenMain
void CO_epoll_initCANopenMain(CO_epoll_t *ep, CO_t *co)
Initialization of functions in CANopen reset-communication section.
Definition: CO_epoll_interface.c:232
CO_epoll_t::timerNext_us
uint32_t timerNext_us
Timer value in microseconds, which can be changed by application and can shorten time of next CO_epol...
Definition: CO_epoll_interface.h:103
CO_epoll_gtw_t::socketTimeoutTmr_us
uint32_t socketTimeoutTmr_us
Socket timeout timer in microseconds.
Definition: CO_epoll_interface.h:240
CO_epoll_t::timerEvent
bool_t timerEvent
True,if timer event is inside CO_epoll_wait()
Definition: CO_epoll_interface.h:105
CO_epoll_t
Object for epoll, timer and event API.
Definition: CO_epoll_interface.h:89
CO_epoll_t::epoll_new
bool_t epoll_new
true, if new epoll event is necessary to process
Definition: CO_epoll_interface.h:113
CO_epoll_create
CO_ReturnError_t CO_epoll_create(CO_epoll_t *ep, uint32_t timerInterval_us)
Create Linux epoll, timerfd and eventfd.
Definition: CO_epoll_interface.c:63
CANopen.h
Main CANopenNode file.
CO_epoll_t::timeDifference_us
uint32_t timeDifference_us
Time difference since last CO_epoll_wait() execution in microseconds.
Definition: CO_epoll_interface.h:100
CO_epoll_gtw_t::socketTimeout_us
uint32_t socketTimeout_us
Socket timeout in microseconds.
Definition: CO_epoll_interface.h:238
CO_epoll_close
void CO_epoll_close(CO_epoll_t *ep)
Close epoll, timerfd and eventfd.
Definition: CO_epoll_interface.c:122
CO_epoll_processLast
void CO_epoll_processLast(CO_epoll_t *ep)
Closing function for an epoll event.
Definition: CO_epoll_interface.c:187
CO_epoll_initCANopenGtw
void CO_epoll_initCANopenGtw(CO_epoll_gtw_t *epGtw, CO_t *co)
Initialization of gateway functions in CANopen reset-communication section.
CO_epoll_closeGtw
void CO_epoll_closeGtw(CO_epoll_gtw_t *epGtw)
Close gateway-ascii sockets.
CO_epoll_t::event_fd
int event_fd
Notification event file descriptor.
Definition: CO_epoll_interface.h:93
CO_t
CANopen object - collection of all CANopenNode objects.
Definition: CANopen.h:301
CO_epoll_t::epoll_fd
int epoll_fd
Epoll file descriptor.
Definition: CO_epoll_interface.h:91
CO_epoll_t::timerInterval_us
uint32_t timerInterval_us
Interval of the timer in microseconds, from CO_epoll_create()
Definition: CO_epoll_interface.h:97
CO_epoll_createGtw
CO_ReturnError_t CO_epoll_createGtw(CO_epoll_gtw_t *epGtw, int epoll_fd, int32_t commandInterface, uint32_t socketTimeout_ms, char *localSocketPath)
Create socket for gateway-ascii command interface and add it to epoll.
CO_epoll_t::previousTime_us
uint64_t previousTime_us
time value from the last process call in microseconds
Definition: CO_epoll_interface.h:107
CO_epoll_gtw_t::freshCommand
bool_t freshCommand
Indication of fresh command.
Definition: CO_epoll_interface.h:248
CO_epoll_gtw_t::gtwa_fdSocket
int gtwa_fdSocket
Gateway socket file descriptor.
Definition: CO_epoll_interface.h:244