OpenEtherCATsociety / SOEM

Simple Open Source EtherCAT Master
Other
1.35k stars 686 forks source link

Sync issue resulting in error 0x27 (Freerun not supported) #870

Open hshah44 opened 3 weeks ago

hshah44 commented 3 weeks ago

I need assistance to solidify my understanding and latch sync0.

Here are the steps to orchestrate this flow:

  1. ec_init

  2. ec_config_init

    • state: EC_STATE_INIT
  3. ec_configdc

    • state: EC_STATE_PRE_OP
  4. ec_config_map

    • state: EC_STATE_PRE_OP
  5. transition to EC_STATE_SAFE_OP

    • state: EC_STATE_SAFE_OP
  6. thread1

    • cycle PDO's infinitely (ec_send_processdata, ec_receive_processdata) with usleep(100)
    • verified wc is incrementing to 2 as expected
  7. thread2

    • wait for 2s to transition to state: EC_STATE_OPERATIONAL

End result: ID: 1 (4097), Parent: 0, State: 0x14 (EC_STATE_NONE), Topology: 1, DC: 1, Delay: 0, StatusCode=0x27 (Freerun not supported)


Thread tasks (I kept it simple to understand the behavior)


void* cycle() {
    ec_send_processdata();
    printf("wc: %d\n", wc);

    while(1) {
        wc = ec_receive_processdata(EC_TIMEOUTRET);
        usleep(100);
        ec_send_processdata();
    }
    return NULL;
}

void* task() {
    printf("sleeping wc: %d\n", wc);
    sleep(2);
    printf("wokeup wc: %d\n", wc);
    transition(1, EC_STATE_OPERATIONAL);
    return NULL;
}

Zipped up wireshark pcap file (step 6 - 7 above) capture.pcapng.zip