diff --git a/APP_Framework/Applications/sensor_app/Makefile b/APP_Framework/Applications/sensor_app/Makefile index 15d1c9691..03bc3952a 100644 --- a/APP_Framework/Applications/sensor_app/Makefile +++ b/APP_Framework/Applications/sensor_app/Makefile @@ -22,10 +22,11 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), 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 diff --git a/APP_Framework/Framework/sensor/co2/Kconfig b/APP_Framework/Framework/sensor/co2/Kconfig index 8efcaa1f1..78a965e8d 100644 --- a/APP_Framework/Framework/sensor/co2/Kconfig +++ b/APP_Framework/Framework/sensor/co2/Kconfig @@ -102,29 +102,12 @@ config SENSOR_G8S if ADD_NUTTX_FETURES config SENSOR_DEVICE_G8S_DEV string "CO2 device name" - default "/dev/ttyS1" + default "/dev/ttyS3" ---help--- If USART1 is selected, then fill in /dev/ttyS1 here. endif if ADD_RTTHREAD_FETURES - config SENSOR_G8S_DRIVER_EXTUART - bool "Using extra uart to support g8-s" - default y - config SENSOR_DEVICE_G8S_DEV - string "g8-s device uart path" - default "/dev/uart2_dev2" - depends on !SENSOR_G8S_DRIVER_EXTUART - - if SENSOR_G8S_DRIVER_EXTUART - config SENSOR_DEVICE_G8S_DEV - string "g8-s device extra uart path" - default "/dev/extuart_dev4" - - config SENSOR_DEVICE_G8S_DEV_EXT_PORT - int "if G8S device using extuart, choose port" - default "4" - endif endif endif diff --git a/APP_Framework/Framework/sensor/co2/g8s/Make.defs b/APP_Framework/Framework/sensor/co2/g8s/Make.defs new file mode 100644 index 000000000..f14b14928 --- /dev/null +++ b/APP_Framework/Framework/sensor/co2/g8s/Make.defs @@ -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 diff --git a/APP_Framework/Framework/sensor/co2/g8s/g8s.c b/APP_Framework/Framework/sensor/co2/g8s/g8s.c index a5122a131..89c7583bc 100644 --- a/APP_Framework/Framework/sensor/co2/g8s/g8s.c +++ b/APP_Framework/Framework/sensor/co2/g8s/g8s.c @@ -47,15 +47,8 @@ static int SensorDeviceOpen(struct SensorDevice *sdev) printf("open %s error\n", SENSOR_DEVICE_G8S_DEV); return -1; } - - - result = sdev->done->ioctl(sdev, SENSOR_DEVICE_PASSIVE); - if (result != 0){ - printf("SensorDeviceOpen:ioctl failed, status=%d\n", result); - } - - return result; } + #else static int SensorDeviceOpen(struct SensorDevice *sdev) { @@ -97,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; @@ -161,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) {