Muhammad Nabeel | 5 Dec 06:06 2013
Picon

SDO is not writting/device is not changing its state


<!-- .ExternalClass .ecxhmmessage P { padding:0px; } .ExternalClass body.ecxhmmessage { font-size:12pt; font-family:Calibri; } -->
Dear All,

Kindly help me, I have trying a lot but not finding my answer, I am writing SDO but it is not working, below is the code,

In this code with the help of state  of the drive I am willing to set my drive in operational state using state machine theory.


 
 switch(state_of_the_drive)
        {
            case S_SWITCH_ON_DISABLED:
                printf("S_SWITCH_ON_DISABLED\n");
                //EC_WRITE_U8(ecrt_sdo_request_data(sdo_cnt), 0x06);
                //EC_WRITE_U16(domain0_output + off_epos3_cntlwd,device_control_commands[0]);
                ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0006); // this command is the right command to send controlword data to change the device state?
               // EC_WRITE_U16(ecrt_sdo_request_data(sdo_cnt), 0x0006);
                //ecrt_master_sdo_download_complete(master,0,0x6040,&a,8,0x00000000);
                return;

            case S_READY_TO_SWITCH_ON:
                printf("S_READY_TO_SWITCH_ON\n");
                ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0007);       
                return;

            case S_SWITCHED_ON:
                printf("S_SWITCHED_ON\n");
                ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,device_control_commands[6]);  
                return;

            case S_FAULT:
                printf("S_FAULT 1 send: %x\n",device_control_commands[7]);
                //EC_WRITE_U16(ecrt_sdo_request_data(sdo_cnt), device_control_commands[7]);
                ecrt_slave_config_sdo8(sc_epos3, 0x6040, 0x00,device_control_commands[7]);
                fault_flag = 1;
                return;
            case S_OPERATION_ENABLE:
                printf("S_OPERATION_ENABLE\n");
                flag_operation = 1;
                return;
        }

Above code is the small part of actual code used for setting the drive in operational state. Below is the complete source code.

#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

/****************************************************************************/

#include "ecrt.h"

/****************************************************************************/

// Application parameters
#define FREQUENCY 100
#define PRIORITY 1

// Optional features
#define CONFIGURE_PDOS  1
#define SDO_ACCESS      1

/****************************************************************************/

// EtherCAT
static ec_master_t *master = NULL;
static ec_master_state_t master_state = {};

static ec_domain_t *domain0 = NULL;
static ec_domain_state_t domain_state = {};

static ec_slave_config_t *sc_epos3 = NULL;
static ec_slave_config_state_t sc_epos3_state = {};

// Timer
static unsigned int sig_alarms = 0;
static unsigned int user_alarms = 0;

/****************************************************************************/

// process data
static uint8_t *domain0_output = NULL;

#define SLAVE_DRIVE_0 0,0
#define MAXON_EPOS3    0x000000fb,0x64400000

//

// offsets for PDO entries

static unsigned int off_epos3_cntlwd;
static unsigned int off_epos3_tpos;
static unsigned int off_epos3_off_pos;
static unsigned int off_epos3_off_vel;
static unsigned int off_epos3_off_toq;
static unsigned int off_epos3_moo;
static unsigned int off_epos3_dof;
static unsigned int off_epos3_tpf;

static unsigned int off_epos3_status;
static unsigned int off_epos3_pos_val;
static unsigned int off_epos3_vel_val;
static unsigned int off_epos3_toq_val;
static unsigned int off_epos3_mood;
static unsigned int off_epos3_dif;
static unsigned int off_epos3_tps;
static unsigned int off_epos3_tpp1pv;
static unsigned int off_epos3_tpp1nv;


const static ec_pdo_entry_reg_t domain0_regs[] = {
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6040, 0, &off_epos3_cntlwd},     // U16
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x607a, 0, &off_epos3_tpos},           // S32
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b0, 0, &off_epos3_off_pos},        // S32
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b1, 0, &off_epos3_off_vel},        // S32
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b2, 0, &off_epos3_off_toq},        // S16
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6060, 0, &off_epos3_moo},        // S8
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x2078, 1, &off_epos3_dof},        // U16
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b8, 0, &off_epos3_tpf},        // U16
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6041, 0, &off_epos3_status},         //
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6064, 0, &off_epos3_pos_val},        //
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x606c, 0, &off_epos3_vel_val},        //
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6077, 0, &off_epos3_toq_val},        //
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6061, 0, &off_epos3_mood},           //
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x2071, 1, &off_epos3_dif},            //
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b9, 0, &off_epos3_tps},        //
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60ba, 0, &off_epos3_tpp1pv},     //
        {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60bb, 0, &off_epos3_tpp1nv},     //
        {}
};


static unsigned int counter = 0;
static unsigned int fault_flag = 0;
static unsigned int state_of_the_drive = 0;
static unsigned int flag_operation = 0;

const static unsigned int state_table[12] = {
    0x0000,     // Start
    0x0100,     // Not Ready to Switch On
    0x0140,     // Switch On Disabled
    0x0121,     // Ready to Switch On
    0x0123,     // Switched On
    0x4123,     // Refresh
    0x4133,     // Measure Init
    0x0137,     // Operation Enable
    0x0117,     // Quickstop Active
    0x010f,     // Fault Reaction Active (disabled)
    0x011f,     // Fault Reaction Active (enabled)
    0x0108      // Fault
};

#define S_START                         0x0000
#define S_NOT_READY_TO_SWITCH_ON     0x0100
#define S_SWITCH_ON_DISABLED         0x0140
#define S_READY_TO_SWITCH_ON         0x0121
#define S_SWITCHED_ON 0x0123
#define S_REFRESH 0x4123
#define S_MEASURE_INIT 0x4133
#define S_OPERATION_ENABLE 0x0137
#define S_QUICKSTOP_ACTIVE 0x0117
#define S_FAULT_REACTION_ACTIVE_D 0x010f
#define S_FAULT_REACTION_ACTIVE_E 0x011f
#define S_FAULT 0x0108

const static unsigned int device_control_commands[9] ={
    0x06,   // Shutdown                             0xxx x110   2, 6, 8
    0x07,   // Switch On                            0xxx x111   3
    0x0f,   // Switch On & Enable Operation      0xxx 1111   3, 4
    0x00,   // Disable Voltage                     0xxx xx0x   7, 9, 10, 12
    0x02,   // Quickstop                            0xxx x01x   7, 10, 11
    0x07,   // Disable Operation                  0xxx 0111    5
    0x0f,   // Enable Operation                   0xxx 1111    4, 16
    0x00,   // Fault Reset                         0xxx xxxx -> 1xxx xxxx 15
    0x80    // Fault Reset                         0xxx xxxx -> 1xxx xxxx 15
};
const uint8_t a=0x06;
/*****************************************************************************/

#if CONFIGURE_PDOS

/* Master 0, Slave 0, "EPOS3"
 * Vendor ID:       0x000000fb
 * Product code:    0x64400000
 * Revision number: 0x22100000
 */

ec_pdo_entry_info_t slave_0_pdo_entries[] = {
    {0x6040, 0x00, 16}, /* 0x6040:00 */
    {0x607a, 0x00, 32}, /* 0x607A:00 */
    {0x60b0, 0x00, 32}, /* 0x60B0:00 */
    {0x60b1, 0x00, 32}, /* 0x60B1:00 */
    {0x60b2, 0x00, 16}, /* 0x60B2:00 */
    {0x6060, 0x00, 8}, /* 0x6060:00 */
    {0x2078, 0x01, 16}, /* 0x2078:01 */
    {0x60b8, 0x00, 16}, /* 0x60B8:00 */
    {0x6041, 0x00, 16}, /* 0x6041:00 */
    {0x6064, 0x00, 32}, /* 0x6064:00 */
    {0x606c, 0x00, 32}, /* 0x606C:00 */
    {0x6077, 0x00, 16}, /* 0x6077:00 */
    {0x6061, 0x00, 8}, /* 0x6061:00 */
    {0x2071, 0x01, 16}, /* 0x2071:01 */
    {0x60b9, 0x00, 16}, /* 0x60B9:00 */
    {0x60ba, 0x00, 32}, /* 0x60BA:00 */
    {0x60bb, 0x00, 32}, /* 0x60BB:00 */
};

ec_pdo_info_t slave_0_pdos[] = {
    {0x1600, 8, slave_0_pdo_entries + 0}, /* 1st receive PDO Mapping */
    {0x1a00, 9, slave_0_pdo_entries + 8}, /* 1st transmit PDO Mapping */
};

