jzolee / HAL2UDP

External step generator and IO interface for LinuxCNC over Ethernet with dual-core ESP32 and W5500 modules.
GNU General Public License v2.0
19 stars 11 forks source link

Getting error #7

Open yathish-debug opened 4 months ago

yathish-debug commented 4 months ago

Hey jzolee, instead of w5500 im using ENC28J60. So I should use UIPEthernet lib. I made the necessary changes but getting some errors. `#include

include

include

include

// MAC address and static IP configuration byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192, 168, 96, 54); unsigned int port = 58427;

define SPI_CS_PIN 5 // SPI chip select pin for ENC28J60

EthernetServer server(80); // Adding EthernetServer for HTTP EthernetUDP Udp; // Use EthernetUDP provided by UIPEthernet

define STEP_0_PIN 12

define STEP_0_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT12)

define STEP_0_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT12)

define DIR_0_PIN 13

define DIR_0_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT13)

define DIR_0_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT13)

define STEP_1_PIN 16

define STEP_1_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT16)

define STEP_1_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT16)

define DIR_1_PIN 17

define DIR_1_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT17)

define DIR_1_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT17)

define STEP_2_PIN 21

define STEP_2_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT21)

define STEP_2_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT21)

define DIR_2_PIN 22

define DIR_2_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT22)

define DIR_2_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT22)

/==================================================================/

define OUT_00_PIN 2

define OUT_00_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT2)

define OUT_00_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT2)

define OUT_01_PIN 4

define OUT_01_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT4)

define OUT_01_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT4)

define OUT_02_PIN 25

define OUT_02_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT25)

define OUT_02_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT25)

define OUT_03_PIN 1

define OUT_03_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT1)

define OUT_03_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT1)

define OUT_04_PIN 14

define OUT_04_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT14)

define OUT_04_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT14)

define OUT_05_PIN 15

define OUT_05_H REG_WRITE(GPIO_OUT_W1TS_REG, BIT15)

define OUT_05_L REG_WRITE(GPIO_OUT_W1TC_REG, BIT15)

/==================================================================/

define IN_00_PIN 26

define IN_00 REG_READ(GPIO_IN_REG) & BIT26 //26

define IN_01_PIN 27

define IN_01 REG_READ(GPIO_IN_REG) & BIT27 //27

define IN_02_PIN 32

define IN_02 REG_READ(GPIO_IN1_REG) & BIT0 //32 -32

define IN_03_PIN 33

define IN_03 REG_READ(GPIO_IN1_REG) & BIT1 //33 -32

define IN_04_PIN 34

define IN_04 REG_READ(GPIO_IN1_REG) & BIT2 //34 -32

define IN_05_PIN 35

define IN_05 REG_READ(GPIO_IN1_REG) & BIT3 //35 -32

define IN_06_PIN 36

define IN_06 REG_READ(GPIO_IN1_REG) & BIT4 //36 -32

define IN_07_PIN 39

define IN_07 REG_READ(GPIO_IN1_REG) & BIT7 //39 -32

/==================================================================/

define CTRL_DIRSETUP 0b00000001

define CTRL_ACCEL 0b00000010

define CTRL_PWMFREQ 0b00000100

define CTRL_READY 0b01000000

define CTRL_ENABLE 0b10000000

define IO_00 0b00000001

define IO_01 0b00000010

define IO_02 0b00000100

define IO_03 0b00001000

define IO_04 0b00010000

define IO_05 0b00100000

define IO_06 0b01000000

define IO_07 0b10000000

/==================================================================/

struct cmdPacket { uint8_t control; uint8_t io; uint16_t pwm[6]; int32_t pos[3]; float vel[3]; } cmd = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f };

struct fbPacket { uint8_t control; uint8_t io; int32_t pos[3]; float vel[3]; } fb = { 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f };

/==================================================================/

volatile unsigned long ul_dirSetup[3] = { 1000, 1000, 1000 }; // x 25 nanosec volatile float f_accel_x2[3] = { 1000.0, 1000.0, 1000.0 }; // acceleration*2 step/sec2

volatile unsigned long ul_cmd_T[3]; unsigned long ul_accelStep[3] = { 0, 0, 0 };

volatile unsigned long ul_T[3] = { 0, 0, 0 }; volatile unsigned long ul_TH[3] = { 0, 0, 0 }; volatile unsigned long ul_TL[3] = { 0, 0, 0 }; volatile bool b_math[3] = { false, false, false }; volatile bool b_dirSignal[3] = { LOW, LOW, LOW }; volatile bool b_dirChange[3] = { false, false, false };

const uint8_t pwm_pin[6] = { OUT_00_PIN, OUT_01_PIN, OUT_02_PIN, OUT_03_PIN, OUT_04_PIN, OUT_05_PIN }; bool pwm_enable[6] = { false, false, false, false, false, false };

hw_timer_t stepGen_0 = NULL; hw_timer_t stepGen_1 = NULL; hw_timer_t* stepGen_2 = NULL;

/==================================================================/ float IRAM_ATTR fastInvSqrt(const float x) { const float xhalf = x 0.5f; union { float x; uint32_t i; } u = { .x = x }; u.i = 0x5f3759df - (u.i >> 1); return u.x (1.5f - xhalf u.x u.x); }

/==================================================================/

void IRAM_ATTR onTime_0() { static bool b_stepState = LOW; static bool b_dirState = LOW;

if (b_stepState == LOW) {
    if (ul_T[0]) {
        if (!b_dirChange[0]) {
            STEP_0_H;
            timerWrite(stepGen_0, ul_TH[0]);
            b_dirState ? fb.pos[0]++ : fb.pos[0]--;
            b_math[0] = true;
        } else {
            if (b_dirSignal[0]) {
                DIR_0_H;
                b_dirState = HIGH;
            } else {
                DIR_0_L;
                b_dirState = LOW;
            }
            timerWrite(stepGen_0, ul_dirSetup[0]);
            b_dirChange[0] = false;
        }
    } else {
        timerWrite(stepGen_0, 4000ul);
        b_math[0] = true;
    }
} else {
    STEP_0_L;
    timerWrite(stepGen_0, ul_TL[0]);
    b_stepState = LOW;
}

}

void IRAM_ATTR onTime_1() { static bool b_stepState = LOW; static bool b_dirState = LOW;

if (b_stepState == LOW) {
    if (ul_T[1]) {
        if (!b_dirChange[1]) {
            STEP_1_H;
            timerWrite(stepGen_1, ul_TH[1]);
            b_stepState = HIGH;
            b_dirState ? fb.pos[1]++ : fb.pos[1]--;
            b_math[1] = true;
        } else {
            if (b_dirSignal[1]) {
                DIR_1_H;
                b_dirState = HIGH;
            } else {
                DIR_1_L;
                b_dirState = LOW;
            }
            timerWrite(stepGen_1, ul_dirSetup[1]);
            b_dirChange[1] = false;
        }
    } else {
        timerWrite(stepGen_1, 4000ul);
        b_math[1] = true;
    }
} else {
    STEP_1_L;
    timerWrite(stepGen_1, ul_TL[1]);
    b_stepState = LOW;
}

}

void IRAM_ATTR onTime_2() { static bool b_stepState = LOW; static bool b_dirState = LOW;

if (b_stepState == LOW) {
    if (ul_T[2]) {
        if (!b_dirChange[2]) {
            STEP_2_H;
            timerWrite(stepGen_2, ul_TH[2]);
            b_stepState = HIGH;
            b_dirState ? fb.pos[2]++ : fb.pos[2]--;
            b_math[2] = true;
        } else {
            if (b_dirSignal[2]) {
                DIR_2_H;
                b_dirState = HIGH;
            } else {
                DIR_2_L;
                b_dirState = LOW;
            }
            timerWrite(stepGen_2, ul_dirSetup[2]);
            b_dirChange[2] = false;
        }
    } else {
        timerWrite(stepGen_2, 4000ul);
        b_math[2] = true;
    }
} else {
    STEP_2_L;
    timerWrite(stepGen_2, ul_TL[2]);
    b_stepState = LOW;
}

}

/==================================================================/ void IRAM_ATTR newT(const int i) { ul_T[i] = 40000000.0f fastInvSqrt((float)ul_accelStep[i] f_accel_x2[i]); ul_TH[i] = ul_T[i] >> 1; ul_TL[i] = ul_T[i] - ul_TH[i]; }

/==================================================================/ void IRAM_ATTR deceleration(const int i) { if (ul_accelStep[i]) { ul_accelStep[i]--; if (ul_accelStep[i]) newT(i); else ul_T[i] = 0; } }

void IRAM_ATTR acceleration(const int i) { if (cmd.control & CTRL_ENABLE) { ul_accelStep[i]++; newT(i); } else deceleration(i); }

/==================================================================/ void IRAM_ATTR outputHandler() { static int last_pwm[6] = { 0, 0, 0, 0, 0, 0 };

bool enable = cmd.control & CTRL_ENABLE;

if (pwm_enable[0]) {
    if (enable) {
        if (last_pwm[0] != cmd.pwm[0]) {
            last_pwm[0] = cmd.pwm[0];
            ledcWrite(0, last_pwm[0]);
        }
    } else {
        ledcWrite(0, 0);
        last_pwm[0] = 0;
    }
} else {
    if (enable) {
        if (cmd.io & IO_00) {
            OUT_00_H;
        } else {
            OUT_00_L;
        }
    } else {
        OUT_00_L;
    }
}

if (pwm_enable[1]) {
    if (enable) {
        if (last_pwm[1] != cmd.pwm[1]) {
            last_pwm[1] = cmd.pwm[1];
            ledcWrite(2, last_pwm[1]);
        }
    } else {
        ledcWrite(2, 0);
        last_pwm[1] = 0;
    }
} else {
    if (enable) {
        if (cmd.io & IO_01) {
            OUT_01_H;
        } else {
            OUT_01_L;
        }
    } else {
        OUT_01_L;
    }
}

if (pwm_enable[2]) {
    if (enable) {
        if (last_pwm[2] != cmd.pwm[2]) {
            last_pwm[2] = cmd.pwm[2];
            ledcWrite(4, last_pwm[2]);
        }
    } else {
        ledcWrite(4, 0);
        last_pwm[2] = 0;
    }
} else {
    if (enable) {
        if (cmd.io & IO_02) {
            OUT_02_H;
        } else {
            OUT_02_L;
        }
    } else {
        OUT_02_L;
    }
}

if (pwm_enable[3]) {
    if (enable) {
        if (last_pwm[3] != cmd.pwm[3]) {
            last_pwm[3] = cmd.pwm[3];
            ledcWrite(6, last_pwm[3]);
        }
    } else {
        ledcWrite(6, 0);
        last_pwm[3] = 0;
    }
} else {
    if (enable) {
        if (cmd.io & IO_03) {
            OUT_03_H;
        } else {
            OUT_03_L;
        }
    } else {
        OUT_03_L;
    }
}

if (pwm_enable[4]) {
    if (enable) {
        if (last_pwm[4] != cmd.pwm[4]) {
            last_pwm[4] = cmd.pwm[4];
            ledcWrite(8, last_pwm[4]);
        }
    } else {
        ledcWrite(8, 0);
        last_pwm[4] = 0;
    }
} else {
    if (enable) {
        if (cmd.io & IO_04) {
            OUT_04_H;
        } else {
            OUT_04_L;
        }
    } else {
        OUT_04_L;
    }
}

if (pwm_enable[5]) {
    if (enable) {
        if (last_pwm[5] != cmd.pwm[5]) {
            last_pwm[5] = cmd.pwm[5];
            ledcWrite(10, last_pwm[5]);
        }
    } else {
        ledcWrite(10, 0);
        last_pwm[5] = 0;
    }
} else {
    if (enable) {
        if (cmd.io & IO_05) {
            OUT_05_H;
        } else {
            OUT_05_L;
        }
    } else {
        OUT_05_L;
    }
}

}

/==================================================================/ void IRAM_ATTR inputHandler() { (IN_00) ? fb.io = IO_00 : fb.io = 0; if (IN_01) fb.io |= IO_01; if (IN_02) fb.io |= IO_02; if (IN_03) fb.io |= IO_03; if (IN_04) fb.io |= IO_04; if (IN_05) fb.io |= IO_05; if (IN_06) fb.io |= IO_06; if (IN_07) fb.io |= IO_07; } /==================================================================/ void IRAM_ATTR commandHandler() { if (cmd.control & CTRL_READY) { Serial.println("Handling CTRL_READY");

    for (int i = 0; i < 3; i++) {
        if (cmd.vel[i] > 0.0f)
            ul_cmd_T[i] = (unsigned long)(40000000.0f / cmd.vel[i]);
        else if (cmd.vel[i] < 0.0f)
            ul_cmd_T[i] = (unsigned long)(40000000.0f / -cmd.vel[i]);
        else
            ul_cmd_T[i] = 40000000ul;
    }
}

if (!(fb.control & CTRL_READY)) {
    Serial.println("fb.control not ready");

    if ((fb.control & CTRL_DIRSETUP)
        && (fb.control & CTRL_ACCEL)
        && (fb.control & CTRL_PWMFREQ)) {
        fb.control |= CTRL_READY;
        Serial.println("CTRL_READY set");
    } else if (cmd.control & CTRL_DIRSETUP) {
        fb.control |= CTRL_DIRSETUP;
        for (int i = 0; i < 3; i++)
            ul_dirSetup[i] = cmd.pos[i] / 25; // 25ns / timer tic
        Serial.println("CTRL_DIRSETUP set");
    } else if (cmd.control & CTRL_ACCEL) {
        fb.control |= CTRL_ACCEL;
        for (int i = 0; i < 3; i++)
            f_accel_x2[i] = (float)cmd.pos[i] * 2.0;
        Serial.println("CTRL_ACCEL set");
    } else if (cmd.control & CTRL_PWMFREQ) {
        fb.control |= CTRL_PWMFREQ;
        for (int i = 0; i < 6; i++) {
            if (cmd.pwm[i]) {
                ledcAttach(pwm_pin[i], i * 2, true);
                ledcAttach(pwm_pin[i], cmd.pwm[i], 10);
                ledcWrite(i * 2, 0);
                pwm_enable[i] = true;
                Serial.print("PWM enabled for pin ");
                Serial.println(pwm_pin[i]);
            } else {
                if (i == 0) {
                    pinMode(OUT_00_PIN, OUTPUT);
                    digitalWrite(OUT_00_PIN, 0);
                } else if (i == 1) {
                    pinMode(OUT_01_PIN, OUTPUT);
                    digitalWrite(OUT_01_PIN, 0);
                } else if (i == 2) {
                    pinMode(OUT_02_PIN, OUTPUT);
                    digitalWrite(OUT_02_PIN, 0);
                } else if (i == 3) {
                    pinMode(OUT_03_PIN, OUTPUT);
                    digitalWrite(OUT_03_PIN, 0);
                } else if (i == 4) {
                    pinMode(OUT_04_PIN, OUTPUT);
                    digitalWrite(OUT_04_PIN, 0);
                } else if (i == 5) {
                    pinMode(OUT_05_PIN, OUTPUT);
                    digitalWrite(OUT_05_PIN, 0);
                }
            }
        }
    }
}

} /==================================================================/ void IRAM_ATTR loop_Core0(void* parameter) { delay(500); Udp.parsePacket(); // to empty buffer

Serial.println("Entering loop_Core0");

// Add this task to the watchdog timer
esp_task_wdt_add(NULL);

for (;;) {
    static unsigned long ul_watchdog;

    if (Udp.parsePacket() == sizeof(cmd) + 1) {
        Serial.println("Packet received");

        char packetBuffer[60]; // buffer for receiving and sending data
        Udp.read(packetBuffer, sizeof(cmd) + 1);

        // Print the raw packet data
        Serial.print("Received raw packet: ");
        for (int i = 0; i < sizeof(cmd) + 1; i++) {
            Serial.print(packetBuffer[i], HEX);
            Serial.print(" ");
        }
        Serial.println();

        uint8_t chk = 71;
        for (int i = 0; i < sizeof(cmd); i++)
            chk ^= packetBuffer[i];

        if (packetBuffer[sizeof(cmd)] == chk) {
            memcpy(&cmd, &packetBuffer, sizeof(cmd));

            // Print the received command packet data
            Serial.println("Received cmdPacket:");
            Serial.print("  control: "); Serial.println(cmd.control, HEX);
            Serial.print("  io: "); Serial.println(cmd.io, HEX);
            for (int i = 0; i < 6; i++) {
                Serial.print("  pwm["); Serial.print(i); Serial.print("]: "); Serial.println(cmd.pwm[i]);
            }
            for (int i = 0; i < 3; i++) {
                Serial.print("  pos["); Serial.print(i); Serial.print("]: "); Serial.println(cmd.pos[i]);
            }
            for (int i = 0; i < 3; i++) {
                Serial.print("  vel["); Serial.print(i); Serial.print("]: "); Serial.println(cmd.vel[i]);
            }

            commandHandler();
            ul_watchdog = millis();
        }

        inputHandler();

        for (int i = 0; i < 3; i++) {
            unsigned long ul_t = ul_T[i];
            if (ul_t)
                b_dirSignal[i] ? fb.vel[i] = 40000000.0f / (float)ul_t : fb.vel[i] = -40000000.0f / (float)ul_t;
            else
                fb.vel[i] = 0.0f;
        }

        // Print the fbPacket data before sending it
        Serial.println("Sending fbPacket:");
        Serial.print("  control: "); Serial.println(fb.control, HEX);
        Serial.print("  io: "); Serial.println(fb.io, HEX);
        for (int i = 0; i < 3; i++) {
            Serial.print("  pos["); Serial.print(i); Serial.print("]: "); Serial.println(fb.pos[i]);
        }
        for (int i = 0; i < 3; i++) {
            Serial.print("  vel["); Serial.print(i); Serial.print("]: "); Serial.println(fb.vel[i]);
        }

        memcpy(&packetBuffer, &fb, sizeof(fb));

        Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
        Udp.write(packetBuffer, sizeof(fb));
        Udp.endPacket();
    }

    if (millis() - ul_watchdog > 10ul) {
        fb.control = 0;
        cmd.control = 0;
        outputHandler();
        ul_watchdog = millis();
    }

    Serial.println("Resetting watchdog timer");
    esp_task_wdt_reset();
}

}

/==================================================================/

void configureInputPins() { Serial.println("Configuring input pins..."); pinMode(IN_00_PIN, INPUT_PULLUP); pinMode(IN_01_PIN, INPUT_PULLUP); pinMode(IN_02_PIN, INPUT_PULLUP); pinMode(IN_03_PIN, INPUT_PULLUP);

pinMode(IN_04_PIN, INPUT);
pinMode(IN_05_PIN, INPUT);
pinMode(IN_06_PIN, INPUT);
pinMode(IN_07_PIN, INPUT);

}

void setup_Core0(void* parameter) { Serial.println("Entering setup_Core0");

configureInputPins();
delay(500);

Serial.println("Starting UDP...");
Udp.begin(port); // Start UDP
delay(100);

Serial.println("Creating loop task on core 0...");

// Add current task to the watchdog timer
esp_task_wdt_add(NULL);

xTaskCreatePinnedToCore(
    loop_Core0, // Task function
    "loopTask_Core0", // Name of task
    8192, // Increased stack size
    NULL, // Parameter of the task
    1, // Priority of the task
    NULL, // Task handle to keep track of created task
    0); // Pin task to core 0

Serial.println("Task created, deleting setup_Core0 task...");
vTaskDelete(NULL);

}

void setup() { Serial.begin(115200); // Ensure this matches your configuration

pinMode(STEP_0_PIN, OUTPUT);
digitalWrite(STEP_0_PIN, 0);
pinMode(DIR_0_PIN, OUTPUT);
digitalWrite(DIR_0_PIN, 0);
pinMode(STEP_1_PIN, OUTPUT);
digitalWrite(STEP_1_PIN, 0);
pinMode(DIR_1_PIN, OUTPUT);
digitalWrite(DIR_1_PIN, 0);
pinMode(STEP_2_PIN, OUTPUT);
digitalWrite(STEP_2_PIN, 0);
pinMode(DIR_2_PIN, OUTPUT);
digitalWrite(DIR_2_PIN, 0);

// Configure the timers
stepGen_0 = timerBegin(40000000); // Timer 0
stepGen_1 = timerBegin(40000000); // Timer 1
stepGen_2 = timerBegin(40000000); // Timer 2

// Attach the interrupt service routine (ISR) `onTime_0` to Timer 0.
timerAttachInterrupt(stepGen_0, &onTime_0);
// Attach the ISR `onTime_1` to Timer 1.
timerAttachInterrupt(stepGen_1, &onTime_1);
// Attach the ISR `onTime_2` to Timer 2.
timerAttachInterrupt(stepGen_2, &onTime_2);

// Set the alarm value for Timer 0 to 40,000,000 microseconds (40 seconds).
timerAlarm(stepGen_0, 40000000, true, 0);
// Set the alarm value for Timer 1 to 40,000,000 microseconds (40 seconds).
timerAlarm(stepGen_1, 40000000, true, 0);
// Set the alarm value for Timer 2 to 40,000,000 microseconds (40 seconds).
timerAlarm(stepGen_2, 40000000, true, 0);
Serial.println("Initializing Ethernet...");
UIPEthernet.init(SPI_CS_PIN); // Use UIPEthernet.init(pin) to configure the CS pin

if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Ethernet.begin(mac, ip);
} else {
    Serial.print("DHCP assigned IP: ");
    Serial.println(Ethernet.localIP());
}

Serial.print("Server IP address: ");
Serial.println(ip);

// Check if the watchdog timer is already initialized
if (esp_task_wdt_status(NULL) == ESP_ERR_NOT_FOUND) {
    // Define the watchdog timer configuration
    esp_task_wdt_config_t wdt_config = {
        .timeout_ms = 10000, // 10 seconds timeout
        .trigger_panic = true
    };

    // Initialize the watchdog timer
    esp_task_wdt_init(&wdt_config);
}

// Add the current task to the watchdog
esp_task_wdt_add(NULL);

xTaskCreatePinnedToCore(
    setup_Core0, // Task function.
    "setup_Core0Task", // name of task.
    8192, // Increase Stack size of task
    NULL, // parameter of the task
    1, // priority of the task (change from 0 to 1)
    NULL, // Task handle to keep track of created task
    0); // pin task to core 0

vTaskDelete(NULL);

}

/==================================================================/ void IRAM_ATTR loop() { // Motor control logic for (int i = 0; i < 3; i++) { if (b_math[i]) { Serial.print("Math processing for axis: "); Serial.println(i); b_math[i] = false; if (!ul_accelStep[i]) { // the axis is stationary long l_pos_error = cmd.pos[i] - fb.pos[i]; Serial.print("Position error for axis "); Serial.print(i); Serial.print(": "); Serial.println(l_pos_error); if (l_pos_error) { // if there is a position error if ((l_pos_error > 0 && b_dirSignal[i] == HIGH) || (l_pos_error < 0 && b_dirSignal[i] == LOW)) // the direction is good acceleration(i); else { // need to change direction (l_pos_error > 0) ? b_dirSignal[i] = HIGH : b_dirSignal[i] = LOW; b_dirChange[i] = true; Serial.print("Changing direction for axis "); Serial.println(i); } } } else { // the axis moves Serial.print("Axis "); Serial.print(i); Serial.println(" is moving"); if ((cmd.vel[i] > 0.0f && b_dirSignal[i] == HIGH) || (cmd.vel[i] < 0.0f && b_dirSignal[i] == LOW)) { // the direction is good if (ul_T[i] > ul_cmd_T[i]) // the speed is low acceleration(i); else if (ul_T[i] < ul_cmd_T[i]) // the speed is high deceleration(i); } else // the direction is wrong or the target speed is zero deceleration(i); } } }

// Ethernet server logic
EthernetClient client = server.available();
if (client) {
    Serial.println("Client connected");
    client.println("Hello, client!");
    delay(1000);
    client.stop();
    Serial.println("Client disconnected");
}

}

`

for this i'm getting output 18:42:53.285 -> mode:DIO, clock div:1 18:42:53.317 -> load:0x3fff0030,len:1448 18:42:53.317 -> load:0x40078000,len:14844 18:42:53.317 -> ho 0 tail 12 room 4 18:42:53.317 -> load:0x40080400,len:4 18:42:53.317 -> load:0x40080404,len:3356 18:42:53.317 -> entry 0x4008059c 18:42:53.448 -> Initializing Ethernet... 18:43:53.774 -> Failed to configure Ethernet using DHCP 18:43:53.839 -> Server IP address: 192.168.96.54 18:43:53.839 -> E (60379) task_wdt: esp_task_wdt_init(573): TWDT already initialized 18:43:53.839 -> Entering setup_Core0 18:43:53.839 -> Configuring input pins... 18:43:54.331 -> Starting UDP... 18:43:54.430 -> Creating loop task on core 0... 18:43:54.430 -> Task created, deleting setup_Core0 task... 18:43:54.955 -> Entering loop_Core0 18:43:54.955 -> Packet received 18:43:54.955 -> Received raw packet: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 BB 0 0 0 EE 2 0 80 A9 3 0 0 0 0 0 0 0 0 0 0 0 0 0 B8 18:43:54.955 -> Received cmdPacket: 18:43:54.955 -> control: 2 18:43:54.955 -> io: 0 18:43:54.955 -> pwm[0]: 0 18:43:54.955 -> pwm[1]: 0 18:43:54.955 -> pwm[2]: 0 18:43:54.955 -> pwm[3]: 0 18:43:54.955 -> pwm[4]: 0 18:43:54.955 -> pwm[5]: 0 18:43:54.955 -> pos[0]: 48000 18:43:54.955 -> pos[1]: 192000 18:43:54.985 -> pos[2]: 240000 18:43:54.986 -> vel[0]: 0.00 18:43:54.986 -> vel[1]: 0.00 18:43:54.986 -> vel[2]: 0.00 18:43:54.986 -> fb.control not ready 18:43:54.986 -> CTRL_ACCEL set 18:43:54.986 -> Sending fbPacket: 18:43:54.986 -> control: 2 Can you help me out?