wezhunter / ESP32_LinuxCNC_MotionController_RealTime

ESP32 hardware based real-time LinuxCNC motion controller
GNU General Public License v3.0
16 stars 10 forks source link

issue with spiethconfig #29

Open simonsdialogs opened 4 months ago

simonsdialogs commented 4 months ago

the function doesn't work because the variable is incorrectly assigned, the result is always written to miso_pin rather than to the correct variable.

  if (result.count("s")) { miso_pin = result["s"].as<int>(); }
        if (miso_pin < 0 || miso_pin > 128 ) { printf_P(PSTR("Invalid or missing MISO pin (0>128)\n")); return EXIT_FAILURE;}

        if (result.count("i")) { miso_pin = result["i"].as<int>(); }
        if (mosi_pin < 0 || mosi_pin > 128 ) { printf_P(PSTR("Invalid or missing MOSI pin (0>128)\n")); return EXIT_FAILURE;}

        if (result.count("c")) { miso_pin = result["c"].as<int>(); }
        if (sck_pin < 0 || sck_pin > 128 ) { printf_P(PSTR("Invalid or missing SCK pin (0>128)\n")); return EXIT_FAILURE;}

        if (result.count("e")) { miso_pin = result["e"].as<int>(); }
        if (cs_pin < 0 || cs_pin > 128 ) { printf_P(PSTR("Invalid or missing Chip Select pin (0>128)\n")); return EXIT_FAILURE;}

        if (result.count("t")) { miso_pin = result["t"].as<int>(); }
        if (int_pin < 0 || int_pin > 128 ) { printf_P(PSTR("Invalid or missing Interrupt pin (0>128)\n")); return EXIT_FAILURE;}
michaelnum commented 3 weeks ago

Hello, does anybody get this spiethconfig working?

I think simonsdialogs means this:

if (result.count("s")) { miso_pin = result["s"].as(); } if (miso_pin < 0 || miso_pin > 128 ) { printf_P(PSTR("Invalid or missing MISO pin (0>128)\n")); return EXIT_FAILURE;}

if (result.count("i")) { mosi_pin = result["i"].as(); } if (mosi_pin < 0 || mosi_pin > 128 ) { printf_P(PSTR("Invalid or missing MOSI pin (0>128)\n")); return EXIT_FAILURE;}

if (result.count("c")) { sck_pin = result["c"].as(); } if (sck_pin < 0 || sck_pin > 128 ) { printf_P(PSTR("Invalid or missing SCK pin (0>128)\n")); return EXIT_FAILURE;}

if (result.count("e")) { cs_pin = result["e"].as(); } if (cs_pin < 0 || cs_pin > 128 ) { printf_P(PSTR("Invalid or missing Chip Select pin (0>128)\n")); return EXIT_FAILURE;}

if (result.count("t")) { int_pin = result["t"].as(); } if (int_pin < 0 || int_pin > 128 ) { printf_P(PSTR("Invalid or missing Interrupt pin (0>128)\n")); return EXIT_FAILURE;}

But only with this the spiethconfig don't work. It always breaks on the fouth value "cs_pin".

I made some tests (but i am not good in C coding). At the end i sort this 5 values in an other way and the error stays at the fourth value. That mans that is not a problem from the value "cs_pin", it is only the position.

Has anybody an idea? Is that a bug in the ESP32Console library?