forked from xuos/xiuos
This commit is contained in:
commit
4745f77708
|
@ -32,6 +32,7 @@ extern int Ps5308Pm1_0Init(void);
|
|||
extern int Ps5308Pm2_5Init(void);
|
||||
extern int Ps5308Pm10Init(void);
|
||||
extern int Zg09Co2Init(void);
|
||||
extern int G8sCo2Init(void);
|
||||
extern int As830Ch4Init(void);
|
||||
extern int Tb600bIaq10IaqInit(void);
|
||||
extern int Tb600bTvoc10TvocInit(void);
|
||||
|
@ -106,6 +107,10 @@ static struct InitDesc sensor_desc[] =
|
|||
{ "zg09_co2", Zg09Co2Init },
|
||||
#endif
|
||||
|
||||
#ifdef SENSOR_G8S
|
||||
{ "g8s_co2", G8sCo2Init },
|
||||
#endif
|
||||
|
||||
#ifdef SENSOR_QS_FX
|
||||
{ "qs_fx_wind_direction", QsFxWindDirectionInit },
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,11 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
|||
CSRCS += co2_zg09.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_G8S), y)
|
||||
CSRCS += co2_g8s.c
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
|
||||
CSRCS += pm1_0_ps5308.c
|
||||
endif
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
* @author AIIT XUOS Lab
|
||||
* @date 2021.12.23
|
||||
*/
|
||||
|
||||
//
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,6 +64,7 @@ config SENSOR_ZG09
|
|||
endif
|
||||
endif
|
||||
|
||||
|
||||
config SENSOR_G8S
|
||||
bool "Using g8-s"
|
||||
default n
|
||||
|
@ -99,7 +100,11 @@ config SENSOR_G8S
|
|||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
|
||||
config SENSOR_DEVICE_G8S_DEV
|
||||
string "CO2 device name"
|
||||
default "/dev/ttyS3"
|
||||
---help---
|
||||
If USART1 is selected, then fill in /dev/ttyS1 here.
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/co2/g8s/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SENSOR_G8S),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/co2/g8s
|
||||
endif
|
|
@ -1,3 +1,13 @@
|
|||
SRC_FILES := g8s.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += g8s.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := g8s.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ static struct SensorProductInfo info =
|
|||
* @param sdev - sensor device pointer
|
||||
* @return success: 1 , failure: other
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -46,6 +47,19 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
printf("open %s error\n", SENSOR_DEVICE_G8S_DEV);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
sdev->fd = PrivOpen(SENSOR_DEVICE_G8S_DEV, O_RDWR);
|
||||
if (sdev->fd < 0) {
|
||||
printf("open %s error\n", SENSOR_DEVICE_G8S_DEV);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
struct SerialDataCfg cfg;
|
||||
cfg.serial_baud_rate = BAUD_RATE_9600;
|
||||
|
@ -67,7 +81,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @description: Read sensor device
|
||||
* @param sdev - sensor device pointer
|
||||
|
@ -76,10 +90,9 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
*/
|
||||
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
||||
{
|
||||
uint8_t tmp = 0;
|
||||
|
||||
PrivWrite(sdev->fd, g8s_read_instruction, sizeof(g8s_read_instruction));
|
||||
|
||||
PrivTaskDelay(500);
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -140,16 +153,26 @@ static int32_t QuantityRead(struct SensorQuantity *quant)
|
|||
result_ascii[i] = quant->sdev->buffer[i];
|
||||
}
|
||||
|
||||
if (8 == ascii_length) {
|
||||
for (i = 0; i < ascii_length; i ++) {
|
||||
result_hex[i] = result_ascii[i] - 0x30;
|
||||
result += result_hex[i] * pow(10, ascii_length - 1 - i);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
if (ascii_length == 0){
|
||||
|
||||
printf("This reading is wrong\n");
|
||||
|
||||
result = SENSOR_QUANTITY_VALUE_ERROR;
|
||||
|
||||
return result;
|
||||
|
||||
}else{
|
||||
|
||||
for (i = 0; i < ascii_length; i ++) {
|
||||
|
||||
result_hex[i] = result_ascii[i] - 0x30;
|
||||
|
||||
result += result_hex[i] * pow(10, ascii_length - 1 - i);
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
if (quant->sdev->status == SENSOR_DEVICE_ACTIVE) {
|
||||
|
|
|
@ -571,6 +571,10 @@ config NSH_DISABLE_CO2ZG09
|
|||
bool "Disable the sensor zg09."
|
||||
default n
|
||||
|
||||
config NSH_DISABLE_CO2G8S
|
||||
bool "Disable the sensor g8-s."
|
||||
default n
|
||||
|
||||
config NSH_DISABLE_PM1_0PS5308
|
||||
bool "Disable the pm1.0 function of the sensor ps5308."
|
||||
default n
|
||||
|
|
|
@ -1478,6 +1478,10 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb,
|
|||
int cmd_Co2Zg09(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_APPLICATION_SENSOR_CO2_G8S) && !defined(CONFIG_NSH_DISABLE_CO2G8S)
|
||||
int cmd_Co2G8S(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308) && !defined(CONFIG_NSH_DISABLE_PM1_0PS5308)
|
||||
int cmd_Pm10Ps5308(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
|
|
@ -138,6 +138,21 @@ int cmd_Co2Zg09(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_Co2g8s
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_APPLICATION_SENSOR_CO2_G8S) && !defined(CONFIG_NSH_DISABLE_CO2G8S)
|
||||
extern void Co2G8s(void);
|
||||
int cmd_Co2G8S(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, world!\n");
|
||||
FrameworkInit();
|
||||
Co2G8s();
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_Pm10Ps5308
|
||||
****************************************************************************/
|
||||
|
|
|
@ -624,6 +624,10 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||
{ "zg09", cmd_Co2Zg09, 1, 1, "[get the concentration of co2 with sensor ZG09.]" },
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_APPLICATION_SENSOR_CO2_G8S) && !defined(CONFIG_NSH_DISABLE_CO2G8S)
|
||||
{ "g8s", cmd_Co2G8S, 1, 1, "[get the concentration of co2 with sensor G8S.]" },
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308) && !defined(CONFIG_NSH_DISABLE_PM1_0PS5308)
|
||||
{ "pm1.0", cmd_Pm10Ps5308, 1, 1, "[get pm1.0 with sensor Ps5308.]" },
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue