feat(gas-logger): добавь непрерывный логгер и JSON-карту

This commit is contained in:
2026-10-01 22:54:29 +03:00
parent 675ce063f0
commit f7a6f767e1
22 changed files with 1250 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
#include "gas_logger_pm35.h"
#include "pm35_map.h"
static uint32_t enter(void *u) { gl_pm35_context *p=u; return p->enter(p->irq_user); }
static void leave(void *u,uint32_t state) { gl_pm35_context *p=u; p->leave(p->irq_user,state); }
static int source(void *u,uint16_t gas,uint16_t *v)
{
gl_pm35_context *p=u;
uint16_t i;
for(i=0;i<gl_pm35_config.channels;i++) if(gl_pm35_channels[i].gas==gas) {
*v=gl_pm35_source_space[i] ? p->pm67_voltage[gl_pm35_source_address[i]] :
p->modbus[gl_pm35_source_address[i]];
return 1;
}
return 0;
}
gl_result gl_pm35_init(gas_logger *l,gl_pm35_context *p,uint16_t *a,uint16_t *b,uint32_t n)
{
gl_port port;
if(!p || !p->modbus || !p->pm67_voltage || !p->enter || !p->leave) return GL_ARGUMENT;
port.user=p;port.enter=enter;port.leave=leave;port.source=source;
return gl_init(l,&gl_pm35_config,&port,a,b,n);
}

View File

@@ -0,0 +1,16 @@
#ifndef GAS_LOGGER_PM35_H
#define GAS_LOGGER_PM35_H
#include "gas_logger.h"
/* Project adapter: pm35_modbus uses the firmware's zero-based modbus[128].
* pm67_voltage[2] is the latest CAN cache, updated under the same IRQ lock.
* No direct CAN requests are performed while capturing. */
typedef struct {
volatile uint16_t *modbus;
volatile uint16_t *pm67_voltage;
uint32_t (*enter)(void *);
void (*leave)(void *,uint32_t);
void *irq_user;
} gl_pm35_context;
gl_result gl_pm35_init(gas_logger *log, gl_pm35_context *context,
uint16_t *bank0, uint16_t *bank1, uint32_t bank_words);
#endif

View File

@@ -0,0 +1,19 @@
/* Generated from pm35.json. Do not edit. */
#ifndef GL_PM35_MAP_H
#define GL_PM35_MAP_H
#include "gas_logger.h"
static const gl_channel gl_pm35_channels[] = {
{20480U, 20480U, 20480U}, /* commands */
{20481U, 20481U, 20481U}, /* current */
{20482U, 20482U, 20482U}, /* dac */
{20483U, 20483U, 20483U}, /* go */
{20484U, 20484U, 20484U}, /* stop */
{20485U, 20485U, 20485U}, /* zpt1 */
{20486U, 20486U, 20486U}, /* zpt2 */
};
static const uint16_t gl_pm35_source_space[] = { 0U, 0U, 0U, 0U, 0U, 1U, 1U };
static const uint16_t gl_pm35_source_address[] = { 127U, 28U, 123U, 80U, 81U, 0U, 1U };
static const gl_config gl_pm35_config = {
24576U, 7U, 760U, 0x635F84CBUL, gl_pm35_channels
};
#endif