1. add sensor as830 of ch4; 2、repair a bug of requiring password in letter shell

it is OK
This commit is contained in:
xuedongliang 2021-12-16 17:40:29 +08:00
commit cb8c68659c
29 changed files with 1419 additions and 2 deletions

View File

@ -29,6 +29,10 @@ extern int Hs300xTemperatureInit(void);
extern int Hs300xHumidityInit(void);
extern int Ps5308Pm1_0Init(void);
extern int Zg09Co2Init(void);
extern int As830Ch4Init(void);
extern int Tb600bIaq10IaqInit(void);
extern int Tb600bTvoc10TvocInit(void);
extern int Tb600bWqHcho1osInit(void);
typedef int (*InitFunc)(void);
struct InitDesc
@ -89,6 +93,22 @@ static struct InitDesc sensor_desc[] =
{ "zg09_co2", Zg09Co2Init },
#endif
#ifdef SENSOR_AS830
{ "ch4_as830", As830Ch4Init },
#endif
#ifdef SENSOR_TB600B_IAQ10
{ "iaq_tb600b_iaq10", Tb600bIaq10IaqInit },
#endif
#ifdef SENSOR_TB600B_TVOC10
{ "tvoc_tb600b_tvoc10", Tb600bTvoc10TvocInit },
#endif
#ifdef SENSOR_TB600B_WQ_HCHO1OS
{ "tvoc_tb600b_wq_hcho1os", Tb600bWqHcho1osInit },
#endif
{ "NULL", NULL },
};

View File

@ -19,7 +19,7 @@ extern int FrameworkInit();
extern void ApplicationOtaTaskInit(void);
int main(void)
{
printf("Hello, world!\n");
printf("Hello, world! \n");
FrameworkInit();
#ifdef APPLICATION_OTA
ApplicationOtaTaskInit();

View File

@ -5,6 +5,46 @@ menu "sensor app"
default n
if APPLICATION_SENSOR
menuconfig APPLICATION_SENSOR_HCHO
bool "Using sensor HCHO apps"
default n
if APPLICATION_SENSOR_HCHO
config APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS
bool "Using sensor TB600B_WQ_HCHO1OS apps"
default n
endif
menuconfig APPLICATION_SENSOR_TVOC
bool "Using sensor TVOC apps"
default n
if APPLICATION_SENSOR_TVOC
config APPLICATION_SENSOR_TVOC_TB600B_TVOC10
bool "Using sensor TB600B_TVOC10 apps"
default n
endif
menuconfig APPLICATION_SENSOR_IAQ
bool "Using sensor IAQ apps"
default n
if APPLICATION_SENSOR_IAQ
config APPLICATION_SENSOR_IAQ_TB600B_IAQ10
bool "Using sensor TB600B_IAQ10 apps"
default n
endif
menuconfig APPLICATION_SENSOR_CH4
bool "Using sensor CH4 apps"
default n
if APPLICATION_SENSOR_CH4
config APPLICATION_SENSOR_CH4_AS830
bool "Using sensor AS830 apps"
default n
endif
menuconfig APPLICATION_SENSOR_CO2
bool "Using sensor CO2 apps"
default n

View File

@ -1,5 +1,21 @@
SRC_FILES :=
ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y)
SRC_FILES += hcho_tb600b_wq_hcho1os.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10), y)
SRC_FILES += tvoc_tb600b_tvoc10.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y)
SRC_FILES += iaq_tb600b_iaq10.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y)
SRC_FILES += ch4_as830.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y)
SRC_FILES += co2_zg09.c
endif