ec_sync_info_t epos3_syncs[] = {
    {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
    {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
    {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_ENABLE},
    {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE},
    {0xff}
};
#endif

/*****************************************************************************/

#if SDO_ACCESS
static ec_sdo_request_t *sdo;
static ec_sdo_request_t *sdo_cnt;
#endif

/*****************************************************************************/

void check_domain_state(ec_domain_t *domain)
{
    ec_domain_state_t ds;

    ecrt_domain_state(domain, &ds);

    if (ds.working_counter != domain_state.working_counter)
        printf("Domain: WC %u.\n", ds.working_counter);
    if (ds.wc_state != domain_state.wc_state)
        printf("Domain: State %u.\n", ds.wc_state);

    domain_state = ds;
}

/*****************************************************************************/

void check_master_state(void)
{
    ec_master_state_t ms;

    ecrt_master_state(master, &ms);

    if (ms.slaves_responding != master_state.slaves_responding)
        printf("%u slave(s).\n", ms.slaves_responding);
    if (ms.al_states != master_state.al_states)
        printf("AL states: 0x%02X.\n", ms.al_states);
    if (ms.link_up != master_state.link_up)
        printf("Link is %s.\n", ms.link_up ? "up" : "down");

    master_state = ms;
}

/*****************************************************************************/

void check_slave_config_states(void)
{
    ec_slave_config_state_t s;

    ecrt_slave_config_state(sc_epos3, &s);

    if (s.al_state != sc_epos3_state.al_state)
        printf("EPOS3 slave 0 State 0x%02X.\n", s.al_state);
    if (s.online != sc_epos3_state.online)
        printf("EPOS3 slave 0: %s.\n", s.online ? "online" : "offline");
    if (s.operational != sc_epos3_state.operational)
        printf("EPOS3 slave 0: %soperational.\n",
                s.operational ? "" : "Not ");
    sc_epos3_state = s;
}

/*****************************************************************************/

#if SDO_ACCESS
void read_sdo(void)
{
    switch (ecrt_sdo_request_state(sdo)) {
        case EC_REQUEST_UNUSED: // request was not used yet
            ecrt_sdo_request_read(sdo); // trigger first read
            break;
        case EC_REQUEST_BUSY:
            //fprintf(stderr, "Still busy...\n");
            break;
        case EC_REQUEST_SUCCESS:
            state_of_the_drive = EC_READ_U16(ecrt_sdo_request_data(sdo));
            fprintf(stderr, "SDO value: 0x%04X\n",state_of_the_drive);
            ecrt_sdo_request_read(sdo); // trigger next read
            break;
        case EC_REQUEST_ERROR:
            fprintf(stderr, "Failed to read SDO!\n");
            ecrt_sdo_request_read(sdo); // retry reading
            break;
    }
}

#endif

#if 1
void move_state_machine(void)
{
    int i=0;
    unsigned int abc = 0;
    if (fault_flag == 1)
    {
        printf("S_FAULT 2 send: %x\n",device_control_commands[8]);
        //EC_WRITE_U8(ecrt_sdo_request_data(sdo_cnt), device_control_commands[8]);
        ecrt_slave_config_sdo8(sc_epos3, 0x6040, 0x00,device_control_commands[7]);
        ecrt_slave_config_sdo8(sc_epos3, 0x6040, 0x00,device_control_commands[8]);
        fault_flag = 0;
        return;
    }

    if (state_of_the_drive & 0x8000)
        state_of_the_drive = state_of_the_drive ^ 0x8000;
    if (state_of_the_drive & 0x0200)
        state_of_the_drive = state_of_the_drive ^ 0x0200;
    if (state_of_the_drive & 0x1000)
        state_of_the_drive = state_of_the_drive ^ 0x1000;
    if (state_of_the_drive & 0x0800)
        state_of_the_drive = state_of_the_drive ^ 0x0800;
    if (state_of_the_drive & 0x0400)
        state_of_the_drive = state_of_the_drive ^ 0x0400;
    if (state_of_the_drive & 0x0200)
        state_of_the_drive = state_of_the_drive ^ 0x0200;
    if (state_of_the_drive & 0x0080)
        state_of_the_drive = state_of_the_drive ^ 0x0080;

        //abc = state_of_the_drive & state_table[i];
        printf("state_of_the_drive :%x\n",state_of_the_drive);
        switch(state_of_the_drive)
        {
            case S_SWITCH_ON_DISABLED:
                printf("S_SWITCH_ON_DISABLED\n");
                //EC_WRITE_U8(ecrt_sdo_request_data(sdo_cnt), 0x06);
                //EC_WRITE_U16(domain0_output + off_epos3_cntlwd,device_control_commands[0]);
               //
                usleep(100);
                //printf("%d",ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0006));
                //EC_WRITE_U1d6(ecrt_sdo_request_data(sdo_cnt), 0x0006);
                //ecrt_master_sdo_download_complete(master,0,0x6040,&a,8,0x00000000);
                ecrt_slave_config_sdo(sc_epos3, 0x6040, 0x00, &a, sizeof(a));


                return;

            case S_READY_TO_SWITCH_ON:
                printf("S_READY_TO_SWITCH_ON\n");
               // ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0007);
                printf("%d",ecrt_slave_config_sdo(sc_epos3, 0x6040, 0x00,0x0007));      
                return;

            case S_SWITCHED_ON:
                printf("S_SWITCHED_ON\n");
                ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,device_control_commands[6]);  
                return;

            case S_FAULT:
                printf("S_FAULT 1 send: %x\n",device_control_commands[7]);
                //EC_WRITE_U16(ecrt_sdo_request_data(sdo_cnt), device_control_commands[7]);
                ecrt_slave_config_sdo8(sc_epos3, 0x6040, 0x00,device_control_commands[7]);
                fault_flag = 1;
                return;
            case S_OPERATION_ENABLE:
                printf("S_OPERATION_ENABLE\n");
                flag_operation = 1;
                return;
        }
   
}
#endif
/****************************************************************************/

void cyclic_task(){
        int i;
        unsigned int data_input=0;

        // receive process data
        ecrt_master_receive(master);
        ecrt_domain_process(domain0);

        // check process data state (optional)
        //check_domain_state(domain0);

        if (counter) {
               counter--;
        }else {        // do this at 1 Hz
               counter = FREQUENCY;

               // check for master state (optional)
               //check_master_state();

               // check for islave configuration state(s) (optional)
               //check_slave_config_states();

#if SDO_ACCESS
                   // read process data SDO
               /*
               read_sdo();
               //printf("read_sdo\n");
               printf("receive :%x ",state_of_the_drive);

                // read process data
                if (flag_operation == 1)
                {
                    flag_operation = 0;
                    printf("e_Operation\n");

                    ecrt_slave_config_sdo16(sc_epos3, 0x607a, 0x00,0x00ff);

                }else
                {
                    move_state_machine();
                }
            */
               
#endif
        }
        ecrt_slave_config_sdo16(sc_epos3, 0x607a, 0x00,0x0000);
        // send process data
        ecrt_domain_queue(domain0);
        ecrt_master_send(master);
}

/****************************************************************************/

void signal_handler(int signum) {
    switch (signum) {
        case SIGALRM:
            sig_alarms++;
            break;
    }
}

/****************************************************************************/

int main(int argc, char **argv)
{
        ec_slave_config_t *sc;
        struct sigaction sa;
        struct itimerval tv;

        master = ecrt_request_master(0);
               printf("ecrt_request_master is called \n");
        if (!master)
               return -1;

        domain0 = ecrt_master_create_domain(master);
        if(!domain0)
               return -1;

        if(!(sc_epos3 = ecrt_master_slave_config(
                       master, SLAVE_DRIVE_0, MAXON_EPOS3))){
               fprintf(stderr, "Failed to get slave configuration. \n");
               return -1;
        }
/*
        ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0006);
        usleep(5000);
        ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0007);
        usleep(5000);
        ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x000f);
        usleep(5000);
        */
        //ecrt_slave_config_sdo16(sc_epos3, 0x6060, 0x00,0x0008);
        //added by kbkbc
        //if (ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,9 ) == 0)
               //printf("change SDO : 0x6040 \n");


#if SDO_ACCESS
    fprintf(stderr, "Creating SDO requests...\n");
    if (!(sdo = ecrt_slave_config_create_sdo_request(sc_epos3, 0x6041,
0x00, 16))) {
        fprintf(stderr, "Failed to create SDO request.\n");
        return -1;
    }
    if (!(sdo_cnt = ecrt_slave_config_create_sdo_request(sc_epos3, 0x6040,
0x00, 8))) {
        fprintf(stderr, "Failed to create SDO request.\n");
        return -1;
    }

       
        ecrt_slave_config_sdo16(sc_epos3, 0x6060, 0x00,0x0008);
        //usleep(5000);
        ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0006);
        //usleep(5000);
        ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0007);
        //usleep(5000);
        ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x000f);
       


    while(1)
    {
        read_sdo();
       
        //printf("read_sdo\n");
        printf("receive :%x ",state_of_the_drive);

        // read process data
        if (state_of_the_drive == state_table[8])
        {
            printf("e_Operation\n");
            while(1);
        }else
        {
            move_state_machine();
        }
        usleep(100000);
    }
   
    //ecrt_sdo_request_timeout(sdo, 10); // ms
#endif

#if CONFIGURE_PDOS
        printf("Configuring PDOs...\n");
        if (ecrt_slave_config_pdos(sc_epos3, EC_END, epos3_syncs)) {
               fprintf(stderr, "Failed to configure PDOs.\n");
               return -1;
        }
        printf("configureing PDO is completed!\n");
#endif
        if( ecrt_domain_reg_pdo_entry_list(domain0, domain0_regs)){
               fprintf(stderr, "PDO entty registration filed! \n");
               return -1;
        }

        printf("Activating master...\n");
        if (ecrt_master_activate(master))
               return -1;

        if( !(domain0_output = ecrt_domain_data(domain0))) {
               return -1;
        }

#if PRIORITY
    pid_t pid = getpid();
    if (setpriority(PRIO_PROCESS, pid, -19))
        fprintf(stderr, "Warning: Failed to set priority: %s\n",
                strerror(errno));
#endif

    sa.sa_handler = signal_handler;
    sigemptyset(&sa.sa_mask);
    sa.sa_flags = 0;
    if (sigaction(SIGALRM, &sa, 0)) {
        fprintf(stderr, "Failed to install signal handler!\n");
        return -1;
    }

    printf("Starting timer...\n");
    tv.it_interval.tv_sec = 0;
    tv.it_interval.tv_usec = 1000000 / FREQUENCY;
    tv.it_value.tv_sec = 0;
    tv.it_value.tv_usec = 1000;
    if (setitimer(ITIMER_REAL, &tv, NULL)) {
        fprintf(stderr, "Failed to start timer: %s\n", strerror(errno));
        return 1;
    }

    printf("Started.\n");

    while (1) {
        //pause();

        #if 0
        struct timeval t;
        gettimeofday(&t, NULL);
        printf("%u.%06u\n", t.tv_sec, t.tv_usec);
        #endif
        while (sig_alarms != user_alarms) {

            cyclic_task();
            user_alarms++;
        }
    }

    return 0;
}

<div><div dir="ltr">
<br><div>

&lt;!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}

