Go to the documentation of this file.
18 #define pPORTFIO_SET ((vuint16_t *)PORTFIO_SET)
19 #define pPORTFIO_CLEAR ((vuint16_t *)PORTFIO_CLEAR)
20 #define pPORTFIO_DIR ((vuint16_t *)PORTFIO_DIR)
31 #define NUMBER_OF_SLAVES 9
106 data_ptr += module_index * 4;
110 return_value = *data_ptr++;
111 return_value += (*data_ptr++ << 8);
112 return_value += (*data_ptr++ << 16);
113 return_value += (*data_ptr++ << 24);
124 data_ptr += module_index * 4;
128 *data_ptr++ = (value >> 0) & 0xFF;
129 *data_ptr++ = (value >> 8) & 0xFF;
130 *data_ptr++ = (value >> 16) & 0xFF;
131 *data_ptr++ = (value >> 24) & 0xFF;
139 if (*
ec_slave[slave_no].inputs & BIT (module_index - 1 + startbit))
153 data_ptr += module_index * 2;
157 return_value = *data_ptr++;
158 return_value += (*data_ptr++ << 8);
169 data_ptr += module_index * 2;
173 *data_ptr++ = (value >> 0) & 0xFF;
174 *data_ptr++ = (value >> 8) & 0xFF;
182 if (*
ec_slave[slave_no].outputs & BIT (module_index - 1 + startbit))
219 rprintp (
"Processor load was %d:%d:%d (1s:5s:10s) with TT errors: %d\n",
251 rprintp(
"Starting simple test\n");
256 rprintp(
"ec_init succeeded.\n");
269 rprintp(
"Slaves mapped, state to SAFE_OP.\n");
276 rprintp(
"\nSlave:%d\n Name:%s\n Output size: %dbits\n Input size: %dbits\n State: %d\n Delay: %d[ns]\n Has DC: %d\n",
279 rprintp(
" Configured address: %x\n",
ec_slave[cnt].configadr);
280 rprintp(
" Outputs address: %x\n",
ec_slave[cnt].outputs);
281 rprintp(
" Inputs address: %x\n",
ec_slave[cnt].inputs);
285 rprintp(
" FMMU%1d Ls:%x Ll:%4d Lsb:%d Leb:%d Ps:%x Psb:%d Ty:%x Act:%x\n",
j,
290 rprintp(
" FMMUfunc 0:%d 1:%d 2:%d 3:%d\n",
295 rprintp(
"Request operational state for all slaves\n");
306 rprintp(
"Operational state reached for all slaves.\n");
310 rprintp(
"Not all slaves reached operational state.\n");
316 rprintp(
"Slave %d State=0x%04x StatusCode=0x%04x\n",
361 task_delay(tick_from_ms(20));
363 task_delay(tick_from_ms(5));
379 task_delay(tick_from_ms(2));
385 rprintp(
"Mismatch of network units!\n");
390 rprintp(
"No slaves found!\n");
392 rprintp(
"End simple test, close socket\n");
398 rprintp(
"ec_init failed");
400 rprintp(
"End program\n");
407 ASSERT (timeout_us > 4000);
425 #define USECS_PER_SEC 1000000
426 #define USECS_PER_TICK (USECS_PER_SEC / CFG_TICKS_PER_SECOND)
428 #define ABS(x) ((x) < 0 ? -(x) : (x))
435 ASSERT (stop.
sec >= start.
sec);
436 if (stop.
sec == start.
sec)
444 ASSERT (difference_us >= 0);
445 return difference_us;
456 int32 measurement_us;
459 boolean is_deviation_within_tolerance;
466 deviation_us =
ABS (measurement_us - sleep_time_us);
467 is_deviation_within_tolerance = deviation_us <= usleep_accuracy_us;
468 ASSERT (is_deviation_within_tolerance);
483 #include <lwip/inet.h>
492 ASSERT (network == htons (host));
502 ASSERT (host == ntohs (network));
512 rprintp(
"SOEM (Simple Open EtherCAT Master)\nSimple test\n");
514 task_spawn (
"simpletest",
simpletest, 9, 8192, NULL);
static void test_osal_current_time(void)
int32 get_input_int32(uint16 slave_no, uint8 module_index)
void set_input_int32(uint16 slave_no, uint8 module_index, int32 value)
int ec_send_processdata(void)
ec_timet osal_current_time(void)
Headerfile for all ethercat headers.
boolean osal_timer_is_expired(osal_timert *self)
int ec_init(const char *ifname)
uint16 oshw_htons(uint16 host)
void simpletest(void *arg)
uint32 network_configuration(void)
uint8 get_input_bit(uint16 slave_no, uint8 module_index)
in_EL1008_t slave_EL1008_1
static void test_osal_timer(void)
static void test_osal_timer_timeout_us(const uint32 timeout_us)
in_EL1008_t slave_EL1008_2
int ec_config_init(uint8 usetable)
uint8 get_output_bit(uint16 slave_no, uint8 module_index)
int16 get_output_int16(uint16 slave_no, uint8 module_index)
void osal_timer_start(osal_timert *self, uint32 timeout_usec)
out_EL2622_t slave_EL2622_3
uint16 oshw_ntohs(uint16 network)
void set_output_int16(uint16 slave_no, uint8 module_index, int16 value)
static int32 time_difference_us(const ec_timet stop, const ec_timet start)
void tt_error(uint32_t task_ix)
out_EL2622_t slave_EL2622_2
int osal_usleep(uint32 usec)
static void test_osal_current_time_for_delay_us(const int32 sleep_time_us)
out_EL2622_t slave_EL2622_1
int ec_writestate(uint16 slave)
static void test_oshw_ntohs(void)
static void my_cyclic_callback(void *arg)
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
in_EL3061_t slave_EL3061_1
int ec_receive_processdata(int timeout)
out_EL4001_t slave_EL4001_1
int ec_config_map(void *pIOmap)
static void test_oshw_htons(void)
void set_output_bit(uint16 slave_no, uint8 module_index, uint8 value)
soem
Author(s): Arthur Ketels and M.J.G. van den Molengraft
autogenerated on Wed Mar 2 2022 01:01:49