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 platform = espressif32
board = esp32-c3-devkitm-1 board = esp32-c3-devkitm-1
framework = arduino 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 board_build.partitions = partitions.csv
monitor_speed = 115200 monitor_speed = 115200
lib_deps = lib_deps =
@ -27,17 +29,17 @@ lib_deps =
Update Update
DNSServer DNSServer
[env:esp8266] ; [env:esp8266]
platform = espressif8266 ; platform = espressif8266
board = d1_mini ; board = d1_mini
framework = arduino ; framework = arduino
monitor_speed = 115200 ; monitor_speed = 115200
lib_deps = ; lib_deps =
aglib=symlink://../arduino ; aglib=symlink://../arduino
EEPROM ; EEPROM
ESP8266HTTPClient ; ESP8266HTTPClient
ESP8266WebServer ; ESP8266WebServer
DNSServer ; DNSServer
monitor_filters = time monitor_filters = time

View File

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

View File

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