--&gt;<div dir="ltr">Dear All,<br><br>Kindly help me, I have trying a lot but not finding my answer, I am writing SDO but it is not working, below is the code,<br><br>In this code with the help of state&nbsp; of the drive I am willing to set my drive in operational state using state machine theory.<br><br><br>&nbsp;<br>&nbsp;switch(state_of_the_drive)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_SWITCH_ON_DISABLED:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_SWITCH_ON_DISABLED\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //EC_WRITE_U8(ecrt_sdo_request_data(sdo_cnt), 0x06);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //EC_WRITE_U16(domain0_output + off_epos3_cntlwd,device_control_commands[0]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0006); // this command is the right command to send controlword data to change the device state?<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // EC_WRITE_U16(ecrt_sdo_request_data(sdo_cnt), 0x0006);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //ecrt_master_sdo_download_complete(master,0,0x6040,&amp;a,8,0x00000000);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_READY_TO_SWITCH_ON:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_READY_TO_SWITCH_ON\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0007);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_SWITCHED_ON:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_SWITCHED_ON\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,device_control_commands[6]);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_FAULT:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_FAULT 1 send: %x\n",device_control_commands[7]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //EC_WRITE_U16(ecrt_sdo_request_data(sdo_cnt), device_control_commands[7]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo8(sc_epos3, 0x6040, 0x00,device_control_commands[7]); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fault_flag = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_OPERATION_ENABLE:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_OPERATION_ENABLE\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag_operation = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>Above code is the small part of actual code used for setting the drive in operational state. Below is the complete source code.<br><br>#include &lt;errno.h&gt;<br>#include &lt;signal.h&gt;<br>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;sys/resource.h&gt;<br>#include &lt;sys/time.h&gt;<br>#include &lt;sys/types.h&gt;<br>#include &lt;unistd.h&gt;<br><br>/****************************************************************************/<br><br>#include "ecrt.h"<br><br>/****************************************************************************/<br><br>// Application parameters<br>#define FREQUENCY 100<br>#define PRIORITY 1<br><br>// Optional features<br>#define CONFIGURE_PDOS&nbsp; 1<br>#define SDO_ACCESS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br><br>/****************************************************************************/<br><br>// EtherCAT<br>static ec_master_t *master = NULL;<br>static ec_master_state_t master_state = {};<br><br>static ec_domain_t *domain0 = NULL;<br>static ec_domain_state_t domain_state = {};<br><br>static ec_slave_config_t *sc_epos3 = NULL;<br>static ec_slave_config_state_t sc_epos3_state = {};<br><br>// Timer<br>static unsigned int sig_alarms = 0;<br>static unsigned int user_alarms = 0;<br><br>/****************************************************************************/<br><br>// process data<br>static uint8_t *domain0_output = NULL;<br><br>#define SLAVE_DRIVE_0 0,0<br>#define MAXON_EPOS3&nbsp;&nbsp;&nbsp; 0x000000fb,0x64400000<br><br>// <br><br>// offsets for PDO entries<br><br>static unsigned int off_epos3_cntlwd;<br>static unsigned int off_epos3_tpos;<br>static unsigned int off_epos3_off_pos;<br>static unsigned int off_epos3_off_vel;<br>static unsigned int off_epos3_off_toq;<br>static unsigned int off_epos3_moo;<br>static unsigned int off_epos3_dof;<br>static unsigned int off_epos3_tpf;<br><br>static unsigned int off_epos3_status;<br>static unsigned int off_epos3_pos_val;<br>static unsigned int off_epos3_vel_val;<br>static unsigned int off_epos3_toq_val;<br>static unsigned int off_epos3_mood;<br>static unsigned int off_epos3_dif;<br>static unsigned int off_epos3_tps;<br>static unsigned int off_epos3_tpp1pv;<br>static unsigned int off_epos3_tpp1nv;<br><br><br>const static ec_pdo_entry_reg_t domain0_regs[] = {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6040, 0, &amp;off_epos3_cntlwd},&nbsp;&nbsp;&nbsp;&nbsp; // U16<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x607a, 0, &amp;off_epos3_tpos},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // S32<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b0, 0, &amp;off_epos3_off_pos},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // S32<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b1, 0, &amp;off_epos3_off_vel},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // S32<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b2, 0, &amp;off_epos3_off_toq},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // S16<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6060, 0, &amp;off_epos3_moo},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // S8<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x2078, 1, &amp;off_epos3_dof},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // U16<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b8, 0, &amp;off_epos3_tpf},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // U16<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6041, 0, &amp;off_epos3_status},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6064, 0, &amp;off_epos3_pos_val},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x606c, 0, &amp;off_epos3_vel_val},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6077, 0, &amp;off_epos3_toq_val},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6061, 0, &amp;off_epos3_mood},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x2071, 1, &amp;off_epos3_dif},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b9, 0, &amp;off_epos3_tps},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60ba, 0, &amp;off_epos3_tpp1pv},&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60bb, 0, &amp;off_epos3_tpp1nv},&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {}<br>};<br><br><br>static unsigned int counter = 0;<br>static unsigned int fault_flag = 0;<br>static unsigned int state_of_the_drive = 0;<br>static unsigned int flag_operation = 0;<br><br>const static unsigned int state_table[12] = {<br>&nbsp;&nbsp;&nbsp; 0x0000,&nbsp;&nbsp;&nbsp;&nbsp; // Start<br>&nbsp;&nbsp;&nbsp; 0x0100,&nbsp;&nbsp;&nbsp;&nbsp; // Not Ready to Switch On<br>&nbsp;&nbsp;&nbsp; 0x0140,&nbsp;&nbsp;&nbsp;&nbsp; // Switch On Disabled<br>&nbsp;&nbsp;&nbsp; 0x0121,&nbsp;&nbsp;&nbsp;&nbsp; // Ready to Switch On<br>&nbsp;&nbsp;&nbsp; 0x0123,&nbsp;&nbsp;&nbsp;&nbsp; // Switched On<br>&nbsp;&nbsp;&nbsp; 0x4123,&nbsp;&nbsp;&nbsp;&nbsp; // Refresh<br>&nbsp;&nbsp;&nbsp; 0x4133,&nbsp;&nbsp;&nbsp;&nbsp; // Measure Init<br>&nbsp;&nbsp;&nbsp; 0x0137,&nbsp;&nbsp;&nbsp;&nbsp; // Operation Enable<br>&nbsp;&nbsp;&nbsp; 0x0117,&nbsp;&nbsp;&nbsp;&nbsp; // Quickstop Active<br>&nbsp;&nbsp;&nbsp; 0x010f,&nbsp;&nbsp;&nbsp;&nbsp; // Fault Reaction Active (disabled)<br>&nbsp;&nbsp;&nbsp; 0x011f,&nbsp;&nbsp;&nbsp;&nbsp; // Fault Reaction Active (enabled)<br>&nbsp;&nbsp;&nbsp; 0x0108&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Fault<br>};<br><br>#define S_START&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x0000<br>#define S_NOT_READY_TO_SWITCH_ON&nbsp;&nbsp;&nbsp;&nbsp; 0x0100<br>#define S_SWITCH_ON_DISABLED&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x0140<br>#define S_READY_TO_SWITCH_ON&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x0121<br>#define S_SWITCHED_ON 0x0123<br>#define S_REFRESH 0x4123<br>#define S_MEASURE_INIT 0x4133<br>#define S_OPERATION_ENABLE 0x0137<br>#define S_QUICKSTOP_ACTIVE 0x0117<br>#define S_FAULT_REACTION_ACTIVE_D 0x010f<br>#define S_FAULT_REACTION_ACTIVE_E 0x011f<br>#define S_FAULT 0x0108<br><br>const static unsigned int device_control_commands[9] ={<br>&nbsp;&nbsp;&nbsp; 0x06,&nbsp;&nbsp; // Shutdown&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xxx x110&nbsp;&nbsp; 2, 6, 8<br>&nbsp;&nbsp;&nbsp; 0x07,&nbsp;&nbsp; // Switch On&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xxx x111&nbsp;&nbsp; 3<br>&nbsp;&nbsp;&nbsp; 0x0f,&nbsp;&nbsp; // Switch On &amp; Enable Operation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xxx 1111&nbsp;&nbsp; 3, 4<br>&nbsp;&nbsp;&nbsp; 0x00,&nbsp;&nbsp; // Disable Voltage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xxx xx0x&nbsp;&nbsp; 7, 9, 10, 12<br>&nbsp;&nbsp;&nbsp; 0x02,&nbsp;&nbsp; // Quickstop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xxx x01x&nbsp;&nbsp; 7, 10, 11<br>&nbsp;&nbsp;&nbsp; 0x07,&nbsp;&nbsp; // Disable Operation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xxx 0111&nbsp;&nbsp;&nbsp; 5<br>&nbsp;&nbsp;&nbsp; 0x0f,&nbsp;&nbsp; // Enable Operation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xxx 1111&nbsp;&nbsp;&nbsp; 4, 16<br>&nbsp;&nbsp;&nbsp; 0x00,&nbsp;&nbsp; // Fault Reset&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xxx xxxx -&gt; 1xxx xxxx 15<br>&nbsp;&nbsp;&nbsp; 0x80&nbsp;&nbsp;&nbsp; // Fault Reset&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xxx xxxx -&gt; 1xxx xxxx 15<br>};<br>const uint8_t a=0x06;<br>/*****************************************************************************/<br><br>#if CONFIGURE_PDOS<br><br>/* Master 0, Slave 0, "EPOS3" <br>&nbsp;* Vendor ID:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x000000fb <br>&nbsp;* Product code:&nbsp;&nbsp;&nbsp; 0x64400000 <br>&nbsp;* Revision number: 0x22100000 <br>&nbsp;*/ <br><br>ec_pdo_entry_info_t slave_0_pdo_entries[] = { <br>&nbsp;&nbsp;&nbsp; {0x6040, 0x00, 16}, /* 0x6040:00 */ <br>&nbsp;&nbsp;&nbsp; {0x607a, 0x00, 32}, /* 0x607A:00 */ <br>&nbsp;&nbsp;&nbsp; {0x60b0, 0x00, 32}, /* 0x60B0:00 */ <br>&nbsp;&nbsp;&nbsp; {0x60b1, 0x00, 32}, /* 0x60B1:00 */ <br>&nbsp;&nbsp;&nbsp; {0x60b2, 0x00, 16}, /* 0x60B2:00 */ <br>&nbsp;&nbsp;&nbsp; {0x6060, 0x00, 8}, /* 0x6060:00 */ <br>&nbsp;&nbsp;&nbsp; {0x2078, 0x01, 16}, /* 0x2078:01 */ <br>&nbsp;&nbsp;&nbsp; {0x60b8, 0x00, 16}, /* 0x60B8:00 */ <br>&nbsp;&nbsp;&nbsp; {0x6041, 0x00, 16}, /* 0x6041:00 */ <br>&nbsp;&nbsp;&nbsp; {0x6064, 0x00, 32}, /* 0x6064:00 */ <br>&nbsp;&nbsp;&nbsp; {0x606c, 0x00, 32}, /* 0x606C:00 */ <br>&nbsp;&nbsp;&nbsp; {0x6077, 0x00, 16}, /* 0x6077:00 */ <br>&nbsp;&nbsp;&nbsp; {0x6061, 0x00, 8}, /* 0x6061:00 */ <br>&nbsp;&nbsp;&nbsp; {0x2071, 0x01, 16}, /* 0x2071:01 */ <br>&nbsp;&nbsp;&nbsp; {0x60b9, 0x00, 16}, /* 0x60B9:00 */ <br>&nbsp;&nbsp;&nbsp; {0x60ba, 0x00, 32}, /* 0x60BA:00 */ <br>&nbsp;&nbsp;&nbsp; {0x60bb, 0x00, 32}, /* 0x60BB:00 */ <br>}; <br><br>ec_pdo_info_t slave_0_pdos[] = { <br>&nbsp;&nbsp;&nbsp; {0x1600, 8, slave_0_pdo_entries + 0}, /* 1st receive PDO Mapping */ <br>&nbsp;&nbsp;&nbsp; {0x1a00, 9, slave_0_pdo_entries + 8}, /* 1st transmit PDO Mapping */ <br>}; <br><br>ec_sync_info_t epos3_syncs[] = { <br>&nbsp;&nbsp;&nbsp; {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE}, <br>&nbsp;&nbsp;&nbsp; {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, <br>&nbsp;&nbsp;&nbsp; {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_ENABLE}, <br>&nbsp;&nbsp;&nbsp; {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE}, <br>&nbsp;&nbsp;&nbsp; {0xff} <br>};<br>#endif<br><br>/*****************************************************************************/<br><br>#if SDO_ACCESS<br>static ec_sdo_request_t *sdo;<br>static ec_sdo_request_t *sdo_cnt;<br>#endif<br><br>/*****************************************************************************/<br><br>void check_domain_state(ec_domain_t *domain)<br>{<br>&nbsp;&nbsp;&nbsp; ec_domain_state_t ds;<br><br>&nbsp;&nbsp;&nbsp; ecrt_domain_state(domain, &amp;ds);<br><br>&nbsp;&nbsp;&nbsp; if (ds.working_counter != domain_state.working_counter)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Domain: WC %u.\n", ds.working_counter);<br>&nbsp;&nbsp;&nbsp; if (ds.wc_state != domain_state.wc_state)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Domain: State %u.\n", ds.wc_state);<br><br>&nbsp;&nbsp;&nbsp; domain_state = ds;<br>}<br><br>/*****************************************************************************/<br><br>void check_master_state(void)<br>{<br>&nbsp;&nbsp;&nbsp; ec_master_state_t ms;<br><br>&nbsp;&nbsp;&nbsp; ecrt_master_state(master, &amp;ms);<br><br>&nbsp;&nbsp;&nbsp; if (ms.slaves_responding != master_state.slaves_responding)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%u slave(s).\n", ms.slaves_responding);<br>&nbsp;&nbsp;&nbsp; if (ms.al_states != master_state.al_states)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("AL states: 0x%02X.\n", ms.al_states);<br>&nbsp;&nbsp;&nbsp; if (ms.link_up != master_state.link_up)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Link is %s.\n", ms.link_up ? "up" : "down");<br><br>&nbsp;&nbsp;&nbsp; master_state = ms;<br>}<br><br>/*****************************************************************************/<br><br>void check_slave_config_states(void)<br>{<br>&nbsp;&nbsp;&nbsp; ec_slave_config_state_t s;<br><br>&nbsp;&nbsp;&nbsp; ecrt_slave_config_state(sc_epos3, &amp;s);<br><br>&nbsp;&nbsp;&nbsp; if (s.al_state != sc_epos3_state.al_state)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("EPOS3 slave 0 State 0x%02X.\n", s.al_state);<br>&nbsp;&nbsp;&nbsp; if (s.online != sc_epos3_state.online)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("EPOS3 slave 0: %s.\n", s.online ? "online" : "offline");<br>&nbsp;&nbsp;&nbsp; if (s.operational != sc_epos3_state.operational)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("EPOS3 slave 0: %soperational.\n",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s.operational ? "" : "Not ");<br>&nbsp;&nbsp;&nbsp; sc_epos3_state = s;<br>}<br><br>/*****************************************************************************/<br><br>#if SDO_ACCESS<br>void read_sdo(void)<br>{<br>&nbsp;&nbsp;&nbsp; switch (ecrt_sdo_request_state(sdo)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case EC_REQUEST_UNUSED: // request was not used yet<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_sdo_request_read(sdo); // trigger first read<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case EC_REQUEST_BUSY:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //fprintf(stderr, "Still busy...\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case EC_REQUEST_SUCCESS:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state_of_the_drive = EC_READ_U16(ecrt_sdo_request_data(sdo));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "SDO value: 0x%04X\n",state_of_the_drive);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_sdo_request_read(sdo); // trigger next read<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case EC_REQUEST_ERROR:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Failed to read SDO!\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_sdo_request_read(sdo); // retry reading<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>#endif<br><br>#if 1<br>void move_state_machine(void)<br>{<br>&nbsp;&nbsp;&nbsp; int i=0;<br>&nbsp;&nbsp;&nbsp; unsigned int abc = 0;<br>&nbsp;&nbsp;&nbsp; if (fault_flag == 1)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_FAULT 2 send: %x\n",device_control_commands[8]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //EC_WRITE_U8(ecrt_sdo_request_data(sdo_cnt), device_control_commands[8]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo8(sc_epos3, 0x6040, 0x00,device_control_commands[7]); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo8(sc_epos3, 0x6040, 0x00,device_control_commands[8]); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fault_flag = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; if (state_of_the_drive &amp; 0x8000)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state_of_the_drive = state_of_the_drive ^ 0x8000;<br>&nbsp;&nbsp;&nbsp; if (state_of_the_drive &amp; 0x0200)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state_of_the_drive = state_of_the_drive ^ 0x0200;<br>&nbsp;&nbsp;&nbsp; if (state_of_the_drive &amp; 0x1000)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state_of_the_drive = state_of_the_drive ^ 0x1000;<br>&nbsp;&nbsp;&nbsp; if (state_of_the_drive &amp; 0x0800)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state_of_the_drive = state_of_the_drive ^ 0x0800;<br>&nbsp;&nbsp;&nbsp; if (state_of_the_drive &amp; 0x0400)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state_of_the_drive = state_of_the_drive ^ 0x0400;<br>&nbsp;&nbsp;&nbsp; if (state_of_the_drive &amp; 0x0200)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state_of_the_drive = state_of_the_drive ^ 0x0200;<br>&nbsp;&nbsp;&nbsp; if (state_of_the_drive &amp; 0x0080)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state_of_the_drive = state_of_the_drive ^ 0x0080;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //abc = state_of_the_drive &amp; state_table[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("state_of_the_drive :%x\n",state_of_the_drive);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch(state_of_the_drive)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_SWITCH_ON_DISABLED:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_SWITCH_ON_DISABLED\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //EC_WRITE_U8(ecrt_sdo_request_data(sdo_cnt), 0x06);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //EC_WRITE_U16(domain0_output + off_epos3_cntlwd,device_control_commands[0]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; usleep(100);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //printf("%d",ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0006));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //EC_WRITE_U1d6(ecrt_sdo_request_data(sdo_cnt), 0x0006);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //ecrt_master_sdo_download_complete(master,0,0x6040,&amp;a,8,0x00000000);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo(sc_epos3, 0x6040, 0x00, &amp;a, sizeof(a));<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_READY_TO_SWITCH_ON:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_READY_TO_SWITCH_ON\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0007); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%d",ecrt_slave_config_sdo(sc_epos3, 0x6040, 0x00,0x0007));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_SWITCHED_ON:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_SWITCHED_ON\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,device_control_commands[6]);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_FAULT:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_FAULT 1 send: %x\n",device_control_commands[7]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //EC_WRITE_U16(ecrt_sdo_request_data(sdo_cnt), device_control_commands[7]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo8(sc_epos3, 0x6040, 0x00,device_control_commands[7]); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fault_flag = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case S_OPERATION_ENABLE:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("S_OPERATION_ENABLE\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag_operation = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>}<br>#endif<br>/****************************************************************************/<br><br>void cyclic_task(){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int i;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned int data_input=0;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // receive process data<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_master_receive(master);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_domain_process(domain0);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // check process data state (optional)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //check_domain_state(domain0);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (counter) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; counter--;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // do this at 1 Hz<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; counter = FREQUENCY;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // check for master state (optional)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //check_master_state();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // check for islave configuration state(s) (optional)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //check_slave_config_states();<br><br>#if SDO_ACCESS<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // read process data SDO<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read_sdo();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //printf("read_sdo\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("receive :%x ",state_of_the_drive);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // read process data<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (flag_operation == 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag_operation = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("e_Operation\n");<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x607a, 0x00,0x00ff);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; move_state_machine();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>#endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x607a, 0x00,0x0000);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // send process data<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_domain_queue(domain0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_master_send(master);<br>}<br><br>/****************************************************************************/<br><br>void signal_handler(int signum) {<br>&nbsp;&nbsp;&nbsp; switch (signum) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case SIGALRM:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sig_alarms++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>/****************************************************************************/<br><br>int main(int argc, char **argv)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ec_slave_config_t *sc;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct sigaction sa;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct itimerval tv;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; master = ecrt_request_master(0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("ecrt_request_master is called \n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!master)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; domain0 = ecrt_master_create_domain(master);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!domain0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!(sc_epos3 = ecrt_master_slave_config(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; master, SLAVE_DRIVE_0, MAXON_EPOS3))){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Failed to get slave configuration. \n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>/*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0006);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; usleep(5000);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0007);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; usleep(5000);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x000f);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; usleep(5000);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //ecrt_slave_config_sdo16(sc_epos3, 0x6060, 0x00,0x0008);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //added by kbkbc<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //if (ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,9 ) == 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //printf("change SDO : 0x6040 \n");<br><br><br>#if SDO_ACCESS<br>&nbsp;&nbsp;&nbsp; fprintf(stderr, "Creating SDO requests...\n");<br>&nbsp;&nbsp;&nbsp; if (!(sdo = ecrt_slave_config_create_sdo_request(sc_epos3, 0x6041,<br>0x00, 16))) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Failed to create SDO request.\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if (!(sdo_cnt = ecrt_slave_config_create_sdo_request(sc_epos3, 0x6040,<br>0x00, 8))) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Failed to create SDO request.\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6060, 0x00,0x0008);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //usleep(5000);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0006);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //usleep(5000);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x0007);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //usleep(5000);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,0x000f);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br><br>&nbsp;&nbsp;&nbsp; while(1)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read_sdo();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //printf("read_sdo\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("receive :%x ",state_of_the_drive);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // read process data<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (state_of_the_drive == state_table[8])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("e_Operation\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while(1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; move_state_machine();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; usleep(100000);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //ecrt_sdo_request_timeout(sdo, 10); // ms<br>#endif<br><br>#if CONFIGURE_PDOS<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Configuring PDOs...\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ecrt_slave_config_pdos(sc_epos3, EC_END, epos3_syncs)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Failed to configure PDOs.\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("configureing PDO is completed!\n");<br>#endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( ecrt_domain_reg_pdo_entry_list(domain0, domain0_regs)){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "PDO entty registration filed! \n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Activating master...\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ecrt_master_activate(master))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( !(domain0_output = ecrt_domain_data(domain0))) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>#if PRIORITY<br>&nbsp;&nbsp;&nbsp; pid_t pid = getpid();<br>&nbsp;&nbsp;&nbsp; if (setpriority(PRIO_PROCESS, pid, -19))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Warning: Failed to set priority: %s\n",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strerror(errno));<br>#endif<br><br>&nbsp;&nbsp;&nbsp; sa.sa_handler = signal_handler;<br>&nbsp;&nbsp;&nbsp; sigemptyset(&amp;sa.sa_mask);<br>&nbsp;&nbsp;&nbsp; sa.sa_flags = 0;<br>&nbsp;&nbsp;&nbsp; if (sigaction(SIGALRM, &amp;sa, 0)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Failed to install signal handler!\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; printf("Starting timer...\n");<br>&nbsp;&nbsp;&nbsp; tv.it_interval.tv_sec = 0;<br>&nbsp;&nbsp;&nbsp; tv.it_interval.tv_usec = 1000000 / FREQUENCY;<br>&nbsp;&nbsp;&nbsp; tv.it_value.tv_sec = 0;<br>&nbsp;&nbsp;&nbsp; tv.it_value.tv_usec = 1000;<br>&nbsp;&nbsp;&nbsp; if (setitimer(ITIMER_REAL, &amp;tv, NULL)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Failed to start timer: %s\n", strerror(errno));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; printf("Started.\n");<br><br>&nbsp;&nbsp;&nbsp; while (1) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //pause();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct timeval t;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gettimeofday(&amp;t, NULL);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%u.%06u\n", t.tv_sec, t.tv_usec);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (sig_alarms != user_alarms) {<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyclic_task();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user_alarms++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; return 0;<br>}<br><br>
</div>
</div> 		 	   		  </div></div>
Raz | 1 Dec 15:20 2013
Picon

