Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to edit schedules
#1
Hi, 

  I do not seem to be able to edit AC outlet schedules. Surprisingly, I could not find anything relevant on the forum; looks like I'm the only one experiencing this issue. I run a fresh installation of RoboTank 6.6 on Raspbian Bullseye, following installation instructions posted in the documentation and a couple of forum posts. 

  I added simple on/off AC outlet schedules, but whenever I try to modify on/off time on the existing schedule and click the Save button, robotank process crashes with error.

Dec 28 00:14:10 robotank startup[1613]: incomingCommand = 71, 7, 1, CO2 ON, 39661, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, null,
Dec 28 00:14:10 robotank startup[1613]: terminate called after throwing an instance of 'std::invalid_argument'
Dec 28 00:14:10 robotank startup[1613]:  what():  stof
Dec 28 00:14:11 robotank startup[1611]: Aborted

Systemd immediately restarts the process, but changes are not saved. Fortunately, I can still delete the schedule and recreate it with a new time, but still quite annoying. Any ideas what the issue could be? Any troubleshooting suggestions?

Thanks
Reply to top
#2
Hi RustyBits, interesting, I just tested mine and its ok, I thought it was something I fixed but code seems ok in 6.6 but based on the info you posted I can see it crashed when running stof (string to float) conversion. This is the line it's crashing.

    scheduleML[arrayLoc] = std::stof(mL);

In the first line you posted is the incoming data from the frontend. The last variable is "null" when it should be a number. This is the mL for dosing, if the schedule isn't for dosing I post 0 as mL in the database, that doesn't seem to be happening in your case.

Here's how you fix it. Run the following commands.

sudo systemctl stop robotank.service

sudo nano /var/www/html/cpp/schedules.h

Scroll down to near the bottom of the file and you'll see the function saveSchedule(). Look for this section.

Code:
void schedules::saveSchedule(int schID, short offOn, char* schName, int start, bool mon, bool tue, bool wed, bool thu, bool fri, bool sat, bool sun, short repeatDays, bool enabled, bool email, bool alert, std::string mL) {  // update existing
    // std::cout << "saveSchedule----------- " << endl;
    // std::cout << "schID       - " << schID << std::endl;
    // std::cout << "offOn       - " << offOn << std::endl;
    // std::cout << "schName     - " << schName << std::endl;
    // std::cout << "start       - " << start << std::endl;
    // std::cout << "mon         - " << mon << std::endl;
    // std::cout << "tue         - " << tue << std::endl;
    // std::cout << "wed         - " << wed << std::endl;
    // std::cout << "thu         - " << thu << std::endl;
    // std::cout << "fri         - " << fri << std::endl;
    // std::cout << "sat         - " << sat << std::endl;
    // std::cout << "sun         - " << sun << std::endl;
    // std::cout << "repeatDays  - " << repeatDays << std::endl;
    // std::cout << "enabled     - " << enabled << std::endl;
    // std::cout << "email       - " << email << std::endl;
    // std::cout << "alert       - " << alert << std::endl;
    // std::cout << "mL          - " << mL << std::endl;

    short arrayLoc = 255;
    for (short a = 0; a < totalSchedules; a++)  // get array location for schedule
    {
        if (scheduleID[a] == schID) {arrayLoc = a; break;}
    }
    // std::cout << "arrayLoc - " << arrayLoc << std::endl;

After the last line I posted above add the following line.

    if (mL == "null") {mL = "0";}  // Check if the string is "null"

Then press CTRL-S on the keyboard to save. Then CTRL-X to exit and run the following commands.

cd /var/www/html/cpp

g++ -o robotank robotank.cpp `mysql_config --cflags --libs` -lwiringPi -lpthread -lquickmail -lcurl -lwebsockets

sudo systemctl start robotank.service

Test it out. :)
Reply to top
#3
Fantastic, it's now working perfectly!

All I needed to do to apply the suggested fix was install the latest version of wiringPi on the system, which enabled me to recompile successfully.



Code:
cd /tmp
wget https://github.com/WiringPi/WiringPi/releases/download/2.61-1/wiringpi-2.61-1-armhf.deb
sudo dpkg -i wiringpi-2.61-1-armhf.deb



Thank you  K0507
[-] The following 1 user Likes RustyBits's post:
  • Rob F
Reply to top
#4
Awesome, glad you figured it out. Thanks for letting me know.
Reply to top


Forum Jump:

Current time: 03-01-2024, 01:41 AM