lark1s_demo/lark1s/lark1s.h

84 lines
2.5 KiB
C

#ifndef __LARK1S_H__
#define __LARK1S_H__
#include "stdint.h"
#define LARK1S_PARSE_OK (0)
#define LARK1S_PARSE_MB_ADDR_NOT_MATCH (1)
#define LARK1S_PARSE_FUNCTION_CODE_ERROR (2)
#define LARK1S_PARSE_FRAME_ERROR (3)
#define LARK1S_PARSE_CRC_ERROR (4)
#define LARK1S_PARSE_DATA_LENGTH_ERROR (5)
#define LARK1S_PARSE_CALI_REG_ERROR (6)
#define LARK1S_CALI_ZERO (0xFFFE)
#define LARK1S_CALI_SPAN (0xFFFD)
#define LARK1S_CALI_ZERO_SPAN (0xFFFC)
struct lark1s_gas_info_s {
uint32_t gas_id;
uint8_t gas_name[12];
uint32_t unit_id;
uint8_t unit_name[8];
uint32_t range;
uint32_t min_cali;
};
struct lark1s_gas_cali_data_s {
uint32_t available;
uint32_t zero_sig_cts;
uint32_t zero_ref_cts;
uint32_t zero_det_temp;
uint32_t zero_lamp_temp;
uint32_t span_concentration;
uint32_t span_sig_cts;
uint32_t span_ref_cts;
uint32_t span_det_temp;
uint32_t span_lamp_temp;
};
struct lark1s_data_s {
uint32_t det_temp;
uint32_t air_pressure;
uint32_t gas3_reading;
uint32_t cts_ref;
uint32_t cts_gas3;
int32_t gas3_compensated_reading;
};
struct lark1s_status_s {
uint16_t zero_record[4];
uint16_t span_record[4];
uint16_t active;
uint16_t restore;
};
#ifdef __cplusplus
extern "C" {
#endif
void lark1s_set_mb_address(uint8_t address);
uint16_t lark1s_get_mb_errno(void);
int lark1s_req_sn(uint8_t *buffer);
int lark1s_parse_sn(uint8_t *buffer, int length, char *sn);
int lark1s_req_gas3_info(uint8_t *buffer);
int lark1s_parse_gas3_info(uint8_t *buffer, int length, struct lark1s_gas_info_s *info);
int lark1s_req_data(uint8_t *buffer);
int lark1s_parse_data(uint8_t *buffer, int length, struct lark1s_data_s *data);
int lark1s_req_gas3_cali_zero_record(uint8_t *buffer, uint16_t type);
int lark1s_parse_gas3_cali_zero_record(uint8_t *buffer, int length);
int lark1s_req_gas3_cali_span_record(uint8_t *buffer, uint32_t concentration);
int lark1s_parse_gas3_cali_span_record(uint8_t *buffer, int length);
int lark1s_req_gas3_cali_active(uint8_t *buffer, uint16_t type);
int lark1s_parse_gas3_cali_active(uint8_t *buffer, int length);
int lark1s_req_gas3_cali_restore(uint8_t *buffer);
int lark1s_parse_gas3_cali_restore(uint8_t *buffer, int length);
int lark1s_req_status(uint8_t *buffer);
int lark1s_parse_status(uint8_t *buffer, int length, struct lark1s_status_s *status);
#ifdef __cplusplus
}
#endif
#endif /* __LARK1S_H__ */