r8169 patch - packet timeout boot failures

hey

I have a problem from time to time that the ethercat interface ( eth1 )
does not send packets. I believe this is a problem in the realtek driver.
I am using 3.2-rt8 kernel.
questions:
1. why do you disable the rtl8169_phy_timer  timer ?
2.  In rtl_hw_start_8168 : why do disable RTL_W16(IntrMask, tp->intr_event); ?

thank you
raz
<div><div dir="ltr">
<div>
<div>
<div>hey<br><br>
</div>I have a problem from time to time that the ethercat interface ( eth1 ) <br>
</div>does not send packets. I believe this is a problem in the realtek driver.<br>I am using 3.2-rt8 kernel. <br>
</div>
<div>questions:<br>
</div>
<div>1. why do you disable the rtl8169_phy_timer&nbsp; timer ?<br>
</div>
<div>2.&nbsp; In rtl_hw_start_8168 : why do disable RTL_W16(IntrMask, tp-&gt;intr_event); ?<br><br>
</div>
<div>thank you<br>raz<br>
</div>
<div><div><div><div>
<br>-- <br><div dir="ltr"><div><a href="https://sites.google.com/site/ironspeedlinux/" target="_blank">https://sites.google.com/site/ironspeedlinux/</a></div></div>
</div></div></div></div>
</div></div>
John Erlandsson | 29 Nov 14:06 2013
Picon