View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file ch4_as830.c
* @brief CH4 AS830 example
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.12.10
*/
#include <user_api.h>
#include <sensor.h>
/**
* @description: Read a ch4
* @return 0
*/
void Ch4As830(void)
{
struct SensorQuantity *ch4 = SensorQuantityFind(SENSOR_QUANTITY_AS830_CH4, SENSOR_QUANTITY_CH4);
SensorQuantityOpen(ch4);
printf("CH4 : %d %%LTL\n", SensorQuantityRead(ch4));
SensorQuantityClose(ch4);
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file hcho_tb600b_wq_hcho1os.c
* @brief hcho example
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.12.15
*/
#include <user_api.h>
#include <sensor.h>
/**
* @description: Read a hcho
* @return 0
*/
void HchoTb600bHcho1os(void)
{
struct SensorQuantity *hcho = SensorQuantityFind(SENSOR_QUANTITY_TB600B_HCHO, SENSOR_QUANTITY_HCHO);
SensorQuantityOpen(hcho);
int32_t result = 0;
result = SensorQuantityRead(hcho);
printf("tvoc concentration is : %dppb\n", result);
SensorQuantityClose(hcho);
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file iaq_tb600b_iaq10.c
* @brief iaq10 example
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.12.14
*/
#include <user_api.h>
#include <sensor.h>
// struct iaq_data {
// uint16_t gas;
// uint8_t TH;
// uint8_t TL;
// uint8_t RhH;
// uint8_t RhL;
// };
/**
* @description: Read a iaq
* @return 0
*/
void IaqTb600bIaq10(void)
{
struct SensorQuantity *iaq = SensorQuantityFind(SENSOR_QUANTITY_TB600B_IAQ, SENSOR_QUANTITY_IAQ);
SensorQuantityOpen(iaq);
int32_t result = 0;
result = SensorQuantityRead(iaq);
printf("Gas concentration is : %dppb\n", result);
SensorQuantityClose(iaq);
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file tvoc_tb600b_tvoc10.c
* @brief tvoc10 example
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.12.15
*/
#include <user_api.h>
#include <sensor.h>
/**
* @description: Read a tvoc
* @return 0
*/
void TvocTb600bTvoc10(void)
{
struct SensorQuantity *tvoc = SensorQuantityFind(SENSOR_QUANTITY_TB600B_TVOC, SENSOR_QUANTITY_TVOC);
SensorQuantityOpen(tvoc);
int32_t result = 0;
result = SensorQuantityRead(tvoc);
printf("tvoc concentration is : %dppb\n", result);
SensorQuantityClose(tvoc);
}

View File

@ -4,6 +4,34 @@ menuconfig SUPPORT_SENSOR_FRAMEWORK
select TRANSFORM_LAYER_ATTRIUBUTE
if SUPPORT_SENSOR_FRAMEWORK
menuconfig SENSOR_HCHO
bool "Using HCHO sensor device"
default n
if SENSOR_HCHO
source "$APP_DIR/Framework/sensor/hcho/Kconfig"
endif
menuconfig SENSOR_TVOC
bool "Using TVOC sensor device"
default n
if SENSOR_TVOC
source "$APP_DIR/Framework/sensor/tvoc/Kconfig"
endif
menuconfig SENSOR_IAQ
bool "Using IAQ sensor device"
default n
if SENSOR_IAQ
source "$APP_DIR/Framework/sensor/iaq/Kconfig"
endif
menuconfig SENSOR_CH4
bool "Using Ch4 sensor device"
default n
if SENSOR_CH4
source "$APP_DIR/Framework/sensor/ch4/Kconfig"
endif
menuconfig SENSOR_CO2
bool "Using CO2 sensor device"
default n

View File

@ -1,5 +1,21 @@
SRC_FILES := sensor.c
ifeq ($(CONFIG_SENSOR_HCHO),y)
SRC_DIR += hcho
endif
ifeq ($(CONFIG_SENSOR_TVOC),y)
SRC_DIR += tvoc
endif
ifeq ($(CONFIG_SENSOR_IAQ),y)
SRC_DIR += iaq
endif
ifeq ($(CONFIG_SENSOR_CH4),y)
SRC_DIR += ch4
endif
ifeq ($(CONFIG_SENSOR_CO2),y)
SRC_DIR += co2
endif

View File

@ -0,0 +1,43 @@
config SENSOR_AS830
bool "Using as830"
default n
if SENSOR_AS830
config SENSOR_DEVICE_AS830
string "as830 sensor name"
default "as830_1"
config SENSOR_QUANTITY_AS830_CH4
string "as830 quantity name"
default "ch4_1"
if ADD_XIUOS_FETURES
config SENSOR_AS830_DRIVER_EXTUART
bool "Using extra uart to support as830"
default y
config SENSOR_DEVICE_AS830_DEV
string "as830 device uart path"
default "/dev/uart2_dev2"
depends on !SENSOR_AS830_DRIVER_EXTUART
if SENSOR_AS830_DRIVER_EXTUART
config SENSOR_DEVICE_AS830_DEV
string "as830 device extra uart path"
default "/dev/extuart_dev1"
config SENSOR_DEVICE_AS830_DEV_EXT_PORT
int "if AS830 device using extuart, choose port"
default "1"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

View File

@ -0,0 +1,5 @@
ifeq ($(CONFIG_SENSOR_AS830),y)
SRC_DIR += as830
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
SRC_FILES := as830.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,225 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file as830.c
* @brief AS830 CH4 driver base sensor
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.12.10
*/
#include <sensor.h>
static struct SensorDevice as830;
static struct SensorProductInfo info =
{
SENSOR_ABILITY_CH4,
"xxxxx",
"AS830",
};
/**
* @description: Open AS830 sensor device
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
sdev->fd = PrivOpen(SENSOR_DEVICE_AS830_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_AS830_DEV);
return -1;
}
struct SerialDataCfg cfg;
cfg.serial_baud_rate = BAUD_RATE_9600;
cfg.serial_data_bits = DATA_BITS_8;
cfg.serial_stop_bits = STOP_BITS_1;
cfg.serial_buffer_size = 128;
cfg.serial_parity_mode = PARITY_NONE;
cfg.serial_bit_order = 0;
cfg.serial_invert_mode = 0;
#ifdef SENSOR_AS830_DRIVER_EXTUART
cfg.ext_uart_no = SENSOR_DEVICE_AS830_DEV_EXT_PORT;
cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &cfg;
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
return result;
}
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
* @param len - the length of the read data
* @return get data length
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
uint8_t tmp = 0;
uint8_t idx = 0;
while (1) {
if (PrivRead(sdev->fd, &tmp, 1) == 1) {
sdev->buffer[idx++] = tmp;
}
if(0xA == tmp){
break;
}
}
return idx;
}
static struct SensorDone done =
{
SensorDeviceOpen,
NULL,
SensorDeviceRead,
NULL,
NULL,
};
/**
* @description: Init AS830 sensor and register
* @return void
*/
static void SensorDeviceAs830Init(void)
{
as830.name = SENSOR_DEVICE_AS830;
as830.info = &info;
as830.done = &done;
SensorDeviceRegister(&as830);
}
/* check data*/
static uint8_t CH4_check(uint8_t *packet)
{
uint8_t i, high, low;
uint8_t checksum = 0;
for( i = 0; i < 10; i++)
{
if(packet[i] == 0x09)
break;
checksum += packet[i];
}
checksum = (unsigned char)(-(signed char)checksum);
high = (checksum & 0xF0) >> 4;
if((high <= 0x0F) && (high >= 0x0A))
high += 0x37;
else if((high <= 0x09) && (high >= 0x00))
high += 0x30;
low = (checksum & 0x0F);
if((low <= 0x0F) && (low >= 0x0A))
low += 0x37;
else if((low <= 0x09) && (low >= 0x00))
low += 0x30;
if((high == packet[i + 1]) && (low == packet[i + 2]))
return 0;
return -1;
}
static struct SensorQuantity as830_ch4;
/**
* @description: Analysis AS830 CH4 result
* @param quant - sensor quantity pointer
* @return quantity value
*/
static int32_t QuantityRead(struct SensorQuantity *quant)
{
if (!quant)
return -1;
uint32_t result;
uint32_t len = 0;
if (quant->sdev->done->read != NULL) {
if(quant->sdev->status == SENSOR_DEVICE_PASSIVE) {
len = quant->sdev->done->read(quant->sdev, 7);
if (len == 0)
{
printf("error read data length = 0.\n");
return -1;
}
if(CH4_check(quant->sdev->buffer) == 0)
{
for(int i = 0; i < len; i++)
{
if(quant->sdev->buffer[i] == 0x09)
{
break;
}
result = result *10 + (quant->sdev->buffer[i] - 0x30);
}
if (result > quant->value.max_value)
quant->value.max_value = result;
else if (result < quant->value.min_value)
quant->value.min_value = result;
quant->value.last_value = result;
return result;
}
else
{
printf("This reading is wrong\n");
result = SENSOR_QUANTITY_VALUE_ERROR;
return result;
}
}
if (quant->sdev->status == SENSOR_DEVICE_ACTIVE)
{
printf("Please set passive mode.\n");
}
}else{
printf("%s don't have read done.\n", quant->name);
}
return -1;
}
/**
* @description: Init AS830 CH4 quantity and register
* @return 0
*/
int As830Ch4Init(void)
{
SensorDeviceAs830Init();
as830_ch4.name = SENSOR_QUANTITY_AS830_CH4;
as830_ch4.type = SENSOR_QUANTITY_CH4;
as830_ch4.value.decimal_places = 0;
as830_ch4.value.max_std = 1000;
as830_ch4.value.min_std = 350;
as830_ch4.value.last_value = SENSOR_QUANTITY_VALUE_ERROR;
as830_ch4.value.max_value = SENSOR_QUANTITY_VALUE_ERROR;
as830_ch4.value.min_value = SENSOR_QUANTITY_VALUE_ERROR;
as830_ch4.sdev = &as830;
as830_ch4.ReadValue = QuantityRead;
SensorQuantityRegister(&as830_ch4);
return 0;
}

View File

@ -0,0 +1,43 @@
config SENSOR_TB600B_WQ_HCHO1OS
bool "Using TB600B WQ_HCHO1OS"
default n
if SENSOR_TB600B_WQ_HCHO1OS
config SENSOR_DEVICE_TB600B_WQ_HCHO1OS
string "tb600b wq_hcho1os sensor name"
default "tb600b_wq_hcho1os_1"
config SENSOR_QUANTITY_TB600B_HCHO
string "tb600b wq_hcho1os quantity name"
default "hcho_1"
if ADD_XIUOS_FETURES
config SENSOR_TB600B_WQ_HCHO1OS_DRIVER_EXTUART
bool "Using extra uart to support tb600b wq_hcho1os"
default y
config SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV
string "tb600b wq_hcho1os device uart path"
default "/dev/uart2_dev2"
depends on !SENSOR_TB600B_WQ_HCHO1OS_DRIVER_EXTUART
if SENSOR_TB600B_WQ_HCHO1OS_DRIVER_EXTUART
config SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV
string "tb600b wq_hcho1os device extra uart path"
default "/dev/extuart_dev5"
config SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV_EXT_PORT
int "if TB600B_WQ_HCHO1OS device using extuart, choose port"
default "5"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

View File

@ -0,0 +1,5 @@
ifeq ($(CONFIG_SENSOR_TB600B_WQ_HCHO1OS),y)
SRC_DIR += tb600b_wq_hcho1os
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
SRC_FILES := tb600b_wq_hcho1os.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,222 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file wq_hcho1os.c
* @brief wq_hcho1os driver base sensor
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.12.15
*/
#include <sensor.h>
static struct SensorDevice wq_hcho1os;
static uint8_t ReadInstruction[9];
static struct SensorProductInfo info =
{
SENSOR_ABILITY_HCHO,
"AQS",
"TB600B_WQ_HCHO1OS",
};
/**
* @description: Open TB600B WQ_HCHO1OS sensor device
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
sdev->fd = PrivOpen(SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV);
return -1;
}
struct SerialDataCfg cfg;
cfg.serial_baud_rate = BAUD_RATE_9600;
cfg.serial_data_bits = DATA_BITS_8;
cfg.serial_stop_bits = STOP_BITS_1;
cfg.serial_buffer_size = 128;
cfg.serial_parity_mode = PARITY_NONE;
cfg.serial_bit_order = 0;
cfg.serial_invert_mode = 0;
#ifdef SENSOR_TB600B_WQ_HCHO1OS_DRIVER_EXTUART
cfg.ext_uart_no = SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV_EXT_PORT;
cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &cfg;
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
return result;
}
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
* @param len - the length of the read data
* @return get data length
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
uint8_t tmp = 0;
uint8_t idx = 0;
/* this instruction will read gas with temperature and humidity,return 9 datas*/
ReadInstruction[0] = 0xFF;
ReadInstruction[1] = 0x01;
ReadInstruction[2] = 0x86;
ReadInstruction[3] = 0x00;
ReadInstruction[4] = 0x00;
ReadInstruction[5] = 0x00;
ReadInstruction[6] = 0x00;
ReadInstruction[7] = 0x00;
ReadInstruction[8] = 0x79;
PrivWrite(sdev->fd, ReadInstruction, 9);
for(idx = 0; idx < 9; idx++)
{
if (PrivRead(sdev->fd, &tmp, 1) == 1) {
sdev->buffer[idx] = tmp;
}
}
return idx;
}
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
* @param len - the length of the read data
* @return get data length
*/
static int SensorDeviceWrite(struct SensorDevice *sdev, const void *buf, size_t len)
{
return PrivWrite(sdev->fd, buf, len);
}
static struct SensorDone done =
{
SensorDeviceOpen,
NULL,
SensorDeviceRead,
SensorDeviceWrite,
NULL,
};
/**
* @description: Init TB600B WQ_HCHO1OS sensor and register
* @return void
*/
static void SensorDeviceTb600bHcho1osInit(void)
{
wq_hcho1os.name = SENSOR_DEVICE_TB600B_WQ_HCHO1OS;
wq_hcho1os.info = &info;
wq_hcho1os.done = &done;
SensorDeviceRegister(&wq_hcho1os);
}
static struct SensorQuantity wq_hcho1os_hcho;
/* check data*/
static uint8_t getCheckSum(uint8_t *packet)
{
uint8_t i;
uint8_t checksum = 0;
for( i = 1; i < 12; i++)
{
checksum += packet[i];
}
checksum = ~checksum + 1;
return checksum;
}
/**
* @description: Analysis TB600B WQ_HCHO1OS result
* @param quant - sensor quantity pointer
* @return quantity value
*/
static int32_t QuantityRead(struct SensorQuantity *quant)
{
if (!quant)
return -1;
uint32_t len = 0;
uint8_t checksum = 0;
uint16_t ppb, ugm3;
if (quant->sdev->done->read != NULL) {
if(quant->sdev->status == SENSOR_DEVICE_PASSIVE) {
len = quant->sdev->done->read(quant->sdev, 9);
if (len == 0)
{
printf("error read data length = 0.\n");
return -1;
}
checksum = getCheckSum(quant->sdev->buffer);
if(checksum == quant->sdev->buffer[8])
{
ugm3 = (uint16_t)quant->sdev->buffer[2] * 256 + (uint16_t)quant->sdev->buffer[3];
ppb = (uint16_t)quant->sdev->buffer[6] * 256 + (uint16_t)quant->sdev->buffer[7];
printf("Formaldehyde concentration is : %dug/m³(%dppb)\n", ugm3, ppb);
return ppb;
}
else
{
printf("This reading is wrong\n");
return SENSOR_QUANTITY_VALUE_ERROR;
}
}
if (quant->sdev->status == SENSOR_DEVICE_ACTIVE)
{
printf("Please set passive mode.\n");
}
}else{
printf("%s don't have read done.\n", quant->name);
}
return -1;
}
/**
* @description: Init TB600B WQ_HCHO1OS quantity and register
* @return 0
*/
int Tb600bWqHcho1osInit(void)
{
SensorDeviceTb600bHcho1osInit();
wq_hcho1os_hcho.name = SENSOR_QUANTITY_TB600B_HCHO;
wq_hcho1os_hcho.type = SENSOR_QUANTITY_HCHO;
wq_hcho1os_hcho.value.decimal_places = 0;
wq_hcho1os_hcho.value.max_std = SENSOR_QUANTITY_VALUE_ERROR;
wq_hcho1os_hcho.value.min_std = SENSOR_QUANTITY_VALUE_ERROR;
wq_hcho1os_hcho.value.last_value = SENSOR_QUANTITY_VALUE_ERROR;
wq_hcho1os_hcho.value.max_value = SENSOR_QUANTITY_VALUE_ERROR;
wq_hcho1os_hcho.value.min_value = SENSOR_QUANTITY_VALUE_ERROR;
wq_hcho1os_hcho.sdev = &wq_hcho1os;
wq_hcho1os_hcho.ReadValue = QuantityRead;
SensorQuantityRegister(&wq_hcho1os_hcho);
return 0;
}

View File

@ -0,0 +1,43 @@
config SENSOR_TB600B_IAQ10
bool "Using TB600B IAQ10"
default n
if SENSOR_TB600B_IAQ10
config SENSOR_DEVICE_TB600B_IAQ10
string "tb600b iaq10 sensor name"
default "tb600b_iaq10_1"
config SENSOR_QUANTITY_TB600B_IAQ
string "tb600b iaq10 quantity name"
default "iaq_1"
if ADD_XIUOS_FETURES
config SENSOR_TB600B_IAQ10_DRIVER_EXTUART
bool "Using extra uart to support tb600b iaq10"
default y
config SENSOR_DEVICE_TB600B_IAQ10_DEV
string "tb600b iaq10 device uart path"
default "/dev/uart2_dev2"
depends on !SENSOR_TB600B_IAQ10_DRIVER_EXTUART
if SENSOR_TB600B_IAQ10_DRIVER_EXTUART
config SENSOR_DEVICE_TB600B_IAQ10_DEV
string "tb600b iaq10 device extra uart path"
default "/dev/extuart_dev5"
config SENSOR_DEVICE_TB600B_IAQ10_DEV_EXT_PORT
int "if TB600B_IAQ10 device using extuart, choose port"
default "5"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

View File

@ -0,0 +1,5 @@
ifeq ($(CONFIG_SENSOR_TB600B_IAQ10),y)
SRC_DIR += tb600b_iaq10
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
SRC_FILES := tb600b_iaq10.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,235 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file tb600b_iaq10.c
* @brief tb600b_iaq10 driver base sensor
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.12.14
*/
#include <sensor.h>
static struct SensorDevice tb600b_iaq10;
static uint8_t ReadInstruction[9];
struct iaq_data {
uint16_t gas;
uint8_t TH;
uint8_t TL;
uint8_t RhH;
uint8_t RhL;
};
static struct SensorProductInfo info =
{
SENSOR_ABILITY_IAQ,
"AQS",
"TB600B_IAQ10",
};
/**
* @description: Open tb600b_iaq10 sensor device
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
sdev->fd = PrivOpen(SENSOR_DEVICE_TB600B_IAQ10_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_TB600B_IAQ10_DEV);
return -1;
}
struct SerialDataCfg cfg;
cfg.serial_baud_rate = BAUD_RATE_9600;
cfg.serial_data_bits = DATA_BITS_8;
cfg.serial_stop_bits = STOP_BITS_1;
cfg.serial_buffer_size = 128;
cfg.serial_parity_mode = PARITY_NONE;
cfg.serial_bit_order = 0;
cfg.serial_invert_mode = 0;
#ifdef SENSOR_TB600B_IAQ10_DRIVER_EXTUART
cfg.ext_uart_no = SENSOR_DEVICE_TB600B_IAQ10_DEV_EXT_PORT;
cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &cfg;
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
return result;
}
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
* @param len - the length of the read data
* @return get data length
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
uint8_t tmp = 0;
uint8_t idx = 0;
int32_t ret = 0;
/* this instruction will read gas with temperature and humidity,return 13 datas*/
ReadInstruction[0] = 0xFF;
ReadInstruction[1] = 0x01;
ReadInstruction[2] = 0x87;
ReadInstruction[3] = 0x00;
ReadInstruction[4] = 0x00;
ReadInstruction[5] = 0x00;
ReadInstruction[6] = 0x00;
ReadInstruction[7] = 0x00;
ReadInstruction[8] = 0x78;
PrivWrite(sdev->fd, ReadInstruction, 9);
for(idx = 0; idx < 13; idx++)
{
if (PrivRead(sdev->fd, &tmp, 1) == 1) {
sdev->buffer[idx] = tmp;
}
}
return idx;
}
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
* @param len - the length of the read data
* @return get data length
*/
static int SensorDeviceWrite(struct SensorDevice *sdev, const void *buf, size_t len)
{
return PrivWrite(sdev->fd, buf, len);
}
static struct SensorDone done =
{
SensorDeviceOpen,
NULL,
SensorDeviceRead,
SensorDeviceWrite,
NULL,
};
/**
* @description: Init tb600b_iaq10 sensor and register
* @return void
*/
static void SensorDeviceTb600bIaq10Init(void)
{
tb600b_iaq10.name = SENSOR_DEVICE_TB600B_IAQ10;
tb600b_iaq10.info = &info;
tb600b_iaq10.done = &done;
SensorDeviceRegister(&tb600b_iaq10);
}
static struct SensorQuantity tb600b_iaq10_iaq;
/* check data*/
static uint8_t getCheckSum(uint8_t *packet)
{
uint8_t i;
uint8_t checksum = 0;
for( i = 1; i < 12; i++)
{
checksum += packet[i];
}
checksum = ~checksum + 1;
return checksum;
}
/**
* @description: Analysis tb600b_iaq10 result
* @param quant - sensor quantity pointer
* @return quantity value
*/
static int32_t QuantityRead(struct SensorQuantity *quant)
{
if (!quant)
return -1;
uint32_t len = 0;
uint8_t checksum = 0;
uint8_t TH, TL, RhH, RhL;
uint16_t gas;
struct iaq_data result;
if (quant->sdev->done->read != NULL) {
if(quant->sdev->status == SENSOR_DEVICE_PASSIVE) {
len = quant->sdev->done->read(quant->sdev, 13);
if (len == 0)
{
printf("error read data length = 0.\n");
return -1;
}
checksum = getCheckSum(quant->sdev->buffer);
if(checksum == quant->sdev->buffer[12])
{
result.gas = (uint16_t)quant->sdev->buffer[6] * 256 + (uint16_t)quant->sdev->buffer[7];
result.TH = ((int)((quant->sdev->buffer[8] << 8)|quant->sdev->buffer[9]))/100;
result.TL = ((int)((quant->sdev->buffer[8] << 8)|quant->sdev->buffer[9]))%100;
result.RhH = ((unsigned int)((quant->sdev->buffer[10] << 8)|quant->sdev->buffer[11]))/100;
result.RhL = ((unsigned int)((quant->sdev->buffer[10] << 8)|quant->sdev->buffer[11]))%100;
printf("Gas concentration is : %dppb\nThe temperature is : %d.%d℃\nThe humidity is : %d.%drh%%\n", result.gas, result.TH, result.TL, result.RhH, result.RhL);
return result.gas;
}
else
{
printf("This reading is wrong\n");
return SENSOR_QUANTITY_VALUE_ERROR;
}
}
if (quant->sdev->status == SENSOR_DEVICE_ACTIVE)
{
printf("Please set passive mode.\n");
}
}else{
printf("%s don't have read done.\n", quant->name);
}
return -1;
}
/**
* @description: Init tb600b_iaq10 quantity and register
* @return 0
*/
int Tb600bIaq10IaqInit(void)
{
SensorDeviceTb600bIaq10Init();
tb600b_iaq10_iaq.name = SENSOR_QUANTITY_TB600B_IAQ;
tb600b_iaq10_iaq.type = SENSOR_QUANTITY_IAQ;
tb600b_iaq10_iaq.value.decimal_places = 0;
tb600b_iaq10_iaq.value.max_std = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_iaq10_iaq.value.min_std = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_iaq10_iaq.value.last_value = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_iaq10_iaq.value.max_value = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_iaq10_iaq.value.min_value = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_iaq10_iaq.sdev = &tb600b_iaq10;
tb600b_iaq10_iaq.ReadValue = QuantityRead;
SensorQuantityRegister(&tb600b_iaq10_iaq);
return 0;
}

View File

@ -51,6 +51,10 @@ extern "C" {
#define SENSOR_ABILITY_CO ((uint32_t)(1 << SENSOR_QUANTITY_CO))
#define SENSOR_ABILITY_PM ((uint32_t)(1 << SENSOR_QUANTITY_PM))
#define SENSOR_ABILITY_VOICE ((uint32_t)(1 << SENSOR_QUANTITY_VOICE))
#define SENSOR_ABILITY_CH4 ((uint32_t)(1 << SENSOR_QUANTITY_CH4))
#define SENSOR_ABILITY_IAQ ((uint32_t)(1 << SENSOR_QUANTITY_IAQ))
#define SENSOR_ABILITY_TVOC ((uint32_t)(1 << SENSOR_QUANTITY_TVOC))
#define SENSOR_ABILITY_HCHO ((uint32_t)(1 << SENSOR_QUANTITY_HCHO))
struct SensorProductInfo {
uint32_t ability; /* Bitwise OR of sensor ability */
@ -89,6 +93,9 @@ enum SensorQuantityType {
SENSOR_QUANTITY_CO,
SENSOR_QUANTITY_PM,
SENSOR_QUANTITY_VOICE,
SENSOR_QUANTITY_CH4,
SENSOR_QUANTITY_IAQ,
SENSOR_QUANTITY_TVOC,
/* ...... */
SENSOR_QUANTITY_END,
};

View File

@ -0,0 +1,43 @@
config SENSOR_TB600B_TVOC10
bool "Using TB600B TVOC10"
default n
if SENSOR_TB600B_TVOC10
config SENSOR_DEVICE_TB600B_TVOC10
string "tb600b tvoc10 sensor name"
default "tb600b_tvoc10_1"
config SENSOR_QUANTITY_TB600B_TVOC
string "tb600b tvoc10 quantity name"
default "tvoc_1"
if ADD_XIUOS_FETURES
config SENSOR_TB600B_TVOC10_DRIVER_EXTUART
bool "Using extra uart to support tb600b tvoc10"
default y
config SENSOR_DEVICE_TB600B_TVOC10_DEV
string "tb600b tvoc10 device uart path"
default "/dev/uart2_dev2"
depends on !SENSOR_TB600B_TVOC10_DRIVER_EXTUART
if SENSOR_TB600B_TVOC10_DRIVER_EXTUART
config SENSOR_DEVICE_TB600B_TVOC10_DEV
string "tb600b tvoc10 device extra uart path"
default "/dev/extuart_dev6"
config SENSOR_DEVICE_TB600B_TVOC10_DEV_EXT_PORT
int "if TB600B_TVOC10 device using extuart, choose port"
default "6"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

View File

@ -0,0 +1,5 @@
ifeq ($(CONFIG_SENSOR_TB600B_TVOC10),y)
SRC_DIR += tb600b_tvoc10
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
SRC_FILES := tb600b_tvoc10.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,227 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file tb600b_tvoc10.c
* @brief tb600b_tvoc10 driver base sensor
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.12.15
*/
#include <sensor.h>
static struct SensorDevice tb600b_tvoc10;
static uint8_t ReadInstruction[9];
static struct SensorProductInfo info =
{
SENSOR_ABILITY_TVOC,
"AQS",
"TB600B_TVOC10",
};
/**
* @description: Open TB600B TVOC10 sensor device
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
sdev->fd = PrivOpen(SENSOR_DEVICE_TB600B_TVOC10_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_TB600B_TVOC10_DEV);
return -1;
}
struct SerialDataCfg cfg;
cfg.serial_baud_rate = BAUD_RATE_9600;
cfg.serial_data_bits = DATA_BITS_8;
cfg.serial_stop_bits = STOP_BITS_1;
cfg.serial_buffer_size = 128;
cfg.serial_parity_mode = PARITY_NONE;
cfg.serial_bit_order = 0;
cfg.serial_invert_mode = 0;
#ifdef SENSOR_TB600B_TVOC10_DRIVER_EXTUART
cfg.ext_uart_no = SENSOR_DEVICE_TB600B_TVOC10_DEV_EXT_PORT;
cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &cfg;
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
return result;
}
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
* @param len - the length of the read data
* @return get data length
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
uint8_t tmp = 0;
uint8_t idx = 0;
/* this instruction will read gas with temperature and humidity,return 13 datas*/
ReadInstruction[0] = 0xFF;
ReadInstruction[1] = 0x01;
ReadInstruction[2] = 0x87;
ReadInstruction[3] = 0x00;
ReadInstruction[4] = 0x00;
ReadInstruction[5] = 0x00;
ReadInstruction[6] = 0x00;
ReadInstruction[7] = 0x00;
ReadInstruction[8] = 0x78;
PrivWrite(sdev->fd, ReadInstruction, 9);
for(idx = 0; idx < 13; idx++)
{
if (PrivRead(sdev->fd, &tmp, 1) == 1) {
sdev->buffer[idx] = tmp;
}
}
return idx;
}
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
* @param len - the length of the read data
* @return get data length
*/
static int SensorDeviceWrite(struct SensorDevice *sdev, const void *buf, size_t len)
{
return PrivWrite(sdev->fd, buf, len);
}
static struct SensorDone done =
{
SensorDeviceOpen,
NULL,
SensorDeviceRead,
SensorDeviceWrite,
NULL,
};
/**
* @description: Init TB600B TVOC10 sensor and register
* @return void
*/
static void SensorDeviceTb600bTvoc10Init(void)
{
tb600b_tvoc10.name = SENSOR_DEVICE_TB600B_TVOC10;
tb600b_tvoc10.info = &info;
tb600b_tvoc10.done = &done;
SensorDeviceRegister(&tb600b_tvoc10);
}
static struct SensorQuantity tb600b_tvoc10_tvoc;
/* check data*/
static uint8_t getCheckSum(uint8_t *packet)
{
uint8_t i;
uint8_t checksum = 0;
for( i = 1; i < 12; i++)
{
checksum += packet[i];
}
checksum = ~checksum + 1;
return checksum;
}
/**
* @description: Analysis TB600B TVOC10 result
* @param quant - sensor quantity pointer
* @return quantity value
*/
static int32_t QuantityRead(struct SensorQuantity *quant)
{
if (!quant)
return -1;
uint32_t len = 0;
uint8_t checksum = 0;
uint8_t TH, TL, RhH, RhL;
uint16_t ppb, ugm3;
if (quant->sdev->done->read != NULL) {
if(quant->sdev->status == SENSOR_DEVICE_PASSIVE) {
len = quant->sdev->done->read(quant->sdev, 13);
if (len == 0)
{
printf("error read data length = 0.\n");
return -1;
}
checksum = getCheckSum(quant->sdev->buffer);
if(checksum == quant->sdev->buffer[12])
{
ugm3 = (uint16_t)quant->sdev->buffer[2] * 256 + (uint16_t)quant->sdev->buffer[3];
ppb = (uint16_t)quant->sdev->buffer[6] * 256 + (uint16_t)quant->sdev->buffer[7];
TH = ((int)((quant->sdev->buffer[8] << 8)|quant->sdev->buffer[9]))/100;
TL = ((int)((quant->sdev->buffer[8] << 8)|quant->sdev->buffer[9]))%100;
RhH = ((unsigned int)((quant->sdev->buffer[10] << 8)|quant->sdev->buffer[11]))/100;
RhL = ((unsigned int)((quant->sdev->buffer[10] << 8)|quant->sdev->buffer[11]))%100;
printf("tvoc concentration is : %dug/m³(%dppb)\nThe temperature is : %d.%d℃\nThe humidity is : %d.%drh%%\n", ugm3, ppb, TH, TL, RhH, RhL);
return ppb;
}
else
{
printf("This reading is wrong\n");
return SENSOR_QUANTITY_VALUE_ERROR;
}
}
if (quant->sdev->status == SENSOR_DEVICE_ACTIVE)
{
printf("Please set passive mode.\n");
}
}else{
printf("%s don't have read done.\n", quant->name);
}
return -1;
}
/**
* @description: Init TB600B TVOC10 quantity and register
* @return 0
*/
int Tb600bTvoc10TvocInit(void)
{
SensorDeviceTb600bTvoc10Init();
tb600b_tvoc10_tvoc.name = SENSOR_QUANTITY_TB600B_TVOC;
tb600b_tvoc10_tvoc.type = SENSOR_QUANTITY_TVOC;
tb600b_tvoc10_tvoc.value.decimal_places = 0;
tb600b_tvoc10_tvoc.value.max_std = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_tvoc10_tvoc.value.min_std = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_tvoc10_tvoc.value.last_value = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_tvoc10_tvoc.value.max_value = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_tvoc10_tvoc.value.min_value = SENSOR_QUANTITY_VALUE_ERROR;
tb600b_tvoc10_tvoc.sdev = &tb600b_tvoc10;
tb600b_tvoc10_tvoc.ReadValue = QuantityRead;
SensorQuantityRegister(&tb600b_tvoc10_tvoc);
return 0;
}

View File

@ -30,6 +30,23 @@ extern void timer_initialize(void);
extern void gapuino_sysinit(void);
extern unsigned int __bss_end__;
/* Return core id. */
uint32_t _procid( void )
{
uint32_t ulProcid = 0;
__asm__ volatile( "csrr %0, mhartid" : "=r"( ulProcid ) );
ulProcid = ulProcid & 0xf;
return ( ulProcid );
}
/* Return cluster id. */
uint32_t _clusterid( void )
{
uint32_t ulCluster = 0;
__asm__ volatile( "csrr %0, mhartid" : "=r"( ulCluster ) );
ulCluster = ulCluster >> 5;
return ( ulCluster );
}
void GapuinoStart(uint32_t mhartid)
{
@ -51,6 +68,7 @@ void InitBoardHardware(void)
timer_initialize();
KPrintf("memory address range: [0x%08x - 0x%08x], size: %d\n", (x_ubase) MEMORY_START_ADDRESS, (x_ubase) MEMORY_END_ADDRESS, GAP8_SRAM_SIZE);
/* initialize memory system */
KPrintf("gap8 cluster id: [0x%x], _procid: [0x%x]\n", _clusterid(),_procid());
KPrintf("board init done.\n");
KPrintf("start kernel...\n");

View File

@ -155,6 +155,7 @@ ShellCommand* shellSeekCommand(Shell *shell,
*/
void shellInit(Shell *shell, char *buffer, unsigned short size)
{
shell->parser.length = 0;
shell->parser.cursor = 0;
shell->history.offset = 0;
@ -187,6 +188,7 @@ void shellInit(Shell *shell, char *buffer, unsigned short size)
SHELL_DEFAULT_USER,
shell->commandList.base,
0));
shellWriteCommandLine(shell, 1);
}
@ -863,7 +865,7 @@ ShellCommand* shellSeekCommand(Shell *shell,
name = shellGetCommandName(&base[i]);
if (!compareLength)
{
if (strcmp(cmd, name) == 0)
if (strncmp(cmd, name, strlen(cmd)) == 0)
{
return &base[i];
}