S88 Calibration log V3.1.9

This commit is contained in:
Gingerman1996
2025-01-06 13:50:28 +07:00
parent c841476ca4
commit 4691500f5f
4 changed files with 70 additions and 16 deletions

View File

@ -12,7 +12,9 @@
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
build_flags = !echo '-D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MODE=1 -D GIT_VERSION=\\"'$(git describe --tags --always --dirty)'\\"'
; build_flags = !echo '-D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MODE=1 -D GIT_VERSION=\\"'$(git describe --tags --always --dirty)'\\"'
build_flags = -D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MODE=1
extra_scripts = pre:version.py
board_build.partitions = partitions.csv
monitor_speed = 115200
lib_deps =
@ -27,17 +29,17 @@ lib_deps =
Update
DNSServer
[env:esp8266]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 115200
lib_deps =
aglib=symlink://../arduino
EEPROM
ESP8266HTTPClient
ESP8266WebServer
DNSServer
; [env:esp8266]
; platform = espressif8266
; board = d1_mini
; framework = arduino
; monitor_speed = 115200
; lib_deps =
; aglib=symlink://../arduino
; EEPROM
; ESP8266HTTPClient
; ESP8266WebServer
; DNSServer
monitor_filters = time

View File

@ -242,6 +242,7 @@ void StateMachine::co2Calibration(void) {
}
delay(1000);
}
delay(2000);
if (ag->s8.setBaselineCalibration()) {
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_3()) {

View File

@ -1,6 +1,6 @@
#include "S8.h"
#include "mb_crc.h"
#include "../Main/utils.h"
#include "mb_crc.h"
#if defined(ESP8266)
#include <SoftwareSerial.h>
#else
@ -275,6 +275,7 @@ bool S8::isBaseLineCalibrationDone(void) {
return true;
}
if (getAcknowledgement() & S8_MASK_CO2_BACKGROUND_CALIBRATION) {
Serial.println("Waiting getAcknowlagdement");
return true;
}
return false;
@ -396,10 +397,8 @@ bool S8::manualCalib(void) {
}
bool result = clearAcknowledgement();
if (result) {
result = sendSpecialCommand(S8_CO2_BACKGROUND_CALIBRATION);
if (result) {
AgLog("Manual calibration in background has started");
} else {
@ -425,17 +424,29 @@ int16_t S8::getAcknowledgement(void) {
// Ask acknowledgement flags
sendCommand(MODBUS_FUNC_READ_HOLDING_REGISTERS, MODBUS_HR1, 0x0001);
Serial.print("Get Acknowladgement Command > ");
for (int i = 0; i < 8; i++) {
Serial.printf(" 0x%02X ", buf_msg[i]);
}
Serial.println();
// Wait response
memset(buf_msg, 0, S8_LEN_BUF_MSG);
uint8_t nb = uartReadBytes(7, S8_TIMEOUT);
Serial.print("Get Acknowladgement Response > ");
for (int i = 0; i < nb; i++) {
Serial.printf(" 0x%02X ", buf_msg[i]);
}
Serial.println();
// Check response and get data
if (validResponseLenght(MODBUS_FUNC_READ_HOLDING_REGISTERS, nb, 7)) {
flags = ((buf_msg[3] << 8) & 0xFF00) | (buf_msg[4] & 0x00FF);
Serial.printf("Flags: %x\n", flags);
} else {
AgLog("Error getting acknowledgement flags!");
Serial.println("Error getting acknowledgement flags!");
}
return flags;
}
@ -455,6 +466,11 @@ bool S8::clearAcknowledgement(void) {
// Ask clear acknowledgement flags
sendCommand(MODBUS_FUNC_WRITE_SINGLE_REGISTER, MODBUS_HR1, 0x0000);
Serial.print("Clear Acknowladgement Command > ");
for (int i = 0; i < 8; i++) {
Serial.printf(" 0x%02X ", buf_msg[i]);
}
Serial.println();
// Save bytes sent
memcpy(buf_msg_sent, buf_msg, 8);
@ -462,6 +478,12 @@ bool S8::clearAcknowledgement(void) {
// Wait response
memset(buf_msg, 0, S8_LEN_BUF_MSG);
uartReadBytes(8, S8_TIMEOUT);
Serial.print("Clear Acknowladgement Response > ");
for (int i = 0; i < 8; i++) {
Serial.printf(" 0x%02X ", buf_msg[i]);
}
Serial.println();
// Check response
if (memcmp(buf_msg_sent, buf_msg, 8) == 0) {
@ -578,6 +600,11 @@ bool S8::sendSpecialCommand(CalibrationSpecialComamnd command) {
// Ask set user special command
sendCommand(MODBUS_FUNC_WRITE_SINGLE_REGISTER, MODBUS_HR2, command);
Serial.print("Send Calibration Command > ");
for (int i = 0; i < 8; i++) {
Serial.printf(" 0x%02X ", buf_msg[i]);
}
Serial.println();
// Save bytes sent
memcpy(buf_msg_sent, buf_msg, 8);
@ -586,6 +613,12 @@ bool S8::sendSpecialCommand(CalibrationSpecialComamnd command) {
memset(buf_msg, 0, S8_LEN_BUF_MSG);
uartReadBytes(8, S8_TIMEOUT);
Serial.print("Send Calibration Response > ");
for (int i = 0; i < 8; i++) {
Serial.printf(" 0x%02X ", buf_msg[i]);
}
Serial.println();
// Check response
if (memcmp(buf_msg_sent, buf_msg, 8) == 0) {
result = true;

18
version.py Normal file
View File

@ -0,0 +1,18 @@
import subprocess
import os
def get_git_version():
try:
version = subprocess.check_output(["git", "describe", "--tags", "--always", "--dirty"]).decode("utf-8").strip()
return version
except Exception as e:
print("Could not get git version:", e)
return "unknown"
git_version = get_git_version()
# git_version = "0.8.7-1-g118f259-dirty"
print("GIT_VERSION:", git_version)
# เพิ่ม GIT_VERSION เป็น build flag
Import("env")
env.Append(CPPDEFINES=[("GIT_VERSION", '\\"{}\\"'.format(git_version))])