Problem building master

Hi!

Having some problems building the master on fedora 19

autoreconf fails with the message:
+ touch ChangeLog
+ autoreconf -i
automake: warnings are treated as errors
/usr/share/automake-1.13/am/ltlibrary.am: warning: 'libethercat.la': linking libtool libraries using a non-POSIX
/usr/share/automake-1.13/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
lib/Makefile.am:33:   while processing Libtool library 'libethercat.la'
autoreconf: automake failed with exit status: 1


I made this change to configure.ac

*** configure.ac.orig    2013-11-29 13:50:20.469640086 +0100
--- configure.ac    2013-11-28 03:11:59.919355571 +0100
*************** AC_CONFIG_MACRO_DIR([m4])
*** 40,45 ****
--- 40,46 ----
  # Global
  #------------------------------------------------------------------------------
 
+ AM_PROG_AR
  AC_PROG_CXX
  AC_PROG_LIBTOOL
  AM_PROG_CC_C_O

And the bootstrap script finished without errors.

#./configure --with-linux-dir=/usr/src/kernels/3.10.20-200.rt17.1.fc19.ccrma.i686.rt --enable-8139too=no --enable-generic=yes --enable-cycles=yes
runs without any problems

#make && make doc
runs without any problems.

make modules fails with the message:
make -C "/usr/src/kernels/3.10.20-200.rt17.1.fc19.ccrma.i686.rt" M="/home/john/src/ethercat" modules
make[1]: Entering directory `/usr/src/kernels/3.10.20-200.rt17.1.fc19.ccrma.i686.rt'
  CC [M]  /home/john/src/ethercat/devices/generic.o
  LD [M]  /home/john/src/ethercat/devices/ec_generic.o
  CC [M]  /home/john/src/ethercat/examples/mini/mini.o
  LD [M]  /home/john/src/ethercat/examples/mini/ec_mini.o
  CC [M]  /home/john/src/ethercat/master/cdev.o
/home/john/src/ethercat/master/cdev.c: In function ‘eccdev_mmap’:
/home/john/src/ethercat/master/cdev.c:3964:22: error: ‘VM_RESERVED’ undeclared (first use in this function)
     vma->vm_flags |= VM_RESERVED; /* Pages will not be swapped out */
                      ^
/home/john/src/ethercat/master/cdev.c:3964:22: note: each undeclared identifier is reported only once for each function it appears in
make[3]: *** [/home/john/src/ethercat/master/cdev.o] Error 1
make[2]: *** [/home/john/src/ethercat/master] Error 2
make[1]: *** [_module_/home/john/src/ethercat] Error 2
make[1]: Leaving directory `/usr/src/kernels/3.10.20-200.rt17.1.fc19.ccrma.i686.rt'
make: *** [modules] Error 2

I suspect that my kernel version is too new. Can someone confirm?

Thanks...


//John
<div>
    Hi!<br><br>
    Having some problems building the master on fedora 19 <br><br>
    autoreconf fails with the message:<br>+ touch
        ChangeLog<br>
        + autoreconf -i<br>
        automake: warnings are treated as errors<br>
        /usr/share/automake-1.13/am/ltlibrary.am: warning:
        'libethercat.la': linking libtool libraries using a non-POSIX<br>
        /usr/share/automake-1.13/am/ltlibrary.am: archiver requires
        'AM_PROG_AR' in 'configure.ac'<br>
        lib/Makefile.am:33:&nbsp;&nbsp; while processing Libtool library
        'libethercat.la'<br>
        autoreconf: automake failed with exit status: 1<br><br><br>
    I made this change to configure.ac<br><br>***
        configure.ac.orig&nbsp;&nbsp;&nbsp; 2013-11-29 13:50:20.469640086 +0100<br>
        --- configure.ac&nbsp;&nbsp;&nbsp; 2013-11-28 03:11:59.919355571 +0100<br>
        *************** AC_CONFIG_MACRO_DIR([m4])<br>
        *** 40,45 ****<br>
        --- 40,46 ----<br>
        &nbsp; # Global<br>
        &nbsp;
#------------------------------------------------------------------------------<br>
        &nbsp; <br>
        + AM_PROG_AR<br>
        &nbsp; AC_PROG_CXX<br>
        &nbsp; AC_PROG_LIBTOOL<br>
        &nbsp; AM_PROG_CC_C_O<br><br>
    And the bootstrap script finished without errors.<br><br>#./configure
      --with-linux-dir=/usr/src/kernels/3.10.20-200.rt17.1.fc19.ccrma.i686.rt
      --enable-8139too=no --enable-generic=yes --enable-cycles=yes<br>
    runs without any problems<br><br>#make &amp;&amp; make
      doc <br>
    runs without any problems.<br><br>
    make modules fails with the message:<br>make -C
        "/usr/src/kernels/3.10.20-200.rt17.1.fc19.ccrma.i686.rt"
        M="/home/john/src/ethercat" modules<br>
        make[1]: Entering directory
        `/usr/src/kernels/3.10.20-200.rt17.1.fc19.ccrma.i686.rt'<br>
        &nbsp; CC [M]&nbsp; /home/john/src/ethercat/devices/generic.o<br>
        &nbsp; LD [M]&nbsp; /home/john/src/ethercat/devices/ec_generic.o<br>
        &nbsp; CC [M]&nbsp; /home/john/src/ethercat/examples/mini/mini.o<br>
        &nbsp; LD [M]&nbsp; /home/john/src/ethercat/examples/mini/ec_mini.o<br>
        &nbsp; CC [M]&nbsp; /home/john/src/ethercat/master/cdev.o<br>
        /home/john/src/ethercat/master/cdev.c: In function
        &lsquo;eccdev_mmap&rsquo;:<br>
        /home/john/src/ethercat/master/cdev.c:3964:22: error:
        &lsquo;VM_RESERVED&rsquo; undeclared (first use in this function)<br>
        &nbsp;&nbsp;&nbsp;&nbsp; vma-&gt;vm_flags |= VM_RESERVED; /* Pages will not be
        swapped out */<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^<br>
        /home/john/src/ethercat/master/cdev.c:3964:22: note: each
        undeclared identifier is reported only once for each function it
        appears in<br>
        make[3]: *** [/home/john/src/ethercat/master/cdev.o] Error 1<br>
        make[2]: *** [/home/john/src/ethercat/master] Error 2<br>
        make[1]: *** [_module_/home/john/src/ethercat] Error 2<br>
        make[1]: Leaving directory
        `/usr/src/kernels/3.10.20-200.rt17.1.fc19.ccrma.i686.rt'<br>
        make: *** [modules] Error 2<br><br>
    I suspect that my kernel version is too new. Can someone confirm?<br><br>
    Thanks...<br><br><br>
    //John<br>
</div>
Fuchs, Alexander | 27 Nov 13:21 2013
Picon
Picon

Problem with QtPdWidgets

Hallo,

 

I’m trying to use the QtPdWidget (V 1.3.5) library together with PdCom (V 3.0.7) on Windows 7 x64.

I compiled PdCom, as well as the QtPdWidgets, with MinGW (GCC V4.4.0), for the Widgets I used Qt V 4.8.5.

Unfortunately I’m not able to execute the testprogram, which is included in the QtPdWidget-library.

The compiling under Qt 4.8.5 is no problem; there are neither warnings nor other issues, but the program crashes immediately after executing it, without showing an error prompt or something.

After removing several functions and elements of the program, to determine the error source, I found out, that those crashes occur, when there’s a declaration, which uses parts of the QtPdWidget library.

For example “Pd::Process p;” in the “private” part of the MainWindow.h file.

Because that is such a basic procedure and there aren’t any compiling errors, I don’t know which the cause of those crashes could be. I hope you can help me with this problem.

 

Best regards,

 

Alex

 

<div>
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hallo,<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">I&rsquo;m trying to use the QtPdWidget (V 1.3.5) library together with PdCom (V 3.0.7) on Windows 7 x64.<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">I compiled PdCom, as well as the QtPdWidgets, with MinGW (GCC V4.4.0), for the Widgets I used Qt V 4.8.5.<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">Unfortunately I&rsquo;m not able to execute the testprogram, which is included in the QtPdWidget-library.<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">The compiling under Qt 4.8.5 is no problem; there are neither warnings nor other issues, but the program crashes immediately after executing it, without showing an error prompt or something.<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">After removing several functions and elements of the program, to determine the error source, I found out, that those crashes occur, when there&rsquo;s a declaration, which uses parts of the QtPdWidget library.<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">For example &ldquo;Pd::Process p;&rdquo; in the &ldquo;private&rdquo; part of the MainWindow.h file.<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">Because that is such a basic procedure and there aren&rsquo;t any compiling errors, I don&rsquo;t know which the cause of those crashes could be. I hope you can help me with this problem.<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">Best regards,<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">Alex</span><span lang="EN-GB"><p></p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><p>&nbsp;</p></span></p>
</div>
</div>
LYNCH, Damien | 27 Nov 05:16 2013
Picon
Picon

ec_e1000e driver not finding NIC? [SEC=UNCLASSIFIED]

Hi,

I am trying to set up the EtherLab master on a PC that has two Intel NICs: 1 x 82566DM-2 (which I am using for
normal network traffic) and 1 x 82573L which I am trying to use for EtherCAT. The PC is running Linux 3.4.69
with the RT patch applied. I configured the master using "./configure --disable-8139too
--enable-e1000e". After making and installing the master I modified /etc/sysconfig/ethercat
specifying the MAC address for the 82573L and "e1000e" as the device module. When I start the service I see
no flashing LEDs on my EtherCAT slave (Beckhoff EK1100 plus a couple of terminals). The following is in the
system log:

Nov 27 15:05:07 (none) kernel: [ 6972.273067] EtherCAT: Master driver 1.5.2 unknown
Nov 27 15:05:07 (none) kernel: [ 6972.273537] EtherCAT: 1 master waiting for devices.
Nov 27 15:05:07 (none) ethercat[22728]: Starting EtherCAT master 1.5.2 ..done
Nov 27 15:05:07 (none) kernel: [ 6972.277191] ec_e1000e: EtherCAT-capable Intel(R) PRO/1000 Network
Driver - 1.9.5-k-EtherCAT
Nov 27 15:05:07 (none) kernel: [ 6972.277194] ec_e1000e: Copyright(c) 1999 - 2012 Intel Corporation.

Running lsmod shows:

Module                  Size  Used by
ec_e1000e             140582  0 
ec_master             239804  1 ec_e1000e

I assume I should be seeing more logging from ec_1000e? Does anyone have any ideas about what I am doing wrong?

Thanks,
Damien
John Erlandsson | 26 Nov 12:36 2013
Picon

Config tool

Hi!

I believe i read something in this mailinglist about a gui config tool 
on github.
Cant seem to find it now.

Does anyone know what I am talking about or did I imagine it?

//John
Shahbaz Youssefi | 22 Nov 15:23 2013
Picon
Gravatar

Re: IgH Ethercat Master and EPOS3

I'm forwarding your question to the mailing list.


On Fri, Nov 22, 2013 at 3:18 PM, Muhammad Nabeel <hafiz_nabeel91 <at> hotmail.com> wrote:
AoA Shahbaz,

Hope you are doing well, I am new to Ubuntu and Ethercat.

I am using EPOS3 from maxon and IgH ethercat master but I am facing difficulties in communication between EPOS3 and IgH ethercat master. I need your help, I tried myself but I still I am confuse how to send/receive data to/from EPOS3. From Etherlab mailing I have found a source code but try to understand it but I still have some confusions.

Please help me, I will be very thankful to you.

I have attached the source code, please see the attachment. Below is the result when I connect EPOS3 and run the program.

ecrt_request_master is called
Configuring PDOs...
configureing PDO is completed!
Activating master...
Warning: Failed to set priority: Permission denied
Starting timer...
Started.
1 slave(s).
AL states: 0x02.
Link is up.
EPOS3 slave 0 State 0x02.
EPOS3 slave 0: online.


What is the meaning of this warning "Failed to set priority: Permission denied"?

Please guide me.

Thank you.

Best regards

Nabeel


 

<div><div dir="ltr">I'm forwarding your question to the mailing list.<br><div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Nov 22, 2013 at 3:18 PM, Muhammad Nabeel <span dir="ltr">&lt;<a href="mailto:hafiz_nabeel91@..." target="_blank">hafiz_nabeel91 <at> hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote">

<div><div dir="ltr">AoA Shahbaz,<br><br>Hope you are doing well, I am new to Ubuntu and Ethercat.<br><br>I am using EPOS3 from maxon and IgH ethercat master but I am facing difficulties in communication between EPOS3 and IgH ethercat master. I need your help, I tried myself but I still I am confuse how to send/receive data to/from EPOS3. From Etherlab mailing I have found a source code but try to understand it but I still have some confusions. <br><br>Please help me, I will be very thankful to you.<br><br>I have attached the source code, please see the attachment. Below is the result when I connect EPOS3 and run the program.<br><br>ecrt_request_master is called <br>
Configuring PDOs...<br>configureing PDO is completed!<br>Activating master...<br>Warning: Failed to set priority: Permission denied<br>Starting timer...<br>Started.<br>1 slave(s).<br>AL states: 0x02.<br>Link is up.<br>EPOS3 slave 0 State 0x02.<br>
EPOS3 slave 0: online.<br><br><br>What is the meaning of this warning "Failed to set priority: Permission denied"?<br><br>Please guide me.<br><br>Thank you.<br><br>Best regards<span class="HOEnZb"><br><br>Nabeel<br><br><br>&nbsp;<br></span>
</div></div>
</blockquote>
</div>
<br>
</div></div>
</div></div>
Martin Troxler | 21 Nov 10:25 2013

waiting for received frames

Hi

I watched that discussion about the need for a API to wait (poll) for 
received frames. I still don't get it why that is nessessary.

Here is a clarification of how ethercat (process data transfer) works:
- Process Data should be regarded as idempotent states, which means it 
doesn't matter how many times you read it.
- it's a kind of huge shift register from the master through all slaves 
and back to the master where each slave (ESC-Chip) manipulates the 
stream of data on the fly.
- Slaves (i.e. the firmware on microcontrollers) cannot delay the 
transmission of the frame. If there is no new data the ESC simply 
transfers the actual content of its local memory.
- The frame transmission time is fixed for a given set of slaves and 
depends largely on the domain size and not on how fast the slave's 
microcontroller can update the data.

Regards
Martin

Note:             

This e-mail is for the named person's use only. It may contain confidential and/or privileged
information. If you have received this e-mail in error, please notify the sender immediately and delete
the material from any system. Any unauthorized copying, disclosure, distribution or other use of this
information by persons or entities other than the intended recipient is prohibited.             

Thank You.
Shahbaz Youssefi | 20 Nov 18:31 2013
Picon
Gravatar

Fwd: unofficial patch: check domain received

Hi

I'm forwarding the patch as I received it (with the name of the author, but I'd wait for his consent before disclosing his other info although just in case).

In fact, the functions therein don't touch the functionality of the master. In other words if you don't use those functions, it doesn't absolutely incur any penalty whatsoever (except perhaps an extra `case` in `ioctl` which I think we can all agree is negligible). The functions themselves are very simple and simply just loop over the domains and tell whether they are received.

Here's how it's tested (quoting from the past):

--- quote ---
Alright, I did the test with the following configuration:

2 slaves, each producing 1.2k data, split equally in 2 datagrams. A bridge placed in the network that introduces a delay between the 2 datagrams. The delays I tested with were 100us, 500us and 1ms. That is, the bridge makes sure there is at least 1ms delay between passing frames. I logged the passing times and this is done correctly.

Now, with ecrt_domain_received, I could see that it returns true after a correct time. That is, when I increase the gap in the bridge, the receive time in the network is increased. With another program I checked the data received from the slaves and they are correct (both datagrams arrive).

So I guess everything works just fine! :)

Thank you for this patch, hope it makes its way to the official release.
Shahbaz

P.S. You had forgot the EXPORT_SYMBOL in your patch (just in case you wanted to give it to the developers)
--- /quote ---

Furthermore, a peculiarity that I discovered is (quoted from another email):

--- quote ---
Something you might want to know:

If ecrt_domain_received is called after ecrt_domain_process, the kernel crashes. I did so to only read data of received domains (after I had processed them) only to discover this behavior.

No big deal though, as I can just read whatever is available and I don't really gain much by ignoring timed-out domains.
--- /quote ---

There was a long discussion on this and it was also reminded at another time. You can read the whole discussion here:

http://lists.etherlab.org/pipermail/etherlab-users/2011/date.html
(search for "Knowing when the packet"...)

and at a later time:

---------- Forwarded message ----------
From: Jun Yuan

patch file for stable 1.5 ;)

--
Jun Yuan


<div><div dir="ltr">
<div>
<div>Hi<br>
</div>
<div>
<br>I'm forwarding the patch as I received it (with the name of the author, but I'd wait for his consent before disclosing his other info although just in case).<br><br>
</div>
In fact, the functions therein don't touch the functionality of the master. In other words if you don't use those functions, it doesn't absolutely incur any penalty whatsoever (except perhaps an extra `case` in `ioctl` which I think we can all agree is negligible). The functions themselves are very simple and simply just loop over the domains and tell whether they are received.<br><br>Here's how it's tested (quoting from the past):<br><br>
</div>--- quote ---<br><div><div>
<div>Alright, I did the test with the following configuration:<br><br>2 
slaves, each producing 1.2k data, split equally in 2 datagrams. A bridge
 placed in the network that introduces a delay between the 2 datagrams. 
The delays I tested with were 100us, 500us and 1ms. That is, the bridge 
makes sure there is at least 1ms delay between passing frames. I logged 
the passing times and this is done correctly.<br><br>Now, with <span>ecrt_domain_received</span>,
 I could see that it returns true after a correct time. That is, when I 
increase the gap in the bridge, the receive time in the network is 
increased. With another program I checked the data <span class="">received</span> from the slaves and they are correct (both datagrams arrive).<br><br>So I guess everything works just fine! :)<br><br>Thank you for this patch, hope it makes its way to the official release.<span class=""><br>Shahbaz<br></span><br>P.S. You had forgot the EXPORT_SYMBOL in your patch (just in case you wanted to give it to the developers)<br>
</div>
<div>--- /quote ---<br><br>
</div>
<div>Furthermore, a peculiarity that I discovered is (quoted from another email):<br><br>
</div>
<div>--- quote ---<br>Something you might want to know:<br><br>If ecrt_domain_received is called after ecrt_domain_process, the kernel crashes. I did so to only read data of <span class="">received</span> domains (after I had processed them) only to discover this behavior.<br>
<br>No big deal though, as I can just read whatever is available and I don't really gain much by ignoring timed-out domains.<br>
</div>
<div>--- /quote ---<br>
</div>
<div><br></div>
<div>There was a long discussion on this and it was also reminded at another time. You can read the whole discussion here:<br><br><a href="http://lists.etherlab.org/pipermail/etherlab-users/2011/date.html">http://lists.etherlab.org/pipermail/etherlab-users/2011/date.html</a><br>
</div>
<div>(search for "Knowing when the packet"...)</div>
<div><br></div>
<div>and at a later time:<br>
</div>
<div>
<br><a href="http://lists.etherlab.org/pipermail/etherlab-users/2012/001755.html">http://lists.etherlab.org/pipermail/etherlab-users/2012/001755.html</a><br><a href="http://lists.etherlab.org/pipermail/etherlab-users/2012/001756.html">http://lists.etherlab.org/pipermail/etherlab-users/2012/001756.html</a><br>
</div>
<div>
<br><div class="gmail_quote">---------- Forwarded message ----------<br>From: Jun Yuan<br><br>patch file for stable 1.5 ;)<br><div class=""><div class="h5"><br></div></div>
<span class="">-- <br>
Jun Yuan</span><br>
</div>
<br>
</div>
</div></div>
</div></div>
Carlos Jiménez Leal | 20 Nov 17:19 2013

SDO abort code

Hello,

I want to pick the abort_code after an error sending an sdo, but I can 
not access from the structure ec_sdo_request_t*, I get a compilation 
error:

ManagerSDO.cpp:97: error: invalid use of incomplete type struct 
ec_sdo_request
/opt/etherlab/include/ecrt.h:241: error: forward declaration of struct 
ec_sdo_request

Anyone have any idea how I can access this code?

Thanks and regards
-- 

Carlos Jiménez

ENCOPIM S.L.
Ctra. de Ripollet a Santiga 104, P.I. Els Pinetons
E-08291 RIPOLLET (Barcelona)
Tel: (+34) 935 94 23 47
Fax: (+34) 935 94 64 15

==========================================================
La información contenida en la presente transmisión es confidencial y 
su
uso únicamente está permitido a su(s) destinatario(s). Si Ud. no es la
persona destinataria de la presente transmisión, rogamos nos lo
comunique de manera inmediata por teléfono (+34 935 942 347) y destruya
cualquier copia de la misma (tanto digitales como en papel).

The information contained in this transmission is confidential and is
intended only for the use of the addressee(s). If you are not the
designated recipient of this transmission, please advise us immediately
by telephone (+34 935 942 347) and destroy any copies (digital and
paper).
==========================================================
_______________________________________________
etherlab-users mailing list
etherlab-users <at> etherlab.org
http://lists.etherlab.org/mailman/listinfo/etherlab-users
Curt | 19 Nov 18:56 2013

example code

Sorry for the newbie questions.

I've downloaded built and installed the ethercat master 1.5.2.

Used the generic driver to communicated with an Beckhoff EK1101 hub, EL1034 
digital input and EL2034 digital output.

I then modified the ./example/user/main.c code to work with these modules.  
Seems to work OK.   I then  looped the digital out to a digital in to some 
basic performance testing.

At a update rate of 1kHz (1 millisecond), it can detect a change on average of 
about 2 ms.    I increased the rate to 2kHz,  it can detect a change on 
average of 1ms, BUT, I see an occasional, "EtherCAT WARNING: Datagram da69fecc 
(domain0-0-main) was SKIPPED 1 time".   I don't see this warning at a 1kHz 
update rate.   

Are these reasonable results, and does this imply that the fastest rate I can 
expect without errors/warnings is 1 kHz?

Would I get significantly better results using the Ethercat kernel module for 
my chipset?

Thanks,

Curt Fiene
Cybermetrix

Gmane