Browse Source

add APP_Framework/Framework/connection function

pull/3/head
Liu_Weichao 1 year ago
parent
commit
86ef526303
  1. 4
      APP_Framework/Applications/framework_init.c
  2. 1
      APP_Framework/Framework/Kconfig
  3. 6
      APP_Framework/Framework/Makefile
  4. 3
      APP_Framework/Framework/connection/Kconfig
  5. 120
      APP_Framework/Framework/connection/adapter.c
  6. 5
      APP_Framework/Framework/connection/adapter.h
  7. 4
      APP_Framework/Framework/sensor/Kconfig
  8. 4
      Ubiquitous/XiUOS/kernel/memory/byte_manage.c
  9. 4
      Ubiquitous/XiUOS/path_app.mk
  10. 4
      Ubiquitous/XiUOS/path_kernel.mk

4
APP_Framework/Applications/framework_init.c

@ -50,7 +50,7 @@ static int AppInitDesc(struct InitDesc sub_desc[])
static struct InitDesc framework[] =
{
#ifdef SENSOR_SENSORDEVICE
#ifdef SUPPORT_SENSOR_FRAMEWORK
{ "perception_framework", SensorFrameworkInit },
#endif
@ -150,7 +150,7 @@ static int ConnectionFrameworkInit(struct InitDesc sub_desc[])
*/
int FrameworkInit()
{
#ifdef SENSOR_SENSORDEVICE
#ifdef SUPPORT_SENSOR_FRAMEWORK
PerceptionFrameworkInit(framework);
#endif

1
APP_Framework/Framework/Kconfig

@ -17,5 +17,6 @@ config TRANSFORM_LAYER_ATTRIUBUTE
source "$APP_DIR/Framework/sensor/Kconfig"
source "$APP_DIR/Framework/connection/Kconfig"
source "$APP_DIR/Framework/know/tflite_sin/Kconfig"
source "$APP_DIR/Framework/know/tflite_mnist/Kconfig"

6
APP_Framework/Framework/Makefile

@ -1,8 +1,12 @@
SRC_DIR := transform_layer
ifeq ($(CONFIG_SENSOR_SENSORDEVICE),y)
ifeq ($(CONFIG_SUPPORT_SENSOR_FRAMEWORK),y)
SRC_DIR += sensor
endif
ifeq ($(CONFIG_SUPPORT_CONNECTION_FRAMEWORK),y)
SRC_DIR += connection
endif
include $(KERNEL_ROOT)/compiler.mk

3
APP_Framework/Framework/connection/Kconfig

@ -0,0 +1,3 @@
menuconfig SUPPORT_CONNECTION_FRAMEWORK
bool "support connection framework"
default n

120
APP_Framework/Framework/connection/adapter.c

@ -20,7 +20,7 @@
#include <adapter.h>
static DoubleLinklistType adapter_list;
static DoublelistType adapter_list;
static int adapter_list_lock;
@ -30,9 +30,13 @@ static int adapter_list_lock;
*/
int AdapterFrameworkInit(void)
{
InitDoubleLinkList(&adapter_list);
int ret = 0;
AppInitDoubleList(&adapter_list);
adapter_list_lock = KMutexCreate();
ret = PrivMutexCreate(&adapter_list_lock, 0);
if(ret < 0) {
printf("AdapterFrameworkInit mutex create failed.\n");
}
return 0;
}
@ -42,24 +46,24 @@ int AdapterFrameworkInit(void)
* @param name - name string
* @return adapter device pointer
*/
struct Adapter *AdapterDeviceFind(const char *name)
struct Adapter *AdapterDeviceFindByName(const char *name)
{
struct Adapter *ret = NULL;
struct SysDoubleLinklistNode *node;
struct DoublelistNode *node;
if (name == NULL)
if (NULL == name)
return NULL;
UserMutexObtain(adapter_list_lock, -1);
DOUBLE_LINKLIST_FOR_EACH(node, &adapter_list) {
struct Adapter *adapter =CONTAINER_OF(node,
PrivMutexObtain(&adapter_list_lock);
DOUBLE_LIST_FOR_EACH(node, &adapter_list) {
struct Adapter *adapter = CONTAINER_OF(node,
struct Adapter, link);
if (strncmp(adapter->name, name, NAME_NUM_MAX) == 0) {
if (0 == strncmp(adapter->name, name, NAME_NUM_MAX)) {
ret = adapter;
break;
}
}
UserMutexAbandon(adapter_list_lock);
PrivMutexAbandon(&adapter_list_lock);
return ret;
}
@ -71,17 +75,17 @@ struct Adapter *AdapterDeviceFind(const char *name)
*/
int AdapterDeviceRegister(struct Adapter *adapter)
{
if (adapter == NULL)
if (NULL == adapter )
return -1;
if (AdapterDeviceFindByName(adapter->name) != NULL) {
if (NULL != AdapterDeviceFindByName(adapter->name)) {
printf("%s: sensor with the same name already registered\n", __func__);
return -1;
}
UserMutexObtain(adapter_list_lock, -1);
DoubleLinkListInsertNodeAfter(&adapter_list, &adapter->link);
UserMutexAbandon(adapter_list_lock);
PrivMutexObtain(&adapter_list_lock);
AppDoubleListInsertNodeAfter(&adapter_list, &adapter->link);
PrivMutexAbandon(&adapter_list_lock);
return 0;
}
@ -95,9 +99,9 @@ int AdapterDeviceUnregister(struct Adapter *adapter)
{
if (!adapter)
return -1;
UserMutexObtain(adapter_list, -1);
DoubleLinkListRmNode(&adapter->link);
UserMutexAbandon(adapter_list);
PrivMutexObtain(&adapter_list_lock);
AppDoubleListRmNode(&adapter->link);
PrivMutexAbandon(&adapter_list_lock);
return 0;
}
@ -121,11 +125,11 @@ int AdapterDeviceOpen(struct Adapter *adapter)
{
case PRIVATE_PROTOCOL:
priv_done = (struct PrivProtocolDone *)adapter->done;
if (priv_done->open == NULL)
if (NULL == priv_done->open)
return 0;
result = priv_done->open(adapter);
if (result == 0) {
if (0 == result) {
printf("Device %s open success.\n", adapter->name);
}else{
if (adapter->fd) {
@ -138,11 +142,11 @@ int AdapterDeviceOpen(struct Adapter *adapter)
case IP_PROTOCOL:
ip_done = (struct IpProtocolDone *)adapter->done;
if (ip_done->open == NULL)
if (NULL == ip_done->open)
return 0;
result = ip_done->open(adapter);
if (result == 0) {
if (0 == result) {
printf("Device %s open success.\n", adapter->name);
}else{
if (adapter->fd) {
@ -179,11 +183,11 @@ int AdapterDeviceClose(struct Adapter *adapter)
{
case PRIVATE_PROTOCOL:
priv_done = (struct PrivProtocolDone *)adapter->done;
if (priv_done->close == NULL)
if (NULL == priv_done->close)
return 0;
result = priv_done->close(adapter);
if (result == 0)
if (0 == result)
printf("%s successfully closed.\n", adapter->name);
else
printf("Closed %s failure.\n", adapter->name);
@ -192,11 +196,11 @@ int AdapterDeviceClose(struct Adapter *adapter)
case IP_PROTOCOL:
ip_done = (struct IpProtocolDone *)adapter->done;
if (ip_done->close == NULL)
if (NULL == ip_done->close)
return 0;
result = ip_done->close(adapter);
if (result == 0)
if (0 == result)
printf("%s successfully closed.\n", adapter->name);
else
printf("Closed %s failure.\n", adapter->name);
@ -221,10 +225,24 @@ ssize_t AdapterDeviceRead(struct Adapter *adapter, void *dst, size_t len)
if (!adapter)
return -1;
if (adapter->done->read == NULL)
return -1;
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
struct PrivProtocolDone *priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->recv)
return -1;
return adapter->done->read(adapter, dst, len);
return priv_done->recv(adapter, dst, len);
} else if (IP_PROTOCOL == adapter->net_protocol) {
struct IpProtocolDone *ip_done = (struct IpProtocolDone *)adapter->done;
if (NULL == ip_done->recv)
return -1;
return ip_done->recv(adapter->socket, dst, len);
} else {
printf("AdapterDeviceRead net_protocol %d not support\n", adapter->net_protocol);
return -1;
}
}
/**
@ -239,10 +257,24 @@ ssize_t AdapterDeviceWrite(struct Adapter *adapter, const void *src, size_t len)
if (!adapter)
return -1;
if (adapter->done->write == NULL)
return -1;
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
struct PrivProtocolDone *priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->send)
return -1;
return priv_done->send(adapter, src, len);
} else if (IP_PROTOCOL == adapter->net_protocol) {
struct IpProtocolDone *ip_done = (struct IpProtocolDone *)adapter->done;
if (NULL == ip_done->send)
return -1;
return adapter->done->write(adapter, src, len);
return ip_done->send(adapter->socket, src, len);
} else {
printf("AdapterDeviceWrite net_protocol %d not support\n", adapter->net_protocol);
return -1;
}
}
/**
@ -256,9 +288,23 @@ int AdapterDeviceControl(struct Adapter *adapter, int cmd, void *args)
{
if (!adapter)
return -1;
if (adapter->done->ioctl == NULL)
return -1;
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
struct PrivProtocolDone *priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->ioctl)
return -1;
return priv_done->ioctl(adapter, cmd, args);
} else if (IP_PROTOCOL == adapter->net_protocol) {
struct IpProtocolDone *ip_done = (struct IpProtocolDone *)adapter->done;
if (NULL == ip_done->ioctl)
return -1;
return adapter->done->ioctl(adapter, cmd, args);
return ip_done->ioctl(adapter, cmd, args);
} else {
printf("AdapterDeviceControl net_protocol %d not support\n", adapter->net_protocol);
return -1;
}
}

5
APP_Framework/Framework/connection/adapter.h

@ -23,6 +23,8 @@
#include <list.h>
#include <transform.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <sys/types.h>
@ -106,6 +108,7 @@ struct Adapter
int fd;
struct AdapterProductInfo *info;
struct Socket *socket;
enum NetProtocolType net_protocol;
enum NetRoleType net_role;
@ -114,7 +117,7 @@ struct Adapter
void *done;
struct SysDoubleLinklistNode link;
struct DoublelistNode link;
};
#endif

4
APP_Framework/Framework/sensor/Kconfig

@ -1,8 +1,8 @@
menuconfig SENSOR_SENSORDEVICE
menuconfig SUPPORT_SENSOR_FRAMEWORK
bool "support sensor framework"
default y
if SENSOR_SENSORDEVICE
if SUPPORT_SENSOR_FRAMEWORK
menuconfig SENSOR_CO2
bool "Using CO2 sensor device"
default n

4
Ubiquitous/XiUOS/kernel/memory/byte_manage.c

@ -953,11 +953,7 @@ void *x_umalloc(x_size_t size)
lock = CriticalAreaLock();
/* alignment */
size = ALIGN_MEN_UP(size, MEM_ALIGN_SIZE);
<<<<<<< HEAD
ret = UserByteManager.dynamic_buddy_manager.done->malloc(&UserByteManager.dynamic_buddy_manager,size, DYNAMIC_BLOCK_NO_EXTMEM_MASK);
=======
ret = UserByteManager.dynamic_buddy_manager.done->malloc(&UserByteManager.dynamic_buddy_manager,size,DYNAMIC_BLOCK_NO_EXTMEM_MASK);
>>>>>>> 0ddb5bfd1f2d80ec762bd2627d04c60da063e9fc
if(ret != NONE)
CHECK(UserByteManager.dynamic_buddy_manager.done->JudgeLegal(&UserByteManager.dynamic_buddy_manager, ret - SIZEOF_DYNAMICALLOCNODE_MEM));

4
Ubiquitous/XiUOS/path_app.mk

@ -11,6 +11,10 @@ APPPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/transform_layer/xiuos
-I$(KERNEL_ROOT)/../../APP_Framework/Framework/transform_layer/xiuos/user_api/posix_support/include #
endif
ifeq ($(CONFIG_SUPPORT_CONNECTION_FRAMEWORK), y)
APPPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/connection #
endif
COMPILE_APP:
@$(eval CPPPATHS=$(APPPATHS))
@echo $(SRC_APP_DIR)

4
Ubiquitous/XiUOS/path_kernel.mk

@ -166,8 +166,8 @@ KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/sensor #
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/transform_layer/xiuos #
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/general_functions/list #
ifeq ($(CONFIG_CONNECTION_ADAPTER), y)
KERNELPATHS += -I$(KERNEL_ROOT)/framework/connection/Adapter/include #
ifeq ($(CONFIG_SUPPORT_CONNECTION_FRAMEWORK), y)
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/connection #
endif
ifeq ($(CONFIG_CRYPTO), y)

Loading…
Cancel
Save