Przetestowałem na szybko na 4 roletach no i cholera działa
Niebawem przetestuje na całej chałupie.
Jeszcze raz dziękuję!
Code: Select all
void writeIntEeprom(int cell, int _value) {
EEPROM.begin(1024);
delay(10);
EEPROM.write(cell, _value);
EEPROM.end();
}Code: Select all
void saveVRelayState() {
if (relays_state_memory == 1 ) {
for (int i = 0; i < max_vrelays; i++) {
vr_state_[i] = vrelay_[i]->isOn();
if (vrelay_state_[i] != vr_state_[i]) {
writeIntEeprom(ep_min_vrelay_state+i, vr_state_[i]);
Serial.printf("# saved v-relay_%d state > %d\n\r", i, vr_state_[i]);
vrelay_state_[i] = !vrelay_state_[i];
}
}
}
}Code: Select all
Sending: [53 55 50 4C 41 C B 0 0 0 28 0 0 0 10 0 0 0 E6 0 0 0 0 0 0 0 DB 21 C 0 0 0 0 0 ]
Sending: [53 55 50 4C 41 ]
Received: [53 55 50 4C 41 C B 0 0 0 32 0 0 0 10 0 0 0 A C5 67 5F 0 0 0 0 E3 9C 1 0 0 0 0 0 53 55 50 4C 41 ]
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Sending: [53 55 50 4C 41 C C 0 0 0 28 0 0 0 10 0 0 0 FF 0 0 0 0 0 0 0 A5 25 C 0 0 0 0 0 ]
Sending: [53 55 50 4C 41 ]
Received: [53 55 50 4C 41 C C 0 0 0 32 0 0 0 10 0 0 0 23 C5 67 5F 0 0 0 0 27 9D 1 0 0 0 0 0 53 55 50 4C 41 ]
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Sending: [53 55 50 4C 41 C D 0 0 0 28 0 0 0 10 0 0 0 18 1 0 0 0 0 0 0 9C 29 C 0 0 0 0 0 ]
Sending: [53 55 50 4C 41 ]
Received: [53 55 50 4C 41 C D 0 0 0 32 0 0 0 10 0 0 0 3C C5 67 5F 0 0 0 0 CF 67 2 0 0 0 0 0 53 55 50 4C 41 ]
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Sending: [53 55 50 4C 41 C E 0 0 0 28 0 0 0 10 0 0 0 31 1 0 0 0 0 0 0 86 2D C 0 0 0 0 0 ]
Sending: [53 55 50 4C 41 ]
Received: [53 55 50 4C 41 C E 0 0 0 32 0 0 0 10 0 0 0 55 C5 67 5F 0 0 0 0 F3 A5 1 0 0 0 0 0 53 55 50 4C 41 ]
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Sending: [53 55 50 4C 41 C F 0 0 0 28 0 0 0 10 0 0 0 4A 1 0 0 0 0 0 0 5D 31 C 0 0 0 0 0 ]
Sending: [53 55 50 4C 41 ]
Received: [53 55 50 4C 41 C F 0 0 0 32 0 0 0 10 0 0 0 6E C5 67 5F 0 0 0 0 96 AC 1 0 0 0 0 0 53 55 50 4C 41 ]
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Sending: [53 55 50 4C 41 C 10 0 0 0 28 0 0 0 10 0 0 0 63 1 0 0 0 0 0 0 38 35 C 0 0 0 0 0 ]
Sending: [53 55 50 4C 41 ]
Received: [53 55 50 4C 41 C 10 0 0 0 32 0 0 0 10 0 0 0 87 C5 67 5F 0 0 0 0 54 60 2 0 0 0 0 0 53 55 50 4C 41 ]
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Sending: [53 55 50 4C 41 C 11 0 0 0 28 0 0 0 10 0 0 0 7C 1 0 0 0 0 0 0 D 39 C 0 0 0 0 0 ]
Sending: [53 55 50 4C 41 ]
Received: [53 55 50 4C 41 C 11 0 0 0 32 0 0 0 10 0 0 0 A0 C5 67 5F 0 0 0 0 80 AF 1 0 0 0 0 0 53 55 50 4C 41 ]
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Sending: [53 55 50 4C 41 C 12 0 0 0 28 0 0 0 10 0 0 0 95 1 0 0 0 0 0 0 2E 3D C 0 0 0 0 0 ]
Sending: [53 55 50 4C 41 ]
Received: [53 55 50 4C 41 C 12 0 0 0 32 0 0 0 10 0 0 0 B9 C5 67 5F 0 0 0 0 D5 D3 1 0 0 0 0 0 53 55 50 4C 41 ]
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Wrote 9 bytes to storage
Wrote 7 bytes to storage
Commit
Sending: [53 55 50 4C 41 C 13 0 0 0 28 0 0 0 10 0 0 0 AE 1 0 0 0 0 0 0 E8 40 C 0 0 0 0 0 ]
Sending: [53 55 50 4C 41 ]
Received: [53 55 50 4C 41 C 13 0 0 0 32 0 0 0 10 0 0 0 D2 C5 67 5F 0 0 0 0 7E 5F 2 0 0 0 0 0 53 55 50 4C 41 ]Ja bym unikał w kodzie tego typu zapisu w pętli. Najlepiej jeśli "eeprom.begin" robisz na początku, potem aktualizujesz wszysto co się da i na koniec robisz "end" lub "commit". W przypadku ESP8266, eerprom.begin ładuje fragment flasha do pamięci RAM i wszystkie operacje są robione w pamięci RAM, dopóki nie zawołasz commit lub end. Robiąc w pętli "begin" i "end" nadpisujesz wielokrotnie ten obszar flasha i mocno go "zużywasz". Pamiętaj, że tam jest około 100000 cyklów zapisu, a potem mogą pojawić się uszkodzenia pamięci.lukfud wrote: Sun Sep 20, 2020 9:34 pm @klew, mam problem z zapisem do eepromu, kiedy używam też swojej funkcji:
Zgadzam się, ale w tym przypadku "begin" i "end" wywoływane jest tylko przy zmianie stanu przekaźnika. Postaram się przepisać inne części programu, aby jak najrzadziej używać tych wywołań.klew wrote: Mon Sep 21, 2020 7:38 amJa bym unikał w kodzie tego typu zapisu w pętli. Najlepiej jeśli "eeprom.begin" robisz na początku, potem aktualizujesz wszysto co się da i na koniec robisz "end" lub "commit". W przypadku ESP8266, eerprom.begin ładuje fragment flasha do pamięci RAM i wszystkie operacje są robione w pamięci RAM, dopóki nie zawołasz commit lub end. Robiąc w pętli "begin" i "end" nadpisujesz wielokrotnie ten obszar flasha i mocno go "zużywasz". Pamiętaj, że tam jest około 100000 cyklów zapisu, a potem mogą pojawić się uszkodzenia pamięci.lukfud wrote: Sun Sep 20, 2020 9:34 pm @klew, mam problem z zapisem do eepromu, kiedy używam też swojej funkcji:
Druga rzecz - zapisywanie stanu przekaźników będzie lada moment w oficjalnej bibliotece, więc może nie warto tego osobno implementować.
Twój kod się gryzie z moim, bo ja wołam raz "begin(1024)" i potem używam "commit" aby od czasu do czas zapisać do flasha. Natomiast Twój kod woła "end", co powoduje, że biblioteka przestaje sobie radzić z zapisem.
Zmień "end" na "commit" i powinno działać.
Skorzystać z klasy Eeprom/Storage do zapisu swoich dancyh.
Zapisywanie stanu polega na kolejności elementów w aplikacji (podobnie jak serwer oczekuje kanałów w określonej kolejności). Najlepiej byłoby po prostu to doimplelemntować do klasy Relay.
Ok, w takim razie cierpliwie czekam