forked from xuos/xiuos
sync the upstream branch
This commit is contained in:
commit
ebbb30c763
|
@ -1,9 +1,15 @@
|
||||||
import os
|
import os
|
||||||
Import('RTT_ROOT')
|
Import('RTT_ROOT')
|
||||||
|
Import('rtconfig')
|
||||||
from building import *
|
from building import *
|
||||||
|
|
||||||
cwd = GetCurrentDir()
|
cwd = GetCurrentDir()
|
||||||
|
|
||||||
|
SOURCES = ['framework_init.c']
|
||||||
|
path = [cwd]
|
||||||
objs = []
|
objs = []
|
||||||
|
group = DefineGroup('sensor', SOURCES, depend = [], CPPPATH = [cwd])
|
||||||
|
objs = objs + group
|
||||||
list = os.listdir(cwd)
|
list = os.listdir(cwd)
|
||||||
|
|
||||||
for d in list:
|
for d in list:
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <user_api.h>
|
#include <transform.h>
|
||||||
|
|
||||||
extern int SensorFrameworkInit(void);
|
extern int SensorFrameworkInit(void);
|
||||||
extern int AdapterFrameworkInit(void);
|
extern int AdapterFrameworkInit(void);
|
||||||
|
|
||||||
extern int Adapter4GInit(void);
|
extern int Adapter4GInit(void);
|
||||||
|
extern int AdapterBlueToothInit(void);
|
||||||
extern int AdapterWifiInit(void);
|
extern int AdapterWifiInit(void);
|
||||||
extern int AdapterZigbeeInit(void);
|
extern int AdapterZigbeeInit(void);
|
||||||
|
|
||||||
|
@ -90,13 +91,16 @@ static struct InitDesc sensor_desc[] =
|
||||||
|
|
||||||
static struct InitDesc connection_desc[] =
|
static struct InitDesc connection_desc[] =
|
||||||
{
|
{
|
||||||
#ifdef ADAPTER_4G
|
#ifdef CONNECTION_ADAPTER_4G
|
||||||
{ "4G adpter", Adapter4GInit},
|
{ "4G adpter", Adapter4GInit},
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONNECTION_ADAPTER_ZIGBEE
|
#ifdef CONNECTION_ADAPTER_ZIGBEE
|
||||||
{ "zigbee adpter", AdapterZigbeeInit},
|
{ "zigbee adpter", AdapterZigbeeInit},
|
||||||
#endif
|
#endif
|
||||||
#ifdef ADAPTER_WIFI
|
#ifdef CONNECTION_ADAPTER_BLUETOOTH
|
||||||
|
{ "BlueTooth adpter", AdapterBlueToothInit},
|
||||||
|
#endif
|
||||||
|
#ifdef CONNECTION_ADAPTER_WIFI
|
||||||
{ "Wifi adpter", AdapterWifiInit},
|
{ "Wifi adpter", AdapterWifiInit},
|
||||||
#endif
|
#endif
|
||||||
{ "NULL", NULL },
|
{ "NULL", NULL },
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import os
|
||||||
|
Import('RTT_ROOT')
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
objs = []
|
||||||
|
list = os.listdir(cwd)
|
||||||
|
|
||||||
|
for d in list:
|
||||||
|
path = os.path.join(cwd, d)
|
||||||
|
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||||
|
objs = objs + SConscript(os.path.join(path, 'SConscript'))
|
||||||
|
|
||||||
|
Return('objs')
|
|
@ -0,0 +1,11 @@
|
||||||
|
import os
|
||||||
|
from building import *
|
||||||
|
Import('RTT_ROOT')
|
||||||
|
Import('rtconfig')
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
DEPENDS = [""]
|
||||||
|
|
||||||
|
SOURCES = ['double_list.c'] + ['single_list.c']
|
||||||
|
path = [cwd]
|
||||||
|
objs = DefineGroup('list', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
||||||
|
Return("objs")
|
|
@ -23,7 +23,7 @@
|
||||||
#define __LIST_H__
|
#define __LIST_H__
|
||||||
|
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
|
#include<stddef.h>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import os
|
||||||
|
from building import *
|
||||||
|
Import('RTT_ROOT')
|
||||||
|
Import('rtconfig')
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
DEPENDS = ["SUPPORT_SENSOR_FRAMEWORK"]
|
||||||
|
SOURCES = []
|
||||||
|
if GetDepend(['APPLICATION_SENSOR_CO2_ZG09']):
|
||||||
|
SOURCES = ['co2_zg09.c'] + SOURCES
|
||||||
|
if GetDepend(['APPLICATION_SENSOR_PM1_0_PS5308']):
|
||||||
|
SOURCES = ['pm1_0_ps5308.c.c'] + SOURCES
|
||||||
|
if GetDepend(['APPLICATION_SENSOR_VOICE_D124']):
|
||||||
|
SOURCES = ['voice_d124.c'] + SOURCES
|
||||||
|
if GetDepend(['APPLICATION_SENSOR_HUMIDITY_HS300X']):
|
||||||
|
SOURCES = ['humidity_hs300x.c'] + SOURCES
|
||||||
|
if GetDepend(['APPLICATION_SENSOR_TEMPERATURE_HS300X']):
|
||||||
|
SOURCES = ['temperature_hs300x.c'] + SOURCES
|
||||||
|
path = [cwd]
|
||||||
|
objs = DefineGroup('sensor_app', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
||||||
|
Return("objs")
|
|
@ -18,7 +18,7 @@
|
||||||
* @date 2021.04.23
|
* @date 2021.04.23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <user_api.h>
|
#include <transform.h>
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -253,11 +253,11 @@ AdapterProductInfoType Ec200tAttach(struct Adapter *adapter)
|
||||||
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
||||||
if (!product_info) {
|
if (!product_info) {
|
||||||
printf("Ec200tAttach malloc product_info error\n");
|
printf("Ec200tAttach malloc product_info error\n");
|
||||||
free(product_info);
|
PrivFree(product_info);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
product_info->model_name = ADAPTER_4G_EC200T;
|
strcpy(product_info->model_name, ADAPTER_4G_EC200T);
|
||||||
|
|
||||||
product_info->model_done = (void *)&ec200t_done;
|
product_info->model_done = (void *)&ec200t_done;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
config ADAPTER_4G
|
config ADAPTER_EC200T
|
||||||
bool "Using 4G adapter function"
|
bool "Using 4G adapter device EC200T"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
if ADAPTER_4G
|
if ADAPTER_EC200T
|
||||||
config ADAPTER_EC200T
|
source "$APP_DIR/Framework/connection/4G/EC200T/Kconfig"
|
||||||
bool "Using 4G adapter device EC200T"
|
endif
|
||||||
default y
|
|
||||||
|
|
||||||
if ADAPTER_EC200T
|
|
||||||
source "$APP_DIR/Framework/connection/4G/EC200T/Kconfig"
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
SRC_FILES := adapter.c adapter_agent.c
|
SRC_FILES := adapter.c adapter_agent.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_LORA),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_LORA),y)
|
||||||
SRC_DIR += lora
|
SRC_DIR += lora
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_4G),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
|
||||||
SRC_DIR += 4G
|
SRC_DIR += 4G
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_NB),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_NB),y)
|
||||||
SRC_DIR += nbiot
|
SRC_DIR += nbiot
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_WIFI),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_WIFI),y)
|
||||||
SRC_DIR += wifi
|
SRC_DIR += wifi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_ETHERNET),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_ETHERNET),y)
|
||||||
SRC_DIR += ethernet
|
SRC_DIR += ethernet
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_BLUETOOTH),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_BLUETOOTH),y)
|
||||||
SRC_DIR += bluetooth
|
SRC_DIR += bluetooth
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ ifeq ($(CONFIG_CONNECTION_ADAPTER_ZIGBEE),y)
|
||||||
SRC_DIR += zigbee
|
SRC_DIR += zigbee
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_5G),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_5G),y)
|
||||||
SRC_DIR += 5G
|
SRC_DIR += 5G
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -39,15 +39,6 @@ extern "C" {
|
||||||
#define ADAPTER_LWIP_OPERATION 2
|
#define ADAPTER_LWIP_OPERATION 2
|
||||||
#define ADAPTER_RAWIP_OPERATION 3
|
#define ADAPTER_RAWIP_OPERATION 3
|
||||||
|
|
||||||
#define ADAPTER_LORA_FUNC ((uint32_t)(1 << ATAPTER_LORA))
|
|
||||||
#define ADAPTER_4G_FUNC ((uint32_t)(1 << ADAPTER_4G))
|
|
||||||
#define ADAPTER_NBIOT_FUNC ((uint32_t)(1 << ADAPTER_NBIOT))
|
|
||||||
#define ADAPTER_WIFI_FUNC ((uint32_t)(1 << ADAPTER_WIFI))
|
|
||||||
#define ADAPTER_ETHERNET_FUNC ((uint32_t)(1 << ADAPTER_ETHERNET))
|
|
||||||
#define ADAPTER_BLUETOOTH_FUNC ((uint32_t)(1 << ADAPTER_BLUETOOTH))
|
|
||||||
#define ADAPTER_ZIGBEE_FUNC ((uint32_t)(1 << ADAPTER_ZIGBEE))
|
|
||||||
#define ADAPTER_5G_FUNC ((uint32_t)(1 << ADAPTER_5G))
|
|
||||||
|
|
||||||
#ifdef CONNECTION_FRAMEWORK_DEBUG
|
#ifdef CONNECTION_FRAMEWORK_DEBUG
|
||||||
#define ADAPTER_DEBUG printf
|
#define ADAPTER_DEBUG printf
|
||||||
#else
|
#else
|
||||||
|
@ -113,8 +104,8 @@ enum IpType
|
||||||
struct AdapterProductInfo
|
struct AdapterProductInfo
|
||||||
{
|
{
|
||||||
uint32_t functions;
|
uint32_t functions;
|
||||||
const char *vendor_name;
|
char vendor_name[NAME_NUM_MAX];
|
||||||
const char *model_name;
|
char model_name[NAME_NUM_MAX];
|
||||||
uint32_t work_mode;
|
uint32_t work_mode;
|
||||||
|
|
||||||
void *model_done;
|
void *model_done;
|
||||||
|
@ -158,7 +149,7 @@ struct PrivProtocolDone
|
||||||
|
|
||||||
struct Adapter
|
struct Adapter
|
||||||
{
|
{
|
||||||
char name[32];
|
char name[NAME_NUM_MAX];
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
int product_info_flag;
|
int product_info_flag;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <user_api.h>
|
#include <user_api.h>
|
||||||
#include <bus.h>
|
|
||||||
|
|
||||||
#define AT_CMD_MAX_LEN 128
|
#define AT_CMD_MAX_LEN 128
|
||||||
#define AT_AGENT_MAX 2
|
#define AT_AGENT_MAX 2
|
||||||
|
@ -36,12 +35,13 @@ static uint32 last_cmd_len = 0;
|
||||||
|
|
||||||
static struct ATAgent at_agent_table[AT_AGENT_MAX] = {0};
|
static struct ATAgent at_agent_table[AT_AGENT_MAX] = {0};
|
||||||
|
|
||||||
uint IpTint(char *ipstr){
|
unsigned int IpTint(char *ipstr)
|
||||||
|
{
|
||||||
if (ipstr == NULL)
|
if (ipstr == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char *token;
|
char *token;
|
||||||
uint i = 3, total = 0, cur;
|
unsigned int i = 3, total = 0, cur;
|
||||||
|
|
||||||
token = strtok(ipstr, ".");
|
token = strtok(ipstr, ".");
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void SwapStr(char *str, int begin, int end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *IpTstr(uint ipint)
|
char *IpTstr(unsigned int ipint)
|
||||||
{
|
{
|
||||||
int LEN = 16;
|
int LEN = 16;
|
||||||
char *new = (char *)malloc(LEN);
|
char *new = (char *)malloc(LEN);
|
||||||
|
@ -124,13 +124,17 @@ uint32 ATSprintf(int fd, const char *format, va_list params)
|
||||||
PrivWrite(fd, send_buf, last_cmd_len);
|
PrivWrite(fd, send_buf, last_cmd_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char *cmd_expr, ...)
|
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...)
|
||||||
{
|
{
|
||||||
if (agent == NULL){
|
if (agent == NULL){
|
||||||
printf("ATAgent is null");
|
printf("ATAgent is null");
|
||||||
return -ERROR;
|
return -ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct timespec abstime;
|
||||||
|
|
||||||
|
abstime.tv_sec = timeout_s;
|
||||||
|
|
||||||
agent->receive_mode = AT_MODE;
|
agent->receive_mode = AT_MODE;
|
||||||
|
|
||||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||||
|
@ -152,7 +156,7 @@ int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char
|
||||||
va_start(params, cmd_expr);
|
va_start(params, cmd_expr);
|
||||||
ATSprintf(agent->fd, cmd_expr, params);
|
ATSprintf(agent->fd, cmd_expr, params);
|
||||||
va_end(params);
|
va_end(params);
|
||||||
if (UserSemaphoreObtain(agent->rsp_sem, timeout) != EOK){
|
if (PrivSemaphoreObtainWait(&agent->rsp_sem, &abstime) != EOK){
|
||||||
result = -ETIMEOUT;
|
result = -ETIMEOUT;
|
||||||
goto __out;
|
goto __out;
|
||||||
}
|
}
|
||||||
|
@ -185,22 +189,24 @@ int EntmSend(ATAgentType agent, const char *data, int len)
|
||||||
memcpy(send_buf, data, len);
|
memcpy(send_buf, data, len);
|
||||||
memcpy(send_buf + len, "!@", 2);
|
memcpy(send_buf + len, "!@", 2);
|
||||||
|
|
||||||
write(agent->fd, send_buf, len + 2);
|
PrivWrite(agent->fd, send_buf, len + 2);
|
||||||
|
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out)
|
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||||
{
|
{
|
||||||
UserTaskDelay(1000);
|
struct timespec abstime;
|
||||||
|
|
||||||
|
abstime.tv_sec = timeout_s;
|
||||||
|
|
||||||
|
PrivTaskDelay(1000);
|
||||||
|
|
||||||
memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX);
|
memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX);
|
||||||
agent->entm_recv_len = 0;
|
agent->entm_recv_len = 0;
|
||||||
|
|
||||||
UserSemaphoreSetValue(agent->entm_rx_notice, 0);
|
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)){
|
||||||
|
return ERROR;
|
||||||
if (UserSemaphoreObtain(agent->entm_rx_notice, time_out)){
|
|
||||||
return -ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_len < agent->entm_recv_len){
|
if (buffer_len < agent->entm_recv_len){
|
||||||
|
@ -225,16 +231,17 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
agent->maintain_len = 0;
|
agent->maintain_len = 0;
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
read(agent->fd, &ch, 1);
|
PrivRead(agent->fd, &ch, 1);
|
||||||
|
|
||||||
printf(" %c(0x%x)\n", ch, ch);
|
printf(" %c(0x%x)\n", ch, ch);
|
||||||
|
|
||||||
if (agent->receive_mode == ENTM_MODE){
|
if (agent->receive_mode == ENTM_MODE){
|
||||||
if (agent->entm_recv_len < ENTM_RECV_MAX){
|
if (agent->entm_recv_len < ENTM_RECV_MAX){
|
||||||
agent->entm_recv_buf[agent->entm_recv_len++] = ch;
|
agent->entm_recv_buf[agent->entm_recv_len] = ch;
|
||||||
|
agent->entm_recv_len++;
|
||||||
|
|
||||||
if (last_ch == '!' && ch == '@'){
|
if (last_ch == '!' && ch == '@'){
|
||||||
UserSemaphoreAbandon(agent->entm_rx_notice);
|
PrivSemaphoreAbandon(&agent->entm_rx_notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
last_ch = ch;
|
last_ch = ch;
|
||||||
|
@ -245,7 +252,8 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
}
|
}
|
||||||
else if (agent->receive_mode == AT_MODE){
|
else if (agent->receive_mode == AT_MODE){
|
||||||
if (read_len < agent->maintain_max){
|
if (read_len < agent->maintain_max){
|
||||||
agent->maintain_buffer[read_len++] = ch;
|
agent->maintain_buffer[read_len] = ch;
|
||||||
|
read_len++;
|
||||||
agent->maintain_len = read_len;
|
agent->maintain_len = read_len;
|
||||||
}else{
|
}else{
|
||||||
printf("maintain_len is_full ...\n");
|
printf("maintain_len is_full ...\n");
|
||||||
|
@ -289,25 +297,25 @@ static int DeleteATAgent(ATAgentType agent)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->entm_rx_notice){
|
if (agent->entm_rx_notice){
|
||||||
UserSemaphoreDelete(agent->entm_rx_notice);
|
PrivSemaphoreDelete(&agent->entm_rx_notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->fd > 0){
|
if (agent->fd > 0){
|
||||||
close(agent->fd);
|
PrivClose(agent->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->rsp_sem){
|
if (agent->rsp_sem){
|
||||||
UserSemaphoreDelete(agent->rsp_sem);
|
PrivSemaphoreDelete(&agent->rsp_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->maintain_buffer){
|
if (agent->maintain_buffer){
|
||||||
free(agent->maintain_buffer);
|
PrivFree(agent->maintain_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(agent, 0x00, sizeof(struct ATAgent));
|
memset(agent, 0x00, sizeof(struct ATAgent));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ATAgentReceiveProcess(void *param)
|
static void *ATAgentReceiveProcess(void *param)
|
||||||
{
|
{
|
||||||
ATAgentType agent = (ATAgentType)param;
|
ATAgentType agent = (ATAgentType)param;
|
||||||
const struct at_urc *urc;
|
const struct at_urc *urc;
|
||||||
|
@ -329,7 +337,7 @@ static void ATAgentReceiveProcess(void *param)
|
||||||
}
|
}
|
||||||
|
|
||||||
agent->reply = NULL;
|
agent->reply = NULL;
|
||||||
UserSemaphoreAbandon(agent->rsp_sem);
|
PrivSemaphoreAbandon(&agent->rsp_sem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,56 +347,51 @@ static int ATAgentInit(ATAgentType agent)
|
||||||
{
|
{
|
||||||
int result = EOK;
|
int result = EOK;
|
||||||
UtaskType at_utask;
|
UtaskType at_utask;
|
||||||
do
|
|
||||||
{
|
|
||||||
agent->maintain_len = 0;
|
|
||||||
agent->maintain_buffer = (char *)malloc(agent->maintain_max);
|
|
||||||
|
|
||||||
if (agent->maintain_buffer == NONE){
|
agent->maintain_len = 0;
|
||||||
break;
|
agent->maintain_buffer = (char *)malloc(agent->maintain_max);
|
||||||
}
|
|
||||||
|
|
||||||
agent->entm_rx_notice = UserSemaphoreCreate(0);
|
if (agent->maintain_buffer == NONE){
|
||||||
if (agent->entm_rx_notice == 0){
|
printf("ATAgentInit malloc maintain_buffer error\n");
|
||||||
break;
|
goto __out;
|
||||||
}
|
}
|
||||||
|
|
||||||
agent->rsp_sem = UserSemaphoreCreate(0);
|
result = PrivSemaphoreCreate(&agent->entm_rx_notice, 0, 0);
|
||||||
if (agent->rsp_sem == 0){
|
if (result < 0){
|
||||||
break;
|
printf("ATAgentInit create entm sem error\n");
|
||||||
}
|
goto __out;
|
||||||
if(PrivMutexCreate(&agent->lock, 0) < 0) {
|
}
|
||||||
printf("AdapterFrameworkInit mutex create failed.\n");
|
|
||||||
}
|
|
||||||
if (agent->lock == 0){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
agent->receive_mode = ENTM_MODE;
|
result = PrivSemaphoreCreate(&agent->rsp_sem, 0, 0);
|
||||||
|
if (result < 0){
|
||||||
|
printf("ATAgentInit create rsp sem error\n");
|
||||||
|
goto __out;
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(at_utask.name, "recv_task", strlen("recv_task"));
|
if(PrivMutexCreate(&agent->lock, 0) < 0) {
|
||||||
at_utask.func_entry = ATAgentReceiveProcess;
|
printf("AdapterFrameworkInit mutex create failed.\n");
|
||||||
at_utask.func_param = agent;
|
goto __out;
|
||||||
at_utask.stack_size = 2048;
|
}
|
||||||
at_utask.prio = 18;
|
|
||||||
|
|
||||||
agent->at_handler = UserTaskCreate(at_utask);
|
agent->receive_mode = ENTM_MODE;
|
||||||
|
|
||||||
// struct SerialDataCfg data_cfg;
|
pthread_attr_t attr;
|
||||||
// memset(&data_cfg, 0, sizeof(struct SerialDataCfg));
|
attr.schedparam.sched_priority = 18;
|
||||||
// data_cfg.serial_baud_rate = 57600;
|
attr.stacksize = 2048;
|
||||||
// ioctl(agent->fd, OPE_INT, &data_cfg);
|
|
||||||
|
|
||||||
if (agent->at_handler == 0) {
|
PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, agent);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = EOK;
|
// struct SerialDataCfg data_cfg;
|
||||||
return result;
|
// memset(&data_cfg, 0, sizeof(struct SerialDataCfg));
|
||||||
} while (1);
|
// data_cfg.serial_baud_rate = 57600;
|
||||||
|
// ioctl(agent->fd, OPE_INT, &data_cfg);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
__out:
|
||||||
DeleteATAgent(agent);
|
DeleteATAgent(agent);
|
||||||
result = -ERROR;
|
result = -ERROR;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +427,7 @@ int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max)
|
||||||
result = ATAgentInit(agent);
|
result = ATAgentInit(agent);
|
||||||
if (result == EOK)
|
if (result == EOK)
|
||||||
{
|
{
|
||||||
UserTaskStartup(agent->at_handler);
|
PrivTaskStartup(&agent->at_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -445,7 +448,7 @@ ATReplyType CreateATReply(uint32 reply_max_len)
|
||||||
reply->reply_buffer = (char *)malloc(reply_max_len);
|
reply->reply_buffer = (char *)malloc(reply_max_len);
|
||||||
if (reply->reply_buffer == NULL){
|
if (reply->reply_buffer == NULL){
|
||||||
printf("no more memory\n");
|
printf("no more memory\n");
|
||||||
free(reply);
|
PrivFree(reply);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(reply->reply_buffer,0,reply_max_len);
|
memset(reply->reply_buffer,0,reply_max_len);
|
||||||
|
@ -456,13 +459,13 @@ void DeleteATReply(ATReplyType reply)
|
||||||
{
|
{
|
||||||
if (reply){
|
if (reply){
|
||||||
if (reply->reply_buffer){
|
if (reply->reply_buffer){
|
||||||
free(reply->reply_buffer);
|
PrivFree(reply->reply_buffer);
|
||||||
reply->reply_buffer = NULL;
|
reply->reply_buffer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply){
|
if (reply){
|
||||||
free(reply);
|
PrivFree(reply);
|
||||||
reply = NULL;
|
reply = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct ATAgent
|
||||||
ATReplyType reply;
|
ATReplyType reply;
|
||||||
int rsp_sem;
|
int rsp_sem;
|
||||||
|
|
||||||
int32 at_handler;
|
pthread_t at_handler;
|
||||||
|
|
||||||
#define ENTM_RECV_MAX 256
|
#define ENTM_RECV_MAX 256
|
||||||
char entm_recv_buf[ENTM_RECV_MAX];
|
char entm_recv_buf[ENTM_RECV_MAX];
|
||||||
|
@ -65,7 +65,7 @@ struct ATAgent
|
||||||
typedef struct ATAgent *ATAgentType;
|
typedef struct ATAgent *ATAgentType;
|
||||||
|
|
||||||
int EntmSend(ATAgentType agent, const char *data, int len);
|
int EntmSend(ATAgentType agent, const char *data, int len);
|
||||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out);
|
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s);
|
||||||
char *GetReplyText(ATReplyType reply);
|
char *GetReplyText(ATReplyType reply);
|
||||||
ATReplyType CreateATReply(uint32 reply_max_len);
|
ATReplyType CreateATReply(uint32 reply_max_len);
|
||||||
uint IpTint(char *ipstr);
|
uint IpTint(char *ipstr);
|
||||||
|
@ -75,7 +75,7 @@ ATAgentType GetATAgent(const char *agent_name);
|
||||||
int InitATAgent(const char *agent_name, int fd, uint32 maintain_max);
|
int InitATAgent(const char *agent_name, int fd, uint32 maintain_max);
|
||||||
int ParseATReply(char* str, const char *format, ...);
|
int ParseATReply(char* str, const char *format, ...);
|
||||||
void DeleteATReply(ATReplyType reply);
|
void DeleteATReply(ATReplyType reply);
|
||||||
int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char *cmd_expr, ...);
|
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...);
|
||||||
|
|
||||||
#define REPLY_TIME_OUT 3000
|
#define REPLY_TIME_OUT 3000
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
config ADAPTER_BLUETOOTH
|
config ADAPTER_HC08
|
||||||
bool "Using bluetooth adapter function"
|
bool "Using bluetooth adapter device HC08"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
if ADAPTER_BLUETOOTH
|
if ADAPTER_HC08
|
||||||
config ADAPTER_HC08
|
source "$APP_DIR/Framework/connection/bluetooth/HC08/Kconfig"
|
||||||
bool "Using bluetooth adapter device HC08"
|
endif
|
||||||
default y
|
|
||||||
|
|
||||||
if ADAPTER_HC08
|
|
||||||
source "$APP_DIR/Framework/connection/bluetooth/HC08/Kconfig"
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
|
@ -210,10 +210,10 @@ static int Hfa21SetAddr(struct Adapter *adapter, const char *ip, const char *gat
|
||||||
char *gw_str = NULL;
|
char *gw_str = NULL;
|
||||||
char *mask_str = NULL;
|
char *mask_str = NULL;
|
||||||
|
|
||||||
dhcp_mode = (char *) UserCalloc(1, 8);
|
dhcp_mode = (char *) PrivCalloc(1, 8);
|
||||||
ip_str = (char *) UserCalloc(1, 17);
|
ip_str = (char *) PrivCalloc(1, 17);
|
||||||
gw_str = (char *) UserCalloc(1, 17);
|
gw_str = (char *) PrivCalloc(1, 17);
|
||||||
mask_str = (char *) UserCalloc(1, 17);
|
mask_str = (char *) PrivCalloc(1, 17);
|
||||||
|
|
||||||
Hfa21InitAtCmd(adapter->agent);
|
Hfa21InitAtCmd(adapter->agent);
|
||||||
|
|
||||||
|
@ -260,8 +260,8 @@ static int Hfa21Ping(struct Adapter *adapter, const char *destination)
|
||||||
{
|
{
|
||||||
char *ping_result = NONE;
|
char *ping_result = NONE;
|
||||||
char *dst = NONE;
|
char *dst = NONE;
|
||||||
ping_result = (char *) UserCalloc(1, 17);
|
ping_result = (char *) PrivCalloc(1, 17);
|
||||||
dst = (char *) UserCalloc(1, 17);
|
dst = (char *) PrivCalloc(1, 17);
|
||||||
strcpy(dst, destination);
|
strcpy(dst, destination);
|
||||||
strcat(dst, "\r");
|
strcat(dst, "\r");
|
||||||
|
|
||||||
|
@ -327,11 +327,11 @@ static int Hfa21Netstat(struct Adapter *adapter)
|
||||||
char *local_ipaddr = NULL;
|
char *local_ipaddr = NULL;
|
||||||
char *gateway = NULL;
|
char *gateway = NULL;
|
||||||
char *netmask = NULL;
|
char *netmask = NULL;
|
||||||
local_ipaddr = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
local_ipaddr = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
gateway = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
gateway = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
netmask = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
netmask = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
work_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
work_mode = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
ip_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
ip_mode = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
|
|
||||||
reply = CreateATReply(HFA21_NETSTAT_RESP_SIZE);
|
reply = CreateATReply(HFA21_NETSTAT_RESP_SIZE);
|
||||||
if (reply == NULL) {
|
if (reply == NULL) {
|
||||||
|
@ -391,13 +391,13 @@ __exit:
|
||||||
if (reply)
|
if (reply)
|
||||||
DeleteATReply(reply);
|
DeleteATReply(reply);
|
||||||
if (local_ipaddr)
|
if (local_ipaddr)
|
||||||
UserFree(local_ipaddr);
|
PrivFree(local_ipaddr);
|
||||||
if (netmask)
|
if (netmask)
|
||||||
UserFree(netmask);
|
PrivFree(netmask);
|
||||||
if (gateway)
|
if (gateway)
|
||||||
UserFree(gateway);
|
PrivFree(gateway);
|
||||||
if (work_mode)
|
if (work_mode)
|
||||||
UserFree(work_mode);
|
PrivFree(work_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Hfa21Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
static int Hfa21Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||||
|
@ -504,11 +504,11 @@ AdapterProductInfoType Hfa21Attach(struct Adapter *adapter)
|
||||||
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
||||||
if (!product_info) {
|
if (!product_info) {
|
||||||
printf("Hfa21Attach Attach malloc product_info error\n");
|
printf("Hfa21Attach Attach malloc product_info error\n");
|
||||||
free(product_info);
|
PrivFree(product_info);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
product_info->model_name = ADAPTER_WIFI_HFA21;
|
strcpy(product_info->model_name, ADAPTER_WIFI_HFA21);
|
||||||
|
|
||||||
product_info->model_done = (void *)&hfa21_done;
|
product_info->model_done = (void *)&hfa21_done;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
config ADAPTER_WIFI
|
config ADAPTER_HFA21
|
||||||
bool "Using WIFI adapter function"
|
bool "Using wifi adapter device HFA21"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
if ADAPTER_WIFI
|
if ADAPTER_HFA21
|
||||||
config ADAPTER_HFA21
|
source "$APP_DIR/Framework/connection/wifi/HFA21/Kconfig"
|
||||||
bool "Using wifi adapter device HFA21"
|
endif
|
||||||
default y
|
|
||||||
|
|
||||||
if ADAPTER_HFA21
|
|
||||||
source "$APP_DIR/Framework/connection/wifi/HFA21/Kconfig"
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
|
@ -439,7 +439,7 @@ AdapterProductInfoType E18Attach(struct Adapter *adapter)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
product_info->model_name = ADAPTER_ZIGBEE_E18;
|
strncpy(product_info->model_name, ADAPTER_ZIGBEE_E18,sizeof(product_info->model_name));
|
||||||
product_info->model_done = (void *)&E18_done;
|
product_info->model_done = (void *)&E18_done;
|
||||||
|
|
||||||
return product_info;
|
return product_info;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
import os
|
||||||
|
Import('RTT_ROOT')
|
||||||
|
Import('rtconfig')
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
SOURCES = []
|
||||||
|
if GetDepend(['SUPPORT_SENSOR_FRAMEWORK']):
|
||||||
|
SOURCES = ['sensor.c'] + SOURCES
|
||||||
|
path = [cwd]
|
||||||
|
objs = []
|
||||||
|
group = DefineGroup('sensor', SOURCES, depend = [], CPPPATH = [cwd])
|
||||||
|
objs = objs + group
|
||||||
|
list = os.listdir(cwd)
|
||||||
|
|
||||||
|
for d in list:
|
||||||
|
path = os.path.join(cwd, d)
|
||||||
|
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||||
|
objs = objs + SConscript(os.path.join(path, 'SConscript'))
|
||||||
|
|
||||||
|
Return('objs')
|
|
@ -0,0 +1,14 @@
|
||||||
|
import os
|
||||||
|
Import('RTT_ROOT')
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
objs = []
|
||||||
|
list = os.listdir(cwd)
|
||||||
|
|
||||||
|
for d in list:
|
||||||
|
path = os.path.join(cwd, d)
|
||||||
|
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||||
|
objs = objs + SConscript(os.path.join(path, 'SConscript'))
|
||||||
|
|
||||||
|
Return('objs')
|
|
@ -0,0 +1,10 @@
|
||||||
|
from building import *
|
||||||
|
import os
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
src = []
|
||||||
|
if GetDepend(['SENSOR_D124']):
|
||||||
|
src += ['d124.c']
|
||||||
|
group = DefineGroup('sensor voice d124', src, depend = [], CPPPATH = [cwd])
|
||||||
|
|
||||||
|
Return('group')
|
|
@ -21,7 +21,7 @@
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
static struct SensorDevice d124;
|
static struct SensorDevice d124;
|
||||||
static int32_t active_task_id;
|
static pthread_t active_task_id;
|
||||||
static pthread_mutex_t buff_lock;
|
static pthread_mutex_t buff_lock;
|
||||||
|
|
||||||
static struct SensorProductInfo info =
|
static struct SensorProductInfo info =
|
||||||
|
|
|
@ -5,7 +5,7 @@ Import('rtconfig')
|
||||||
cwd = GetCurrentDir()
|
cwd = GetCurrentDir()
|
||||||
DEPENDS = [""]
|
DEPENDS = [""]
|
||||||
|
|
||||||
SOURCES = []
|
SOURCES = ['transform.c']
|
||||||
path = [cwd]
|
path = [cwd]
|
||||||
objs = DefineGroup('transform', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
objs = DefineGroup('transform', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
||||||
Return("objs")
|
Return("objs")
|
|
@ -0,0 +1,191 @@
|
||||||
|
/*
|
||||||
|
* 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 xiuos.c
|
||||||
|
* @brief Converts the framework interface to an operating system interface
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.07
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <transform.h>
|
||||||
|
|
||||||
|
/**************************mutex***************************/
|
||||||
|
/* private mutex API */
|
||||||
|
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr)
|
||||||
|
{
|
||||||
|
return pthread_mutex_init(p_mutex, attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivMutexDelete(pthread_mutex_t *p_mutex)
|
||||||
|
{
|
||||||
|
return pthread_mutex_destroy(p_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivMutexObtain(pthread_mutex_t *p_mutex)
|
||||||
|
{
|
||||||
|
return pthread_mutex_lock(p_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivMutexAbandon(pthread_mutex_t *p_mutex)
|
||||||
|
{
|
||||||
|
return pthread_mutex_unlock(p_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************semaphore****************************/
|
||||||
|
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value)
|
||||||
|
{
|
||||||
|
return sem_init(sem, pshared, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivSemaphoreDelete(sem_t *sem)
|
||||||
|
{
|
||||||
|
return sem_destroy(sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime)
|
||||||
|
{
|
||||||
|
return sem_timedwait(sem, abstime);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivSemaphoreObtainNoWait(sem_t *sem)
|
||||||
|
{
|
||||||
|
return sem_trywait(sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivSemaphoreAbandon(sem_t *sem)
|
||||||
|
{
|
||||||
|
return sem_post(sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************task*************************/
|
||||||
|
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||||
|
void *(*start_routine)(void *), void *arg)
|
||||||
|
{
|
||||||
|
pthread_attr_t attrtmp ;
|
||||||
|
pthread_attr_init(&attrtmp);
|
||||||
|
pthread_attr_setschedparam(&attrtmp, &(attr->schedparam)); /* 修改属性对应的优先级 */
|
||||||
|
pthread_attr_setstacksize(&attrtmp, (size_t)((attr->stacksize)));
|
||||||
|
return pthread_create(thread, &attrtmp, start_routine, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivTaskStartup(pthread_t *thread)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivTaskDelete(pthread_t thread, int sig)
|
||||||
|
{
|
||||||
|
_pthread_data_t *ptd;
|
||||||
|
ptd = _pthread_get_data(thread);
|
||||||
|
return rt_thread_detach(ptd->tid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrivTaskQuit(void *value_ptr)
|
||||||
|
{
|
||||||
|
pthread_exit(value_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivTaskDelay(int32_t ms)
|
||||||
|
{
|
||||||
|
rt_thread_mdelay(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************fs**************************/
|
||||||
|
|
||||||
|
/************************Driver Posix Transform***********************/
|
||||||
|
int PrivOpen(const char *path, int flags)
|
||||||
|
{
|
||||||
|
return open(path, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivClose(int fd)
|
||||||
|
{
|
||||||
|
return close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivRead(int fd, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return read(fd, buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivWrite(int fd, const void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return write(fd, buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int PrivSerialIoctl(int fd, int cmd, void *args)
|
||||||
|
{
|
||||||
|
struct dfs_fd *rt_fd;
|
||||||
|
int ret = 0;
|
||||||
|
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
|
||||||
|
struct SerialDataCfg *serial_cfg = (struct SerialDataCfg *)args;
|
||||||
|
config.baud_rate = serial_cfg->serial_baud_rate;
|
||||||
|
config.data_bits = serial_cfg->serial_data_bits;
|
||||||
|
config.stop_bits = serial_cfg->serial_stop_bits;
|
||||||
|
config.bufsz = RT_SERIAL_RB_BUFSZ;
|
||||||
|
config.parity = serial_cfg->serial_parity_mode;
|
||||||
|
config.invert = serial_cfg->serial_invert_mode;
|
||||||
|
rt_fd = fd_get(fd);
|
||||||
|
ret = rt_fd->fops->ioctl(rt_fd, RT_DEVICE_CTRL_CONFIG, &config);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int PrivPinIoctl(int fd, int cmd, void *args)
|
||||||
|
{
|
||||||
|
struct PinParam *pin_cfg = (struct PinParam *)args;
|
||||||
|
|
||||||
|
return ioctl(fd, cmd, pin_cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivIoctl(int fd, int cmd, void *args)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct PrivIoctlCfg *ioctl_cfg = (struct PrivIoctlCfg *)args;
|
||||||
|
|
||||||
|
switch (ioctl_cfg->ioctl_driver_type)
|
||||||
|
{
|
||||||
|
case SERIAL_TYPE:
|
||||||
|
ret = PrivSerialIoctl(fd, cmd, ioctl_cfg->args);
|
||||||
|
break;
|
||||||
|
case PIN_TYPE:
|
||||||
|
ret = PrivPinIoctl(fd, cmd, ioctl_cfg->args);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************memory api************/
|
||||||
|
void *PrivMalloc(size_t size)
|
||||||
|
{
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *PrivRealloc(void *pointer, size_t size)
|
||||||
|
{
|
||||||
|
return realloc(pointer, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *PrivCalloc(size_t count, size_t size)
|
||||||
|
{
|
||||||
|
return calloc(count, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrivFree(void *pointer)
|
||||||
|
{
|
||||||
|
free(pointer);
|
||||||
|
}
|
||||||
|
|
|
@ -30,19 +30,23 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <pthread_internal.h>
|
||||||
|
#include <semaphore.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dfs_poll.h>
|
#include <dfs_poll.h>
|
||||||
|
#include <dfs_posix.h>
|
||||||
|
#include <dfs.h>
|
||||||
#ifdef RT_USING_POSIX_TERMIOS
|
#ifdef RT_USING_POSIX_TERMIOS
|
||||||
#include <posix_termios.h>
|
#include <posix_termios.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef DRV_USING_OV2640
|
#ifdef DRV_USING_OV2640
|
||||||
#include <drv_ov2640.h>
|
#include <drv_ov2640.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(RT_USING_SAL)
|
#if defined(RT_USING_SAL)&& defined (RT_USING_LWIP)
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#else
|
#elif defined RT_USING_LWIP
|
||||||
#include <lwip/netdb.h>
|
#include <lwip/netdb.h>
|
||||||
#include <lwip/sockets.h>
|
#include <lwip/sockets.h>
|
||||||
#endif /* RT_USING_SAL */
|
#endif /* RT_USING_SAL */
|
||||||
|
@ -50,6 +54,139 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef signed char int8;
|
||||||
|
typedef signed short int16;
|
||||||
|
typedef signed int int32;
|
||||||
|
typedef unsigned char uint8;
|
||||||
|
typedef unsigned short uint16;
|
||||||
|
typedef unsigned int uint32;
|
||||||
|
|
||||||
|
#ifdef ARCH_CPU_64BIT
|
||||||
|
typedef signed long int64;
|
||||||
|
typedef unsigned long uint64;
|
||||||
|
#else
|
||||||
|
typedef signed long long int64;
|
||||||
|
typedef unsigned long long uint64;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define OPE_INT 0x0000
|
||||||
|
#define OPE_CFG 0x0001
|
||||||
|
|
||||||
|
#define NAME_NUM_MAX 32
|
||||||
|
|
||||||
|
/*********************GPIO define*********************/
|
||||||
|
#define GPIO_LOW 0x00
|
||||||
|
#define GPIO_HIGH 0x01
|
||||||
|
|
||||||
|
#define GPIO_CFG_OUTPUT 0x00
|
||||||
|
#define GPIO_CFG_INPUT 0x01
|
||||||
|
#define GPIO_CFG_INPUT_PULLUP 0x02
|
||||||
|
#define GPIO_CFG_INPUT_PULLDOWN 0x03
|
||||||
|
#define GPIO_CFG_OUTPUT_OD 0x04
|
||||||
|
|
||||||
|
#define GPIO_CONFIG_MODE 0xffffffff
|
||||||
|
#ifndef SERIAL_RB_BUFSZ
|
||||||
|
#define SERIAL_RB_BUFSZ 128
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct PinDevIrq
|
||||||
|
{
|
||||||
|
int irq_mode;//< RISING/FALLING/HIGH/LOW
|
||||||
|
void (*hdr) (void *args);//< callback function
|
||||||
|
void *args;//< the params of callback function
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PinParam
|
||||||
|
{
|
||||||
|
int cmd;//< cmd:GPIO_CONFIG_MODE/GPIO_IRQ_REGISTER/GPIO_IRQ_FREE/GPIO_IRQ_DISABLE/GPIO_IRQ_ENABLE
|
||||||
|
long pin;//< pin number
|
||||||
|
int mode;//< pin mode: input/output
|
||||||
|
struct PinDevIrq irq_set;//< pin irq set
|
||||||
|
uint64_t arg;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PinStat
|
||||||
|
{
|
||||||
|
long pin;//< pin number
|
||||||
|
uint16_t val;//< pin level
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ExtSerialPortConfigure
|
||||||
|
{
|
||||||
|
PORT_CFG_INIT = 0,
|
||||||
|
PORT_CFG_PARITY_CHECK,
|
||||||
|
PORT_CFG_DISABLE,
|
||||||
|
PORT_CFG_DIV,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SerialDataCfg
|
||||||
|
{
|
||||||
|
uint32_t serial_baud_rate;
|
||||||
|
uint8_t serial_data_bits;
|
||||||
|
uint8_t serial_stop_bits;
|
||||||
|
uint8_t serial_parity_mode;
|
||||||
|
uint8_t serial_bit_order;
|
||||||
|
uint8_t serial_invert_mode;
|
||||||
|
uint16_t serial_buffer_size;
|
||||||
|
|
||||||
|
uint8_t ext_uart_no;
|
||||||
|
enum ExtSerialPortConfigure port_configure;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum IoctlDriverType
|
||||||
|
{
|
||||||
|
SERIAL_TYPE = 0,
|
||||||
|
SPI_TYPE,
|
||||||
|
I2C_TYPE,
|
||||||
|
PIN_TYPE,
|
||||||
|
DEFAULT_TYPE,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PrivIoctlCfg
|
||||||
|
{
|
||||||
|
enum IoctlDriverType ioctl_driver_type;
|
||||||
|
void *args;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**********************mutex**************************/
|
||||||
|
|
||||||
|
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);
|
||||||
|
int PrivMutexDelete(pthread_mutex_t *p_mutex);
|
||||||
|
int PrivMutexObtain(pthread_mutex_t *p_mutex);
|
||||||
|
int PrivMutexAbandon(pthread_mutex_t *p_mutex);
|
||||||
|
|
||||||
|
/*********************semaphore**********************/
|
||||||
|
|
||||||
|
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value);
|
||||||
|
int PrivSemaphoreDelete(sem_t *sem);
|
||||||
|
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime);
|
||||||
|
int PrivSemaphoreObtainNoWait(sem_t *sem);
|
||||||
|
int PrivSemaphoreAbandon(sem_t *sem);
|
||||||
|
int32_t PrivSemaphoreSetValue(int32_t sem, uint16_t val);
|
||||||
|
|
||||||
|
/*********************task**************************/
|
||||||
|
|
||||||
|
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||||
|
void *(*start_routine)(void *), void *arg);
|
||||||
|
int PrivTaskStartup(pthread_t *thread);
|
||||||
|
int PrivTaskDelete(pthread_t thread, int sig);
|
||||||
|
void PrivTaskQuit(void *value_ptr);
|
||||||
|
int PrivTaskDelay(int32_t ms);
|
||||||
|
|
||||||
|
/*********************driver*************************/
|
||||||
|
|
||||||
|
int PrivOpen(const char *path, int flags);
|
||||||
|
int PrivRead(int fd, void *buf, size_t len);
|
||||||
|
int PrivWrite(int fd, const void *buf, size_t len);
|
||||||
|
int PrivClose(int fd);
|
||||||
|
int PrivIoctl(int fd, int cmd, void *args);
|
||||||
|
|
||||||
|
/*********************memory***********************/
|
||||||
|
|
||||||
|
void *PrivMalloc(size_t size);
|
||||||
|
void *PrivRealloc(void *pointer, size_t size);
|
||||||
|
void *PrivCalloc(size_t count, size_t size);
|
||||||
|
void PrivFree(void *pointer);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -24,9 +24,8 @@
|
||||||
|
|
||||||
int sem_init(sem_t *sem, int pshared, unsigned int value)
|
int sem_init(sem_t *sem, int pshared, unsigned int value)
|
||||||
{
|
{
|
||||||
int32 ret = 0;
|
*sem = UserSemaphoreCreate(value);
|
||||||
ret = UserSemaphoreCreate(value);
|
if (*sem < 0) {
|
||||||
if (ret < 0) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
/*
|
||||||
|
* @Author: chunyexixiaoyu
|
||||||
|
* @Date: 2021-09-24 16:33:15
|
||||||
|
* @LastEditTime: 2021-09-24 15:48:30
|
||||||
|
* @LastEditors: Please set LastEditors
|
||||||
|
* @Description: In User Settings Edit
|
||||||
|
* @FilePath: \xiuos\Ubiquitous\RT_Thread\bsp\stm32f407-atk-coreboard\applications\main.c
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
|
@ -10,14 +19,27 @@
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#ifdef RT_USING_POSIX
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <dfs_poll.h>
|
||||||
|
#include <dfs_posix.h>
|
||||||
|
#include <dfs.h>
|
||||||
|
#ifdef RT_USING_POSIX_TERMIOS
|
||||||
|
#include <posix_termios.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LED0_PIN GET_PIN(F, 9)
|
#define LED0_PIN GET_PIN(F, 9)
|
||||||
|
extern int FrameworkInit();
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int count = 1;
|
int count = 1;
|
||||||
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
|
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
|
||||||
rt_thread_mdelay(100);
|
rt_thread_mdelay(100);
|
||||||
|
FrameworkInit();
|
||||||
printf("XIUOS stm32f4 build %s %s\n",__DATE__,__TIME__);
|
printf("XIUOS stm32f4 build %s %s\n",__DATE__,__TIME__);
|
||||||
while (count++)
|
while (count++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue