Go to the documentation of this file.
26 #define NSEC_PER_SEC 1000000000
58 #define MAXSTREAM 200000
61 #define SYNC0TIME 8000
66 struct timeval tv,t1,
t2;
75 pthread_cond_t
cond = PTHREAD_COND_INITIALIZER;
76 pthread_mutex_t
mutex = PTHREAD_MUTEX_INITIALIZER;
93 fp = fopen(fname,
"w");
96 for (i = 0; i < length; i++)
109 printf(
"Starting E/BOX test\n");
114 printf(
"ec_init on %s succeeded.\n",ifname);
122 (strcmp(
ec_slave[1].name,
"E/BOX") == 0))
144 (strcmp(
ec_slave[1].name,
"E/BOX") == 0)
147 printf(
"E/BOX found.\n");
157 printf(
"Slave:%d Name:%s Output size:%3dbits Input size:%3dbits State:%2d delay:%d.%d\n",
161 printf(
"Request operational state for all slaves\n");
174 printf(
"Operational state reached for all slaves.\n");
182 for(i = 1; i <= 200; i++)
187 printf(
"PD cycle %5d DCtime %12lld Cnt:%3d Data: %6d %6d %6d %6d %6d %6d %6d %6d \n",
198 printf(
"Not all slaves reached operational state.\n");
203 printf(
"E/BOX not found in slave configuration.\n");
206 printf(
"Request safe operational state for all slaves\n");
218 (strcmp(
ec_slave[1].name,
"E/BOX") == 0))
232 printf(
"No slaves found!\n");
234 printf(
"End E/BOX, close socket\n");
240 printf(
"No socket connection on %s\nExcecute as root\n",ifname);
266 delta = (reftime - 50000) % cycletime;
267 if(delta> (cycletime /2)) { delta= delta - cycletime; }
270 *offsettime = -(delta / 100) - (
integral /20);
283 pthread_mutex_lock(&
mutex);
287 ts.tv_sec = tp.tv_sec;
288 ht = (tp.tv_usec / 1000) + 1;
289 ts.tv_nsec = ht * 1000000;
290 cycletime = *(
int*)ptr * 1000;
298 pthread_cond_timedwait(&
cond, &
mutex, &ts);
316 for(i = 0 ; i < 50 ; i++)
324 for(i = 0 ; i < 50 ; i++)
339 int main(
int argc,
char *argv[])
342 struct sched_param param;
343 int policy = SCHED_OTHER;
345 printf(
"SOEM (Simple Open EtherCAT Master)\nE/BOX test\n");
349 schedp.sched_priority = 30;
350 sched_setscheduler(0, SCHED_FIFO, &
schedp);
362 ctime = atoi(argv[2]);
367 memset(¶m, 0,
sizeof(param));
369 param.sched_priority = 40;
370 pthread_setschedparam(
thread1, policy, ¶m);
377 printf(
"Usage: ebox ifname [cycletime]\nifname = eth0 for example\ncycletime in us\n");
380 schedp.sched_priority = 0;
381 sched_setscheduler(0, SCHED_OTHER, &
schedp);
383 printf(
"End program\n");
boolean ec_configdc(void)
int ec_send_processdata(void)
Headerfile for all ethercat headers.
int ec_init(const char *ifname)
out_EBOX_streamt * out_EBOX
void ecatthread(void *ptr)
struct PACKED out_EBOX_streamt
int ec_config_init(uint8 usetable)
void add_timespec(struct timespec *ts, int64 addtime)
void ec_sync(int64 reftime, int64 cycletime, int64 *offsettime)
int ec_SDOwrite(uint16 Slave, uint16 Index, uint8 SubIndex, boolean CA, int psize, void *p, int Timeout)
int ec_writestate(uint16 slave)
int main(int argc, char *argv[])
in_EBOX_streamt * in_EBOX
struct PACKED in_EBOX_streamt
int output_cvs(char *fname, int length)
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
int ec_receive_processdata(int timeout)
int gettimeofday(struct timeval *tp, void *tzp)
void ec_dcsync0(uint16 slave, boolean act, uint32 CyclTime, int32 CyclShift)
int ec_config_map(void *pIOmap)
void eboxtest(char *ifname)
struct sched_param schedp
soem
Author(s): Arthur Ketels and M.J.G. van den Molengraft
autogenerated on Wed Mar 2 2022 01:01:48