forked from xuos/xiuos
Compare commits
278 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
fe97465d4c | |
|
|
5b692bd0a5 | |
|
|
a110ab511c | |
|
|
0788041dcc | |
|
|
93a8685c31 | |
|
|
ad944a88d7 | |
|
|
089f9c8975 | |
|
|
4e5e123799 | |
|
|
65220e5aa7 | |
|
|
13432d41c6 | |
|
|
ffeaf4771e | |
|
|
d90f3e5dac | |
|
|
a9c7733e1e | |
|
|
a656ffaa66 | |
|
|
b97b9c49cd | |
|
|
12c24ddc73 | |
|
|
39c8ee354b | |
|
|
65603817a4 | |
|
|
d3df1f97ef | |
|
|
012111c2cc | |
|
|
872aba7ccd | |
|
|
87dc5269ee | |
|
|
48decbe80f | |
|
|
9109db0d94 | |
|
|
e0bc75c405 | |
|
|
d6ff73acab | |
|
|
2532ae43d4 | |
|
|
b825fd7f84 | |
|
|
813ca3dd20 | |
|
|
d471bc04db | |
|
|
2df93dc327 | |
|
|
078f4babf1 | |
|
|
33abc16c67 | |
|
|
4b40ae19dc | |
|
|
b37885b839 | |
|
|
042a51dc36 | |
|
|
fb27201603 | |
|
|
0ecb29c887 | |
|
|
af665f9f29 | |
|
|
7b33905b3e | |
|
|
2ec0e796fe | |
|
|
e231a29f5a | |
|
|
4f72b78b96 | |
|
|
8ae4bce9a5 | |
|
|
20d9a52bdb | |
|
|
b38e5c1c5c | |
|
|
54d6c01868 | |
|
|
84f78b6435 | |
|
|
a894bc8940 | |
|
|
3d16b694dd | |
|
|
cfadebc3e8 | |
|
|
6074b2b147 | |
|
|
692e010e0d | |
|
|
8bc7546828 | |
|
|
c63301a870 | |
|
|
94c6631a24 | |
|
|
dc5537a64f | |
|
|
2b3f3de22e | |
|
|
a9deff5cd0 | |
|
|
bbb8dd75f8 | |
|
|
198fabf970 | |
|
|
5677cd0768 | |
|
|
0c45a736d3 | |
|
|
3d9160fa44 | |
|
|
6b41cdbcfe | |
|
|
ba7e1a0d3b | |
|
|
0a58099c51 | |
|
|
f0240eb702 | |
|
|
2db9716cc0 | |
|
|
640c5e6f59 | |
|
|
e6390ecf73 | |
|
|
84f453d4ac | |
|
|
f33c50b97e | |
|
|
cc8f577ba4 | |
|
|
85105cb65d | |
|
|
d615793063 | |
|
|
3819716568 | |
|
|
60e1c1bf8f | |
|
|
669ef1eb2b | |
|
|
95b049e636 | |
|
|
a3377c21b6 | |
|
|
8a589d0eaa | |
|
|
58057e0b5e | |
|
|
08388f1b11 | |
|
|
0a3ba23753 | |
|
|
0a71b8b62a | |
|
|
cf1d5a234b | |
|
|
83d383feab | |
|
|
47cea831ba | |
|
|
a4eec2646d | |
|
|
4db0c44434 | |
|
|
1776223332 | |
|
|
79edaf3d17 | |
|
|
5e499bf975 | |
|
|
d797a999ae | |
|
|
a16223f850 | |
|
|
abba2ce735 | |
|
|
419b53594f | |
|
|
179c894840 | |
|
|
5ae31a37f3 | |
|
|
195e0085db | |
|
|
4b0783ab07 | |
|
|
27ad06f4c1 | |
|
|
0996e47b88 | |
|
|
d7e72942b5 | |
|
|
779444f998 | |
|
|
35dc835d12 | |
|
|
918b3663b8 | |
|
|
eed171df2a | |
|
|
9b3c321150 | |
|
|
a286b2292f | |
|
|
1655d28d63 | |
|
|
5dc639a133 | |
|
|
bebc65607e | |
|
|
7fee9d9e9f | |
|
|
10c39d930c | |
|
|
73fbeea117 | |
|
|
e0c9761f75 | |
|
|
002325c1d8 | |
|
|
1b73886dbc | |
|
|
572cbd201a | |
|
|
0ebfda21f7 | |
|
|
3a5d63762b | |
|
|
3950a6ec28 | |
|
|
ba51d8ba8e | |
|
|
c88ce9d708 | |
|
|
bfe1e72378 | |
|
|
e6fa8a2603 | |
|
|
732320f5c9 | |
|
|
3a6b5d7f4f | |
|
|
8632d37d14 | |
|
|
bcb5e48d6a | |
|
|
d2e6719a0e | |
|
|
f55da28789 | |
|
|
b2de31844a | |
|
|
a590d902f5 | |
|
|
60dbe78045 | |
|
|
ff78fcc100 | |
|
|
aea6a4f63e | |
|
|
d1da6ae35b | |
|
|
df2a1043df | |
|
|
d144306f76 | |
|
|
55654af275 | |
|
|
fb11970cab | |
|
|
806492e271 | |
|
|
8001b07341 | |
|
|
c621db2ca7 | |
|
|
f8b845ca62 | |
|
|
9ad282c39e | |
|
|
a4e37b962f | |
|
|
e4742a480c | |
|
|
6b091797ae | |
|
|
e37d8ed7d1 | |
|
|
1a0880c3f2 | |
|
|
6010fe5654 | |
|
|
a7bdd89097 | |
|
|
32bf012d9a | |
|
|
ce60710fe6 | |
|
|
9f6419e5f6 | |
|
|
4edf73254e | |
|
|
b933e0decb | |
|
|
0b5c6b0f9f | |
|
|
6b4097b941 | |
|
|
d57552e223 | |
|
|
4f7f98b0e9 | |
|
|
27cc89bcef | |
|
|
38c4419ef9 | |
|
|
bc014769f5 | |
|
|
4e1bc3bf04 | |
|
|
5761bd0916 | |
|
|
186790f5ec | |
|
|
1864f39dd2 | |
|
|
59fa5451ca | |
|
|
5a64507a84 | |
|
|
56a014fe98 | |
|
|
9b334f90e0 | |
|
|
6a89a12c49 | |
|
|
04dc796f95 | |
|
|
a3094c1dd6 | |
|
|
2df54e7f41 | |
|
|
6ef80903ce | |
|
|
4f85bc91e5 | |
|
|
5622be48ac | |
|
|
669b7f427e | |
|
|
b20f041722 | |
|
|
e802403362 | |
|
|
19b16f7729 | |
|
|
465241e569 | |
|
|
dc8244cc5d | |
|
|
d0902ca37f | |
|
|
6fa996d132 | |
|
|
a782b53423 | |
|
|
5a3954b726 | |
|
|
0b49dd1a3c | |
|
|
9b83bc586e | |
|
|
2757649473 | |
|
|
100fe8c2d0 | |
|
|
4fd39c0dd7 | |
|
|
d8ac0998b2 | |
|
|
f1029b81c3 | |
|
|
1f97dd3d77 | |
|
|
e5bf0cee41 | |
|
|
d845bd61b6 | |
|
|
334d5f1eee | |
|
|
0125fdf0ef | |
|
|
22e35a70aa | |
|
|
8583ea25b6 | |
|
|
ba31c9e0f8 | |
|
|
f4b21208e8 | |
|
|
2a01ff712d | |
|
|
bc47ae644f | |
|
|
31189c2939 | |
|
|
1061ce4dff | |
|
|
c1976c8d92 | |
|
|
0d93a91829 | |
|
|
7145cd6920 | |
|
|
2a8a11849d | |
|
|
49df162734 | |
|
|
5560fc5318 | |
|
|
987fd6c798 | |
|
|
ebc61431bd | |
|
|
7c252bda56 | |
|
|
e31199a104 | |
|
|
68cdcbdcce | |
|
|
06ed03337a | |
|
|
72e09d82e7 | |
|
|
164614a75a | |
|
|
75259c4006 | |
|
|
992b8f62ab | |
|
|
afc27bce65 | |
|
|
96baeb9482 | |
|
|
2a07e463f6 | |
|
|
629e8893e3 | |
|
|
f22fbc3c94 | |
|
|
14f0e442ad | |
|
|
32c8701391 | |
|
|
452699ac02 | |
|
|
77bae67322 | |
|
|
02cbcf2b23 | |
|
|
2bfd6c9aaa | |
|
|
8bb59ddf3a | |
|
|
8c929ba701 | |
|
|
e7175c2745 | |
|
|
e746639f8a | |
|
|
d89e018d33 | |
|
|
c7c7e700ca | |
|
|
5d6aa56f29 | |
|
|
00b39cdd55 | |
|
|
b8cf052d49 | |
|
|
d3836f1a6f | |
|
|
33984d8872 | |
|
|
2bc1de068c | |
|
|
4f15f1e70b | |
|
|
d6495c03d2 | |
|
|
696c9f6fe0 | |
|
|
9a818b1ef4 | |
|
|
b5e08c5d43 | |
|
|
636f803b7b | |
|
|
51ebd8f604 | |
|
|
5f4922866e | |
|
|
d0e42a9b51 | |
|
|
107913cb61 | |
|
|
7361d1c65f | |
|
|
9965ce4c43 | |
|
|
a39bc41597 | |
|
|
3352d4be6b | |
|
|
485555b3a2 | |
|
|
0bb057c642 | |
|
|
0504cf0e48 | |
|
|
234f4fc2ed | |
|
|
2d7d5d121d | |
|
|
7a8766a74d | |
|
|
e26c93a666 | |
|
|
9802c89fd6 | |
|
|
700a07bc84 | |
|
|
37bdc4a33f | |
|
|
c612502cdc | |
|
|
012fc146cc |
|
|
@ -1,24 +1,31 @@
|
|||
[submodule "Ubiquitous/RT-Thread_Fusion_XiUOS/rt-thread"]
|
||||
path = Ubiquitous/RT-Thread_Fusion_XiUOS/rt-thread
|
||||
url = https://code.gitlink.org.cn/chunyexixiaoyu/rt-thread.git
|
||||
url = https://www.gitlink.org.cn/chunyexixiaoyu/rt-thread.git
|
||||
[submodule "Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/kendryte-sdk/kendryte-sdk-source"]
|
||||
path = Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/kendryte-sdk/kendryte-sdk-source
|
||||
url = https://code.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
|
||||
url = https://www.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
|
||||
[submodule "Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/kendryte-sdk/kendryte-sdk-source"]
|
||||
path = Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/kendryte-sdk/kendryte-sdk-source
|
||||
url = https://code.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
|
||||
url = https://www.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
|
||||
[submodule "Ubiquitous/XiZi/fs/lwext4/lwext4_submodule"]
|
||||
path = Ubiquitous/XiZi/fs/lwext4/lwext4_submodule
|
||||
url = https://gitlink.org.cn/xuos/lwext4_filesystem_support_XiUOS.git
|
||||
[submodule "Ubiquitous/Nuttx_Fusion_XiUOS/nuttx"]
|
||||
path = Ubiquitous/Nuttx_Fusion_XiUOS/nuttx
|
||||
url = https://code.gitlink.org.cn/wgzAIIT/incubator-nuttx.git
|
||||
url = https://www.gitlink.org.cn/wgzAIIT/incubator-nuttx.git
|
||||
[submodule "Ubiquitous/Nuttx_Fusion_XiUOS/apps"]
|
||||
path = Ubiquitous/Nuttx_Fusion_XiUOS/apps
|
||||
url = https://code.gitlink.org.cn/wgzAIIT/incubator-nuttx-apps.git
|
||||
url = https://www.gitlink.org.cn/wgzAIIT/incubator-nuttx-apps.git
|
||||
[submodule "APP_Framework/Applications/webnet/WebNet_XiUOS"]
|
||||
path = APP_Framework/Applications/webnet/WebNet_XiUOS
|
||||
url = https://gitlink.org.cn/xuos/WebNet_XiUOS.git
|
||||
[submodule "Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/kendryte-sdk/kendryte-sdk-source"]
|
||||
path = Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/kendryte-sdk/kendryte-sdk-source
|
||||
url = https://code.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
|
||||
url = https://www.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
|
||||
[submodule "APP_Framework/lib/lorawan/lora_radio_driver"]
|
||||
path = APP_Framework/lib/lorawan/lora_radio_driver
|
||||
url = https://gitlink.org.cn/IACU/lora_radio_driver.git
|
||||
[submodule "APP_Framework/lib/lorawan/lorawan_devicenode"]
|
||||
path = APP_Framework/lib/lorawan/lorawan_devicenode
|
||||
url = https://gitlink.org.cn/IACU/lorawan_devicenode.git
|
||||
branch = master
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
# APP_Framework/Applications/Make.defs
|
||||
############################################################################
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list
|
||||
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ include $(KERNEL_ROOT)/.config
|
|||
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += framework_init.c
|
||||
CSRCS +=
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
|
|
@ -10,9 +10,10 @@ endif
|
|||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_DIR := general_functions app_test
|
||||
|
||||
SRC_FILES := main.c framework_init.c
|
||||
SRC_FILES := main.c
|
||||
ifeq ($(CONFIG_LIB_LV),y)
|
||||
SRC_DIR += lv_app
|
||||
SRC_DIR += tinyttf_app
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_OTA),y)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,179 @@ menu "test app"
|
|||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_FS
|
||||
bool "Config test fs with sd or usb"
|
||||
default n
|
||||
if USER_TEST_FS
|
||||
if ADD_XIZI_FETURES
|
||||
config FPATH
|
||||
string "Set test file path"
|
||||
default "/test_file"
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
menuconfig USER_TEST_GPIO
|
||||
select BSP_USING_GPIO
|
||||
select RESOURCES_PIN
|
||||
select BSP_USING_LED
|
||||
select BSP_USING_KEY
|
||||
bool "Config test gpio with led and key"
|
||||
default n
|
||||
if USER_TEST_GPIO
|
||||
if ADD_XIZI_FETURES
|
||||
config GPIO_DEV_DRIVER
|
||||
string "Set gpio dev path"
|
||||
default "/dev/pin_dev"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_LORA
|
||||
select BSP_USING_UART
|
||||
select BSP_USING_GPIO
|
||||
select RESOURCES_PIN
|
||||
select BSP_USING_UART2
|
||||
select BSP_USING_LORA
|
||||
bool "Config test uart(loraE220)"
|
||||
default n
|
||||
if USER_TEST_LORA
|
||||
if ADD_XIZI_FETURES
|
||||
config LORA_UART_DEV_DRIVER
|
||||
string "Set uart dev path"
|
||||
default "/dev/uart2_dev2"
|
||||
config LORA_PIN_DEV_DRIVER
|
||||
string "Set pin dev path"
|
||||
default "/dev/pin_dev"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_RS485
|
||||
select BSP_USING_UART
|
||||
select BSP_USING_GPIO
|
||||
select RESOURCES_PIN
|
||||
select BSP_USING_UART1
|
||||
bool "Config test uart(RS485)"
|
||||
default n
|
||||
if USER_TEST_RS485
|
||||
if ADD_XIZI_FETURES
|
||||
config RS485_UART_DEV_DRIVER
|
||||
string "Set uart dev path"
|
||||
default "/dev/uart1_dev1"
|
||||
config RS485_PIN_DEV_DRIVER
|
||||
string "Set pin dev path"
|
||||
default "/dev/pin_dev"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_RTC
|
||||
select BSP_USING_RTC
|
||||
bool "Config test rtc"
|
||||
default n
|
||||
if USER_TEST_RTC
|
||||
if ADD_XIZI_FETURES
|
||||
config RTC_DEV_DRIVER
|
||||
string "Set rtc dev path"
|
||||
default "/dev/rtc_dev"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_HWTIMER
|
||||
select BSP_USING_HWTIMER
|
||||
select BSP_USING_GPIO
|
||||
select RESOURCES_PIN
|
||||
select BSP_USING_LED
|
||||
bool "Config test hwtimer"
|
||||
default n
|
||||
if USER_TEST_HWTIMER
|
||||
if ADD_XIZI_FETURES
|
||||
config HWTIMER_TIMER_DEV_DRIVER
|
||||
string "Set pin dev path"
|
||||
default "/dev/timer0_dev0"
|
||||
config HWTIMER_PIN_DEV_DRIVER
|
||||
string "Set pin dev path"
|
||||
default "/dev/pin_dev"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_WDT
|
||||
select BSP_USING_WDT0
|
||||
bool "Config test watchdog"
|
||||
default n
|
||||
if USER_TEST_WDT
|
||||
if ADD_XIZI_FETURES
|
||||
config WDT0_DEV_DRIVER
|
||||
string "Set wdt dev path"
|
||||
default "/dev/wdt0_dev0"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_LCD_EDU
|
||||
select BSP_USING_LCD
|
||||
bool "Config test lcd in PrivOpen"
|
||||
default n
|
||||
if USER_TEST_LCD_EDU
|
||||
if ADD_XIZI_FETURES
|
||||
config EDU_LCD_DEV_DRIVER
|
||||
string "Set lcd dev path"
|
||||
default "/dev/lcd_dev"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_TOUCH
|
||||
select BSP_USING_TOUCH
|
||||
bool "Config test touch"
|
||||
default n
|
||||
if USER_TEST_TOUCH
|
||||
if ADD_XIZI_FETURES
|
||||
config TOUCH_DEV_DRIVER
|
||||
string "Set touch dev path"
|
||||
default "/dev/touch_dev"
|
||||
config TOUCH_LCD_DEV_DRIVER
|
||||
string "Set lcd dev path"
|
||||
default "/dev/lcd_dev"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_I2C
|
||||
select BSP_USING_I2C
|
||||
bool "Config test i2c"
|
||||
default n
|
||||
if USER_TEST_I2C
|
||||
if ADD_XIZI_FETURES
|
||||
config I2C_DEV_DRIVER
|
||||
string "Set i2c dev path"
|
||||
default "/dev/i2c1_dev0"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_CAN
|
||||
select BSP_USING_CAN
|
||||
bool "Config test can"
|
||||
default n
|
||||
if USER_TEST_CAN
|
||||
if ADD_XIZI_FETURES
|
||||
config CAN_DEV_DRIVER
|
||||
string "Set can dev path"
|
||||
default "/dev/can2_dev1"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_CAMERA
|
||||
select BSP_USING_CAMERA
|
||||
select BSP_USING_LCD
|
||||
bool "Config test camera with lcd"
|
||||
default n
|
||||
if USER_TEST_CAMERA
|
||||
if ADD_XIZI_FETURES
|
||||
config CAMERA_DEV_DRIVER
|
||||
string "Set camera dev path"
|
||||
default "/dev/camera_dev"
|
||||
config CAMERA_LCD_DEV_DRIVER
|
||||
string "Set lcd dev path"
|
||||
default "/dev/lcd_dev"
|
||||
endif
|
||||
endif
|
||||
|
||||
config USER_TEST_SEMC
|
||||
bool "Config test semc sdram"
|
||||
default n
|
||||
|
|
@ -33,5 +206,39 @@ menu "test app"
|
|||
config USER_TEST_LCD
|
||||
bool "Config test lcd device"
|
||||
default n
|
||||
|
||||
menuconfig USER_TEST_ETHERNET
|
||||
bool "Config test ethernet only for edu-riscv64"
|
||||
default n
|
||||
if USER_TEST_ETHERNET
|
||||
if ADD_XIZI_FETURES
|
||||
choice
|
||||
prompt "set ethernet role as client or server"
|
||||
default ETHERNET_AS_SERVER
|
||||
|
||||
config ETHERNET_AS_SERVER
|
||||
bool "test as server"
|
||||
|
||||
config ETHERNET_AS_CLIENT
|
||||
bool "test as client"
|
||||
endchoice
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_FLASH
|
||||
bool "Config test w25q128 device"
|
||||
default n
|
||||
if USER_TEST_FLASH
|
||||
if ADD_XIZI_FETURES
|
||||
config FLASH_DEV_DRIVER
|
||||
string "Set flash dev path"
|
||||
default "/dev/qspi_W25Q128"
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig USER_TEST_TIMER
|
||||
bool "Config test soft timer"
|
||||
default n
|
||||
|
||||
endif
|
||||
endmenu
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
|||
CSRCS += test_lcd.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BSP_USING_TOUCH),y)
|
||||
CSRCS += test_touch.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MUSL_LIBC),y)
|
||||
CSRCS += test_musl.c
|
||||
endif
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
endif
|
||||
|
|
@ -25,6 +33,10 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
|||
SRC_FILES += test_dac.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_FS),y)
|
||||
SRC_FILES += test_fs.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_SEMC),y)
|
||||
SRC_FILES += test_extsram.c
|
||||
endif
|
||||
|
|
@ -33,5 +45,61 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
|||
SRC_FILES +=
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_I2C),y)
|
||||
SRC_FILES += test_i2c.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_GPIO),y)
|
||||
SRC_FILES += test_gpio.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_LORA),y)
|
||||
SRC_FILES += test_loraE220.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_RTC),y)
|
||||
SRC_FILES += test_rtc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_RS485),y)
|
||||
SRC_FILES += test_rs485.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_HWTIMER),y)
|
||||
SRC_FILES += test_hwtimer.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_LCD_EDU),y)
|
||||
SRC_FILES += test_lcd_edu.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_WDT),y)
|
||||
SRC_FILES += test_wdt.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_TOUCH),y)
|
||||
SRC_FILES += test_touch.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_CAMERA),y)
|
||||
SRC_FILES += test_camera.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_ETHERNET),y)
|
||||
SRC_FILES += test_ethernet.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_FLASH),y)
|
||||
SRC_FILES += test_flash.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_CAN),y)
|
||||
SRC_FILES += test_can.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_TIMER),y)
|
||||
SRC_FILES += test_timer.c
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
void TestAdc(void)
|
||||
{
|
||||
|
|
@ -57,3 +58,4 @@ void TestAdc(void)
|
|||
return;
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* 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: test_camera.c
|
||||
* @brief: a application of camera function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/7
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
static uint16_t image_buff[384000];
|
||||
|
||||
void TestCamera(int argc, char *argv[])
|
||||
{
|
||||
int frame_counter = 10000;
|
||||
if (argc > 1)
|
||||
{
|
||||
frame_counter = atoi(argv[1]);
|
||||
}
|
||||
printf("This test will refresh %d frames\n", frame_counter);
|
||||
|
||||
int camera_fd = PrivOpen(CAMERA_DEV_DRIVER, O_RDWR);
|
||||
if (camera_fd < 0)
|
||||
{
|
||||
printf("open camera fd error:%d\n", camera_fd);
|
||||
return;
|
||||
}
|
||||
int lcd_fd = PrivOpen(CAMERA_LCD_DEV_DRIVER, O_RDWR);
|
||||
if (lcd_fd < 0)
|
||||
{
|
||||
printf("open lcd fd error:%d\n", lcd_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
//configure the camera's output address
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = CAMERA_TYPE;
|
||||
struct CameraCfg camera_cfg ={
|
||||
.gain_manu_enable = 0,
|
||||
.gain = 0xFF,
|
||||
.window_w = 800,
|
||||
.window_h = 600,
|
||||
.output_w = IMAGE_WIDTH,
|
||||
.output_h = IMAGE_HEIGHT,
|
||||
.window_xoffset = 0,
|
||||
.window_yoffset = 0
|
||||
};
|
||||
ioctl_cfg.args = &camera_cfg;
|
||||
if (0 != PrivIoctl(camera_fd, OPE_CFG, &ioctl_cfg))
|
||||
{
|
||||
printf("camera pin fd error %d\n", camera_fd);
|
||||
PrivClose(camera_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
ioctl_cfg.args = (void *)image_buff;
|
||||
|
||||
if (0 != PrivRead(camera_fd, image_buff, NULL_PARAMETER))
|
||||
{
|
||||
printf("camera pin fd error %d\n", camera_fd);
|
||||
PrivClose(camera_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("address buff is %x\n", image_buff);
|
||||
|
||||
|
||||
LcdWriteParam graph_param;
|
||||
graph_param.type = LCD_DOT_TYPE;
|
||||
|
||||
//clear the LCD
|
||||
uint16_t back_color[LCD_SIZE];
|
||||
memset(back_color,0,sizeof(back_color));
|
||||
for (int i = 0; i < LCD_SIZE; i++)
|
||||
{
|
||||
graph_param.pixel_info.pixel_color = &back_color;
|
||||
graph_param.pixel_info.x_startpos = 0;
|
||||
graph_param.pixel_info.y_startpos = i;
|
||||
graph_param.pixel_info.x_endpos = LCD_SIZE -1;
|
||||
graph_param.pixel_info.y_endpos = i;
|
||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||
}
|
||||
|
||||
//refresh the LCD using photo of camera
|
||||
while (frame_counter--)
|
||||
{
|
||||
for (int i = 0; i < IMAGE_HEIGHT; i++)
|
||||
{
|
||||
graph_param.pixel_info.pixel_color = image_buff + i * IMAGE_WIDTH;
|
||||
graph_param.pixel_info.x_startpos = 0;
|
||||
graph_param.pixel_info.y_startpos = i + (LCD_SIZE - IMAGE_HEIGHT) / 2;
|
||||
graph_param.pixel_info.x_endpos = IMAGE_WIDTH - 1;
|
||||
graph_param.pixel_info.y_endpos = i + (LCD_SIZE - IMAGE_HEIGHT) / 2;
|
||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||
}
|
||||
}
|
||||
|
||||
// close test
|
||||
PrivClose(lcd_fd);
|
||||
PrivClose(camera_fd);
|
||||
printf("The camera test is finished successfully\n");
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestCamera, a camera test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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: test_can.c
|
||||
* @brief: a application of can function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2023/2/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
|
||||
void TestCAN(void)
|
||||
{
|
||||
// config CAN pin(SCL:34.SDA:35) in menuconfig
|
||||
int can_fd = PrivOpen(CAN_DEV_DRIVER, O_RDWR);
|
||||
if (can_fd < 0)
|
||||
{
|
||||
printf("open can_fd fd error:%d\n", can_fd);
|
||||
return;
|
||||
}
|
||||
printf("CAN open successful!\n");
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = CAN_TYPE;
|
||||
|
||||
struct CanDriverConfigure can_config;
|
||||
can_config.brp = 8U;
|
||||
can_config.tbs1 = 1U + 8U;
|
||||
can_config.tbs2 = 4U;
|
||||
can_config.tsjw = 4U;
|
||||
can_config.mode = 0U;
|
||||
|
||||
ioctl_cfg.args = (void *)&can_config;
|
||||
|
||||
if (0 != PrivIoctl(can_fd, OPE_INT, &ioctl_cfg))
|
||||
{
|
||||
printf("init can fd error %d\n", can_fd);
|
||||
PrivClose(can_fd);
|
||||
return;
|
||||
}
|
||||
printf("CAN configure successful!\n");
|
||||
|
||||
uint8_t data_buff[64u] = {1,2,3,4,4,3,2,1};
|
||||
struct CanSendConfigure frame_send;
|
||||
frame_send.ide=0;
|
||||
frame_send.stdid = 0x55;
|
||||
frame_send.rtr=0;
|
||||
frame_send.data_lenth=8;
|
||||
frame_send.data = data_buff;
|
||||
|
||||
struct CanSendConfigure frame_recv;
|
||||
uint8_t recv_buff[65U] = {0};
|
||||
frame_recv.data = recv_buff;
|
||||
|
||||
// CAN write
|
||||
while (1)
|
||||
{
|
||||
PrivTaskDelay(500);
|
||||
PrivWrite(can_fd, &frame_send, NONE);
|
||||
PrivTaskDelay(500);
|
||||
PrivRead(can_fd, &frame_recv, NONE);
|
||||
// if any data has received,Then printf message
|
||||
if(frame_recv.data_lenth > 0){
|
||||
printf("ID %08x:%s\n",frame_recv.exdid,frame_recv.data);
|
||||
}
|
||||
}
|
||||
|
||||
PrivClose(can_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestCAN, a can test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -17,10 +17,10 @@
|
|||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/1/11
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
void TestDac(void)
|
||||
{
|
||||
|
|
@ -57,3 +57,4 @@ void TestDac(void)
|
|||
return;
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TestDac, a dac test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* 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: test_ethernet.c
|
||||
* @brief: a application of ethernet function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
#include <socket.h>
|
||||
|
||||
#define BUFF_SIZE 128
|
||||
#define RECV_SIZE 16
|
||||
#define TCP_PORT 12345
|
||||
|
||||
const static uint32_t sn = 0;
|
||||
|
||||
#ifdef ETHERNET_AS_SERVER
|
||||
static int32_t wiz_server_op(uint8_t sn, uint8_t *buf, uint32_t buf_size,
|
||||
uint16_t port, enum TCP_OPTION opt) {
|
||||
int32_t ret = 0;
|
||||
uint16_t size = 0, sentsize = 0;
|
||||
switch (getSn_SR(sn)) {
|
||||
case SOCK_ESTABLISHED:
|
||||
if (getSn_IR(sn) & Sn_IR_CON) {
|
||||
printf("%d:Connected\r\n", sn);
|
||||
setSn_IR(sn, Sn_IR_CON);
|
||||
}
|
||||
if (opt == SEND_DATA) {
|
||||
uint32_t sent_size = 0;
|
||||
memset(buf,0,buf_size);
|
||||
strcpy(buf,"The message has been recved");
|
||||
ret = wiz_sock_send(sn, buf, buf_size);
|
||||
if (ret < 0) {
|
||||
wiz_sock_close(sn);
|
||||
return ret;
|
||||
}
|
||||
} else if (opt == RECV_DATA) {
|
||||
uint32_t size = 0;
|
||||
if ((size = getSn_RX_RSR(sn)) > 0) {
|
||||
if (size > buf_size) size = buf_size;
|
||||
memset(buf,0,buf_size);
|
||||
ret = wiz_sock_recv(sn, buf, size);
|
||||
printf("Recv message: %s\n",buf);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SOCK_CLOSE_WAIT:
|
||||
printf("%d:CloseWait\r\n", sn);
|
||||
if ((ret = wiz_sock_disconnect(sn)) != SOCK_OK) return ret;
|
||||
printf("%d:Closed\r\n", sn);
|
||||
break;
|
||||
case SOCK_INIT:
|
||||
printf("%d:Listen, port [%d]\r\n", sn, port);
|
||||
if ((ret = wiz_sock_listen(sn)) != SOCK_OK) return ret;
|
||||
break;
|
||||
case SOCK_CLOSED:
|
||||
printf("%d:LBTStart\r\n", sn);
|
||||
if ((ret = wiz_socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret;
|
||||
printf("%d:Opened\r\n", sn);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TestSocketAsServer(int argc, char *argv[])
|
||||
{
|
||||
x_err_t ret;
|
||||
uint8_t buf[BUFF_SIZE] = {0};
|
||||
|
||||
while (1) {
|
||||
ret = wiz_server_op(0, buf, BUFF_SIZE, TCP_PORT, RECV_DATA);
|
||||
if (ret > 0) {
|
||||
wiz_server_op(0, buf, BUFF_SIZE, TCP_PORT, SEND_DATA);
|
||||
};
|
||||
}
|
||||
|
||||
return ;
|
||||
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestSocketAsServer, a w5500 server test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
#elif defined ETHERNET_AS_CLIENT
|
||||
|
||||
static uint32_t wiz_client_op(uint8_t sn, uint8_t *buf, uint32_t buf_size,
|
||||
uint8_t dst_ip[4], uint16_t dst_port,
|
||||
enum TCP_OPTION opt) {
|
||||
// assert(buf_size <= g_wiznet_buf_size);
|
||||
int32_t ret;
|
||||
switch (getSn_SR(sn)) {
|
||||
case SOCK_CLOSE_WAIT:
|
||||
wiz_sock_disconnect(sn);
|
||||
break;
|
||||
case SOCK_CLOSED:
|
||||
wiz_socket(sn, Sn_MR_TCP, 5000, 0x00);
|
||||
break;
|
||||
case SOCK_INIT:
|
||||
KPrintf("[SOCKET CLIENT] sock init.\n");
|
||||
wiz_sock_connect(sn, dst_ip, dst_port);
|
||||
break;
|
||||
case SOCK_ESTABLISHED:
|
||||
if (getSn_IR(sn) & Sn_IR_CON) {
|
||||
printf("[SOCKET CLIENT] %d:Connected\r\n", sn);
|
||||
setSn_IR(sn, Sn_IR_CON);
|
||||
}
|
||||
if (opt == SEND_DATA) {
|
||||
uint32_t sent_size = 0;
|
||||
ret = wiz_sock_send(sn, buf, buf_size);
|
||||
if (ret < 0) {
|
||||
wiz_sock_close(sn);
|
||||
return ret;
|
||||
}
|
||||
} else if (opt == RECV_DATA) {
|
||||
uint32_t size = 0;
|
||||
if ((size = getSn_RX_RSR(sn)) > 0) {
|
||||
if (size > buf_size) size = buf_size;
|
||||
ret = wiz_sock_recv(sn, buf, size);
|
||||
if (ret <= 0) return ret;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TestSocketAsClient(int argc, char *argv[])
|
||||
{
|
||||
x_err_t ret;
|
||||
uint8_t buf[BUFF_SIZE] = {0};
|
||||
uint32_t tmp_ip[4];
|
||||
uint32_t port;
|
||||
const uint8_t client_sock = 2;
|
||||
|
||||
if(argc<3){
|
||||
printf("Please enter command like TestSocketAsClient ip:port msg\n");
|
||||
}
|
||||
|
||||
sscanf(argv[1],"%d.%d.%d.%d:%d",tmp_ip,tmp_ip+1,tmp_ip+2,tmp_ip+3,&port);
|
||||
printf("Client to %d.%d.%d.%d:%d\n",tmp_ip[0],tmp_ip[1],tmp_ip[2],tmp_ip[3],port);
|
||||
uint8_t destination_ip[4]={0};
|
||||
for(int i=0;i<4;i++){
|
||||
destination_ip[i]=tmp_ip[i];
|
||||
}
|
||||
|
||||
while(1){
|
||||
ret = wiz_client_op(client_sock, argv[2], strlen(argv[2]), destination_ip, port,SEND_DATA);
|
||||
printf("sizeof:%d\n",strlen(argv[2]));
|
||||
PrivTaskDelay(1000);
|
||||
if (ret > 0) {
|
||||
ret=wiz_client_op(client_sock, buf, BUFF_SIZE, destination_ip, port, RECV_DATA);
|
||||
printf("read ret is %d\n",ret);
|
||||
if(ret>0){
|
||||
printf("client recv msg successfully!\n");
|
||||
printf("%s\n",buf);
|
||||
}
|
||||
};
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return ;
|
||||
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestSocketAsClient, a w5500 client-ip-port-msg test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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: test_flash.c
|
||||
* @brief: a application of flash function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
void TestFlash(void)
|
||||
{
|
||||
int fd = open(FLASH_DEV_DRIVER,O_RDWR);
|
||||
if(fd<0){
|
||||
printf("fs fd open error:%d\n",fd);
|
||||
return;
|
||||
}
|
||||
struct BusBlockWriteParam flash_writer;
|
||||
uint8_t read_buff[8] = {1,2,3,4,5,6,7,8};
|
||||
flash_writer.pos = 0x000000L;
|
||||
flash_writer.size = 8;
|
||||
flash_writer.buffer = read_buff;
|
||||
struct BusBlockReadParam flash_reader;
|
||||
flash_reader.pos = 0x000000L;
|
||||
flash_reader.size = 8;
|
||||
flash_reader.buffer = read_buff;
|
||||
|
||||
PrivRead(fd,&flash_reader,NONE);
|
||||
printf("Read data is:");
|
||||
for(int i=0;i<flash_writer.size;i++){
|
||||
printf("%02x ",read_buff[i]);
|
||||
read_buff[i]++;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
PrivWrite(fd,&flash_writer,NONE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestFlash, a flash test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* 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: test_fs.c
|
||||
* @brief: a application of file_system function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/11/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
#define MAX_READ_LENGTH 1000
|
||||
|
||||
// sd card here is loaded as "/"
|
||||
void TestFs(void)
|
||||
{
|
||||
//open the file in sdcard
|
||||
int fd = open(FPATH,O_RDWR|O_CREAT);
|
||||
if(fd<0){
|
||||
printf("fs fd open error:%d\n",fd);
|
||||
return;
|
||||
}
|
||||
|
||||
char filewords[MAX_READ_LENGTH];
|
||||
memset(filewords,0,MAX_READ_LENGTH);
|
||||
const char *input_words = "these words are going to write in fs\n";
|
||||
|
||||
//read and write then close file
|
||||
int err_flag = read(fd,filewords,MAX_READ_LENGTH);
|
||||
if(err_flag<0){
|
||||
printf("read failed,error:%d\n",err_flag);
|
||||
return;
|
||||
}
|
||||
printf("read data is \n%s\n",filewords);
|
||||
|
||||
err_flag = write(fd,input_words,strlen(input_words));
|
||||
if(err_flag<0){
|
||||
printf("write failed,error:%d\n",err_flag);
|
||||
return;
|
||||
}
|
||||
err_flag = close(fd);
|
||||
if(err_flag<0){
|
||||
printf("close failed,error %d\n",err_flag);
|
||||
return ;
|
||||
}
|
||||
|
||||
//re-open the file and re-read the file
|
||||
fd = open(FPATH,O_RDWR);
|
||||
if(fd<0){
|
||||
printf("fs fd open error:%d\n",fd);
|
||||
return;
|
||||
}
|
||||
err_flag = read(fd,filewords,MAX_READ_LENGTH);
|
||||
if(err_flag<0){
|
||||
printf("read failed,error:%d\n",err_flag);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("read data is \n%s\n",filewords);
|
||||
err_flag = close(fd);
|
||||
if(err_flag<0){
|
||||
printf("close failed,error:%d\n",err_flag);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestFs, a sd or usb filesystem test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* 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: test_gpio.c
|
||||
* @brief: a application of GPIO function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
#ifdef BOARD_EDU_RISCV64_EVB
|
||||
#define BSP_LED_PIN 29
|
||||
#define BSP_KEY_PIN 31
|
||||
#elif defined BOARD_HC32F4A0_EVB
|
||||
#define BSP_LED_PIN 134
|
||||
#define BSP_KEY_PIN 176
|
||||
#endif
|
||||
#define NULL_PARAMETER 0
|
||||
|
||||
void TestGpio(void)
|
||||
{
|
||||
int pin_fd = PrivOpen(GPIO_DEV_DRIVER, O_RDWR);
|
||||
if(pin_fd < 0) {
|
||||
printf("open pin fd error:%d\n",pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
//config led pin in board
|
||||
struct PinParam parameter;
|
||||
parameter.cmd = GPIO_CONFIG_MODE;
|
||||
parameter.pin = BSP_LED_PIN;
|
||||
parameter.mode = GPIO_CFG_OUTPUT;
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
|
||||
ioctl_cfg.args = (void *)¶meter;
|
||||
|
||||
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
|
||||
printf("ioctl pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
//config key pin in board
|
||||
parameter.pin = BSP_KEY_PIN;
|
||||
parameter.mode = GPIO_CFG_INPUT;
|
||||
|
||||
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
|
||||
printf("ioctl pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
struct PinStat pin_led;
|
||||
struct PinStat pin_key;
|
||||
|
||||
pin_led.pin = BSP_LED_PIN;
|
||||
pin_key.pin = BSP_KEY_PIN;
|
||||
|
||||
//recycle read pin and write pin until key break
|
||||
while(1){
|
||||
if(0 > PrivRead(pin_fd, &pin_key, NULL_PARAMETER)) {
|
||||
printf("read pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
//led on if key pressed,or led off
|
||||
if(pin_key.val){
|
||||
pin_led.val = GPIO_HIGH;
|
||||
}else{
|
||||
pin_led.val = GPIO_LOW;
|
||||
}
|
||||
|
||||
if(0 > PrivWrite(pin_fd, &pin_led, NULL_PARAMETER)) {
|
||||
printf("write pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestGpio, a gpio test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* 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: test_hwtimer.c
|
||||
* @brief: a application of hwtimer function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
#define BSP_LED_PIN 134
|
||||
#define NULL_PARAMETER 0
|
||||
|
||||
static uint16_t pin_fd=0;
|
||||
static struct PinStat pin_led;
|
||||
|
||||
void ledflip(void *parameter)
|
||||
{
|
||||
pin_led.pin = BSP_LED_PIN;
|
||||
pin_led.val = !pin_led.val;
|
||||
PrivWrite(pin_fd,&pin_led,NULL_PARAMETER);
|
||||
}
|
||||
|
||||
void TestHwTimer(void)
|
||||
{
|
||||
x_ticks_t period = 100000;
|
||||
|
||||
pin_fd = PrivOpen(HWTIMER_PIN_DEV_DRIVER, O_RDWR);
|
||||
if(pin_fd<0){
|
||||
printf("open pin fd error:%d\n",pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
int timer_fd = PrivOpen(HWTIMER_TIMER_DEV_DRIVER, O_RDWR);
|
||||
if(timer_fd<0){
|
||||
printf("open timer fd error:%d\n",timer_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
//config led pin in board
|
||||
struct PinParam parameter;
|
||||
parameter.cmd = GPIO_CONFIG_MODE;
|
||||
parameter.pin = BSP_LED_PIN;
|
||||
parameter.mode = GPIO_CFG_OUTPUT;
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
|
||||
ioctl_cfg.args = (void *)¶meter;
|
||||
|
||||
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
|
||||
printf("ioctl pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
ioctl_cfg.ioctl_driver_type = TIME_TYPE;
|
||||
ioctl_cfg.args = (void *)&ledflip;
|
||||
if (0 != PrivIoctl(timer_fd, OPE_INT, &ioctl_cfg)) {
|
||||
printf("timer pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
ioctl_cfg.args = (void *).
|
||||
if (0 != PrivIoctl(timer_fd, OPE_CFG, &ioctl_cfg)) {
|
||||
printf("timer pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
while(1){
|
||||
|
||||
}
|
||||
|
||||
// int32 timer_handle = KCreateTimer("LED on and off by 1s",&ledflip,&pin_fd,period,TIMER_TRIGGER_PERIODIC);
|
||||
|
||||
// KTimerStartRun(timer_handle);
|
||||
PrivClose(pin_fd);
|
||||
PrivClose(timer_fd);
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestHwTimer, a timer test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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: test_i2c.c
|
||||
* @brief: a application of i2c function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
#define I2C_SLAVE_ADDRESS 0x0012U
|
||||
|
||||
void TestI2C(void)
|
||||
{
|
||||
// config IIC pin(SCL:34.SDA:35) in menuconfig
|
||||
int iic_fd = PrivOpen(I2C_DEV_DRIVER, O_RDWR);
|
||||
if (iic_fd < 0)
|
||||
{
|
||||
printf("open iic_fd fd error:%d\n", iic_fd);
|
||||
return;
|
||||
}
|
||||
printf("IIC open successful!\n");
|
||||
|
||||
// init iic
|
||||
uint16 iic_address = I2C_SLAVE_ADDRESS;
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = I2C_TYPE;
|
||||
ioctl_cfg.args = (void *)&iic_address;
|
||||
|
||||
if (0 != PrivIoctl(iic_fd, OPE_INT, &ioctl_cfg))
|
||||
{
|
||||
printf("ioctl iic fd error %d\n", iic_fd);
|
||||
PrivClose(iic_fd);
|
||||
return;
|
||||
}
|
||||
printf("IIC configure successful!\n");
|
||||
|
||||
// I2C read and write
|
||||
char tmp_buff[100];
|
||||
while (1)
|
||||
{
|
||||
PrivTaskDelay(1000);
|
||||
PrivWrite(iic_fd, "Hello World!\n", sizeof("Hello World!\n"));
|
||||
printf("msg send:%s\n", "Hello World!\n");
|
||||
PrivTaskDelay(1000);
|
||||
memset(tmp_buff, 0, sizeof(tmp_buff));
|
||||
PrivRead(iic_fd, tmp_buff, sizeof(tmp_buff));
|
||||
printf("msg recv:%s\n", tmp_buff);
|
||||
}
|
||||
|
||||
PrivClose(iic_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestI2C, a iic test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -1,26 +1,22 @@
|
|||
/****************************************************************************
|
||||
* apps/examples/fb/fb_main.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
/**
|
||||
* @file: test_lcd.c
|
||||
* @brief: a application of dac function
|
||||
* @version: 2.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/1/11
|
||||
*/
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
|
|
@ -29,40 +25,39 @@
|
|||
#ifdef CONFIG_K210_LCD
|
||||
void LcdDemo(void)
|
||||
{
|
||||
int x1 = 50, y1 = 50, x2 = LCD_XSIZE_TFT - 50, y2 = LCD_YSIZE_TFT - 50;
|
||||
int lcd_fd = PrivOpen("/dev/lcd_dev",O_RDWR);
|
||||
LcdWriteParam disp_info;
|
||||
|
||||
Main_Image_Start_Address(LCD_START_ADDR);
|
||||
Main_Image_Width(LCD_XSIZE_TFT);
|
||||
Main_Window_Start_XY(0, 0);
|
||||
Canvas_Image_Start_address(LCD_START_ADDR);
|
||||
Canvas_image_width(LCD_XSIZE_TFT);
|
||||
Active_Window_XY(0, 0);
|
||||
Active_Window_WH(LCD_XSIZE_TFT, LCD_YSIZE_TFT);
|
||||
up_mdelay(10);
|
||||
Canvas_Image_Start_address(LCD_START_ADDR);
|
||||
disp_info.type = 0;
|
||||
disp_info.string_info.x_pos = 80;
|
||||
disp_info.string_info.y_pos = 80;
|
||||
disp_info.string_info.width = 250;
|
||||
disp_info.string_info.height = 24;
|
||||
disp_info.string_info.font_size = 24;
|
||||
disp_info.string_info.addr = "wecome test lcd";
|
||||
disp_info.string_info.font_color = GREEN;
|
||||
disp_info.string_info.back_color = BLUE;
|
||||
PrivWrite(lcd_fd, &disp_info, sizeof(LcdWriteParam));
|
||||
PrivTaskDelay(2000);
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
x1 = 50;
|
||||
y1 = 50;
|
||||
x2 = LCD_XSIZE_TFT - 50;
|
||||
y2 = LCD_YSIZE_TFT - 50;
|
||||
syslog(LOG_NOTICE, "Disp_demo %d (%d,%d - %d,%d)\n", i, x1, y1, x2, y2);
|
||||
LT768_DrawSquare_Fill(x1, y1, x2, y2, Red);
|
||||
up_mdelay(2000);
|
||||
x1 += 20;
|
||||
y1 += 20;
|
||||
x2 -= 20;
|
||||
y2 -= 20;
|
||||
LT768_DrawSquare_Fill(x1, y1, x2, y2, Green);
|
||||
up_mdelay(2000);
|
||||
x1 += 20;
|
||||
y1 += 20;
|
||||
x2 -= 20;
|
||||
y2 -= 20;
|
||||
LT768_DrawSquare_Fill(x1, y1, x2, y2, Blue);
|
||||
up_mdelay(2000);
|
||||
}
|
||||
disp_info.type = 1;
|
||||
lv_color_t redcolor = {
|
||||
.ch = {
|
||||
.red = 0b11111,
|
||||
.green = 0,
|
||||
.blue = 0
|
||||
}
|
||||
};
|
||||
disp_info.pixel_info.x_startpos = 0;
|
||||
disp_info.pixel_info.x_endpos = 50;
|
||||
disp_info.pixel_info.y_startpos = 0;
|
||||
disp_info.pixel_info.y_endpos = 50;
|
||||
disp_info.pixel_info.pixel_color = &redcolor;
|
||||
PrivWrite(lcd_fd, &disp_info, sizeof(LcdWriteParam));
|
||||
PrivTaskDelay(2000);
|
||||
|
||||
disp_info.type = SHOW_TRIANGLE;
|
||||
PrivWrite(lcd_fd, &disp_info, sizeof(LcdWriteParam));
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* 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: test_lcd.c
|
||||
* @brief: a application of lcd function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
#define GRAPHIC_CTRL_RECT_UPDATE 0x00
|
||||
#define LCD_STRING_TYPE 0
|
||||
#define LCD_DOT_TYPE 1
|
||||
#define LCD_FONT_RECT_WIDTH 150
|
||||
#define LCD_FONT_RECT_HEIGHT 50
|
||||
#define NULL_PARAMETER 0
|
||||
|
||||
void TestLcd(void)
|
||||
{
|
||||
int lcd_fd = PrivOpen(EDU_LCD_DEV_DRIVER, O_RDWR);
|
||||
if (lcd_fd < 0)
|
||||
{
|
||||
printf("open lcd fd error:%d\n", lcd_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
LcdWriteParam graph_param;
|
||||
|
||||
// black
|
||||
uint16* color_select = malloc(sizeof(uint16) * 321 * 321);
|
||||
memset(color_select, 0x00, sizeof(uint16) * 321 * 321);
|
||||
graph_param.type = LCD_DOT_TYPE;
|
||||
graph_param.pixel_info.x_startpos = 0;
|
||||
graph_param.pixel_info.y_startpos = 0;
|
||||
graph_param.pixel_info.x_endpos = 320;
|
||||
graph_param.pixel_info.y_endpos = 320;
|
||||
graph_param.pixel_info.pixel_color = color_select;
|
||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||
free(color_select);
|
||||
|
||||
// draw text
|
||||
graph_param.type = LCD_STRING_TYPE;
|
||||
graph_param.string_info.x_pos = 0;
|
||||
graph_param.string_info.y_pos = 0;
|
||||
graph_param.string_info.width = 250;
|
||||
graph_param.string_info.height = 24;
|
||||
graph_param.string_info.font_size = 24;
|
||||
graph_param.string_info.back_color = 0xFFFF;
|
||||
graph_param.string_info.font_color = 0x0000;
|
||||
graph_param.string_info.addr = "hello_world!";
|
||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||
|
||||
// draw line
|
||||
color_select = malloc(sizeof(uint16) * 1 * 320);
|
||||
for (int i = 0; i < 320; i++)
|
||||
{
|
||||
color_select[i] = 0xF800;
|
||||
}
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
graph_param.type = LCD_DOT_TYPE;
|
||||
graph_param.pixel_info.x_startpos = 0;
|
||||
graph_param.pixel_info.y_startpos = i * 50;
|
||||
graph_param.pixel_info.x_endpos = 319;
|
||||
graph_param.pixel_info.y_endpos = i * 50;
|
||||
graph_param.pixel_info.pixel_color = color_select;
|
||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||
}
|
||||
free(color_select);
|
||||
|
||||
PrivClose(lcd_fd);
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestLcd, a lcd test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* 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: test_loraE220.c
|
||||
* @brief: a application of loraE220 function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
#define NULL_PARAMETER 0
|
||||
#define E220_CFG_LENGTH
|
||||
#define GPIOSET(fd, buf, bit) \
|
||||
{ \
|
||||
buf.val = bit; \
|
||||
if (0 > PrivWrite(fd, &buf, NULL_PARAMETER)) \
|
||||
{ \
|
||||
printf("write pin fd error %d\n", fd); \
|
||||
PrivClose(fd); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
#define BSP_E220_M0_PIN 32
|
||||
#define BSP_E220_M1_PIN 33
|
||||
|
||||
void TestLora(int argc, char *argv[])
|
||||
{
|
||||
char uart_recvbuff[100];
|
||||
memset(uart_recvbuff, 0, sizeof(uart_recvbuff));
|
||||
|
||||
int pin_fd = PrivOpen(LORA_PIN_DEV_DRIVER, O_RDWR);
|
||||
if (pin_fd < 0)
|
||||
{
|
||||
printf("open pin fd error:%d\n", pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
int uart_fd = PrivOpen(LORA_UART_DEV_DRIVER, O_RDWR);
|
||||
if (uart_fd < 0)
|
||||
{
|
||||
printf("open pin fd error:%d\n", uart_fd);
|
||||
return;
|
||||
}
|
||||
printf("uart and pin fopen success\n");
|
||||
|
||||
struct PinStat pin_m0;
|
||||
struct PinStat pin_m1;
|
||||
pin_m0.pin = BSP_E220_M0_PIN;
|
||||
pin_m1.pin = BSP_E220_M1_PIN;
|
||||
|
||||
// config led pin in board
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
struct PinParam pin_param;
|
||||
pin_param.cmd = GPIO_CONFIG_MODE;
|
||||
pin_param.mode = GPIO_CFG_OUTPUT;
|
||||
pin_param.pin = BSP_E220_M0_PIN;
|
||||
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
|
||||
ioctl_cfg.args = &pin_param;
|
||||
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg))
|
||||
{
|
||||
printf("ioctl pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
pin_param.pin = BSP_E220_M1_PIN;
|
||||
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg))
|
||||
{
|
||||
printf("ioctl pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("pin configure success\n");
|
||||
struct SerialDataCfg uart_cfg;
|
||||
|
||||
// loraE220 support only 9600bps with 8N1 during initializing
|
||||
uart_cfg.serial_baud_rate = BAUD_RATE_9600;
|
||||
uart_cfg.serial_data_bits = DATA_BITS_8;
|
||||
uart_cfg.serial_stop_bits = STOP_BITS_1;
|
||||
uart_cfg.serial_parity_mode = PARITY_NONE;
|
||||
uart_cfg.serial_bit_order = BIT_ORDER_LSB;
|
||||
uart_cfg.serial_invert_mode = NRZ_NORMAL;
|
||||
uart_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
|
||||
uart_cfg.serial_timeout = 1000;
|
||||
uart_cfg.is_ext_uart = 0;
|
||||
|
||||
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
|
||||
ioctl_cfg.args = (void *)&uart_cfg;
|
||||
|
||||
if (0 != PrivIoctl(uart_fd, OPE_INT, &ioctl_cfg))
|
||||
{
|
||||
printf("ioctl uart fd error %d\n", uart_fd);
|
||||
PrivClose(uart_fd);
|
||||
return;
|
||||
}
|
||||
printf("uart configure success\n");
|
||||
|
||||
GPIOSET(pin_fd, pin_m0, GPIO_HIGH);
|
||||
GPIOSET(pin_fd, pin_m1, GPIO_HIGH);
|
||||
printf("lora configure into sleep(configure) mode\n");
|
||||
|
||||
// send configure data, and receive the same length of data
|
||||
// configure loraE220 as address 1949 CH17 36.8kps
|
||||
char sendbuff[] = {0xC0, 0x00, 0x05, 0x19, 0x49, 0xE6, 0x00, 0x17};
|
||||
|
||||
PrivTaskDelay(2000);
|
||||
|
||||
printf("Sending lora configure information(SIZE:%d)\n", sizeof(sendbuff));
|
||||
PrivWrite(uart_fd, sendbuff, sizeof(sendbuff));
|
||||
printf("lora configure information send\n");
|
||||
|
||||
PrivTaskDelay(2000);
|
||||
|
||||
PrivRead(uart_fd, uart_recvbuff, sizeof(sendbuff));
|
||||
printf("%x %x %x %x", uart_recvbuff[0], uart_recvbuff[1], uart_recvbuff[2], uart_recvbuff[3]);
|
||||
printf("lora configure success\n");
|
||||
|
||||
// error when all bytes are 0xff
|
||||
if (0xFF == (uart_recvbuff[0] & uart_recvbuff[1] & uart_recvbuff[2]))
|
||||
{
|
||||
printf("from lora receive error:%d\n", 0xff);
|
||||
return;
|
||||
}
|
||||
|
||||
uart_cfg.serial_baud_rate = BAUD_RATE_115200;
|
||||
if (0 != PrivIoctl(uart_fd, OPE_INT, &ioctl_cfg))
|
||||
{
|
||||
printf("ioctl uart fd error %d\n", uart_fd);
|
||||
PrivClose(uart_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
// into transparent transmission mode
|
||||
GPIOSET(pin_fd, pin_m0, GPIO_LOW);
|
||||
GPIOSET(pin_fd, pin_m1, GPIO_LOW);
|
||||
// receive and send "Hello World"
|
||||
while (1)
|
||||
{
|
||||
PrivTaskDelay(500);
|
||||
PrivWrite(uart_fd, "Hello_World!", sizeof("Hello_World!"));
|
||||
printf("Data Send:\n%s\n", "Hello_World!");
|
||||
|
||||
PrivTaskDelay(500);
|
||||
memset(uart_recvbuff, 0, sizeof(uart_recvbuff));
|
||||
PrivRead(uart_fd, uart_recvbuff, sizeof(uart_recvbuff));
|
||||
printf("Receive Data is :\n%s\n", uart_recvbuff);
|
||||
}
|
||||
PrivClose(pin_fd);
|
||||
PrivClose(uart_fd);
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestLora, a lora test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* 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: test_musl.c
|
||||
* @brief: a application of musl test function
|
||||
* @version: 2.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/11/8
|
||||
*/
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
|
||||
#if defined(CONFIG_MUSL_LIBC) && defined(CONFIG_FS_AUTOMOUNTER)
|
||||
|
||||
static void file_read_and_write(void)
|
||||
{
|
||||
FILE *p;
|
||||
char s[] = "good luck to you!";
|
||||
char buffer[20];
|
||||
|
||||
if((p = fopen("/mnt/sdcard/test.txt","w+")) == NULL)
|
||||
{
|
||||
printf("Can not open file!\n");
|
||||
}
|
||||
fwrite(s, sizeof(s) + 1, 1, p);
|
||||
fseek(p, SEEK_SET, 0);
|
||||
fread(buffer, sizeof(buffer) + 1, 1, p);
|
||||
printf("read string is: %s\n", buffer);
|
||||
fclose(p);
|
||||
}
|
||||
|
||||
static void file_operations(void)
|
||||
{
|
||||
int ret;
|
||||
FILE *fp;
|
||||
char filename1[] = "/mnt/sdcard/file1.txt";
|
||||
char filename2[] = "/mnt/sdcard/file2.txt";
|
||||
|
||||
fp = fopen(filename1, "w");
|
||||
|
||||
fprintf(fp, "%s", "this is runoob.com");
|
||||
fclose(fp);
|
||||
|
||||
ret = remove(filename1);
|
||||
|
||||
if(ret == 0)
|
||||
{
|
||||
printf("remove file1 success!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error,can not remove file1!\n");
|
||||
}
|
||||
|
||||
ret = remove(filename2);
|
||||
if(ret == 0)
|
||||
{
|
||||
printf("remove file2 success!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error,can not remove file2!\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void malloc_and_free(void)
|
||||
{
|
||||
int *p;
|
||||
int len;
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
len = 1024*(i+1);
|
||||
p = malloc(len);
|
||||
if(p)
|
||||
{
|
||||
printf("malloc %d bytes success!\n",len);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
void Testmusl(void)
|
||||
{
|
||||
printf("--------start test file read and write!--------\n");
|
||||
file_read_and_write();
|
||||
printf("----------start test file operationsn!---------\n");
|
||||
file_operations();
|
||||
printf("---------start test malloc and free!-----------\n");
|
||||
malloc_and_free();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* 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: test_rs485.c
|
||||
* @brief: a application of rs485 function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
#define BSP_485_DIR_PIN 24
|
||||
|
||||
void Test485(void)
|
||||
{
|
||||
int pin_fd = PrivOpen(RS485_PIN_DEV_DRIVER, O_RDWR);
|
||||
if (pin_fd < 0)
|
||||
{
|
||||
printf("open pin fd error:%d\n", pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
int uart_fd = PrivOpen(RS485_UART_DEV_DRIVER, O_RDWR);
|
||||
if (uart_fd < 0)
|
||||
{
|
||||
printf("open pin fd error:%d\n", uart_fd);
|
||||
return;
|
||||
}
|
||||
printf("uart and pin fopen success\n");
|
||||
|
||||
//config led pin in board
|
||||
struct PinParam pin_parameter;
|
||||
memset(&pin_parameter, 0, sizeof(struct PinParam));
|
||||
pin_parameter.cmd = GPIO_CONFIG_MODE;
|
||||
pin_parameter.pin = BSP_485_DIR_PIN;
|
||||
pin_parameter.mode = GPIO_CFG_OUTPUT;
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
|
||||
ioctl_cfg.args = (void *)&pin_parameter;
|
||||
|
||||
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
|
||||
printf("ioctl pin fd error %d\n", pin_fd);
|
||||
PrivClose(pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
struct SerialDataCfg uart_cfg;
|
||||
memset(&uart_cfg, 0, sizeof(struct SerialDataCfg));
|
||||
|
||||
uart_cfg.serial_baud_rate = BAUD_RATE_115200;
|
||||
uart_cfg.serial_data_bits = DATA_BITS_8;
|
||||
uart_cfg.serial_stop_bits = STOP_BITS_1;
|
||||
uart_cfg.serial_parity_mode = PARITY_NONE;
|
||||
uart_cfg.serial_bit_order = BIT_ORDER_LSB;
|
||||
uart_cfg.serial_invert_mode = NRZ_NORMAL;
|
||||
uart_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
|
||||
uart_cfg.serial_timeout = 1000;
|
||||
uart_cfg.is_ext_uart = 0;
|
||||
|
||||
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
|
||||
ioctl_cfg.args = (void *)&uart_cfg;
|
||||
|
||||
if (0 != PrivIoctl(uart_fd, OPE_INT, &ioctl_cfg))
|
||||
{
|
||||
printf("ioctl uart fd error %d\n", uart_fd);
|
||||
PrivClose(uart_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
struct PinStat pin_dir;
|
||||
pin_dir.pin = BSP_485_DIR_PIN;
|
||||
while (1)
|
||||
{
|
||||
pin_dir.val = GPIO_HIGH;
|
||||
PrivWrite(pin_fd,&pin_dir,0);
|
||||
PrivWrite(uart_fd,"Hello world!\n",sizeof("Hello world!\n"));
|
||||
PrivTaskDelay(100);
|
||||
|
||||
pin_dir.val = GPIO_LOW;
|
||||
PrivWrite(pin_fd,&pin_dir,0);
|
||||
char recv_buff[100];
|
||||
memset(recv_buff,0,sizeof(recv_buff));
|
||||
PrivRead(uart_fd,recv_buff,20);
|
||||
printf("%s",recv_buff);
|
||||
PrivTaskDelay(100);
|
||||
}
|
||||
PrivClose(pin_fd);
|
||||
PrivClose(uart_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(Test485, a RS485 test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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: test_rtc.c
|
||||
* @brief: a application of rtc function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
void TestRTC(int argc,char *argv[])
|
||||
{
|
||||
int rtc_fd = PrivOpen(RTC_DEV_DRIVER, O_RDWR);
|
||||
if(rtc_fd<0){
|
||||
printf("open rtc fd error:%d\n",rtc_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if(argc>1){
|
||||
int times = atoi(argv[1]);
|
||||
printf("Time will be printf %d times\n",times);
|
||||
|
||||
struct RtcDrvConfigureParam rtc_para;
|
||||
time_t my_time=0;
|
||||
|
||||
rtc_para.rtc_operation_cmd = OPER_RTC_SET_TIME;
|
||||
rtc_para.time = &my_time;
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = RTC_TYPE;
|
||||
ioctl_cfg.args = (void *)&rtc_para;
|
||||
|
||||
PrivIoctl(rtc_fd,0,&ioctl_cfg);
|
||||
|
||||
rtc_para.rtc_operation_cmd = OPER_RTC_GET_TIME;
|
||||
for(size_t i=0;i<times;i++){
|
||||
PrivIoctl(rtc_fd,0,&ioctl_cfg);
|
||||
printf("The time now is %d\n",*(rtc_para.time));
|
||||
PrivTaskDelay(5000);
|
||||
}
|
||||
}
|
||||
|
||||
PrivClose(rtc_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestRTC, a rtc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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: test_timer.c
|
||||
* @brief: a application of soft timer function
|
||||
* @version: 3.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2023/03/09
|
||||
*/
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
void TimerFunction(union sigval sig_val)
|
||||
{
|
||||
static int cnt = 0;
|
||||
printf("%s cnt %d\n", __func__, cnt++);
|
||||
}
|
||||
|
||||
void TestTimer(void)
|
||||
{
|
||||
int ret = 0;
|
||||
int timer_flags;
|
||||
timer_t timer_id;
|
||||
struct sigevent evp;
|
||||
memset(&evp, 0, sizeof(struct sigevent));
|
||||
|
||||
timer_flags = TIMER_TRIGGER_PERIODIC;
|
||||
|
||||
evp.sigev_notify = SIGEV_THREAD;
|
||||
evp.sigev_notify_function = TimerFunction;
|
||||
evp.sigev_notify_attributes = &timer_flags;
|
||||
|
||||
ret = timer_create(CLOCK_REALTIME, &evp, &timer_id);
|
||||
if (ret < 0) {
|
||||
printf("%s create timer failed ret %d\n", __func__, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
struct itimerspec value;
|
||||
//active time interval
|
||||
value.it_interval.tv_sec = 2;
|
||||
value.it_interval.tv_nsec = 0;
|
||||
|
||||
//first timer set time
|
||||
value.it_value.tv_sec = 2;
|
||||
value.it_value.tv_nsec = 0;
|
||||
|
||||
ret = timer_settime(timer_id, 1, &value, NULL);
|
||||
if (ret < 0) {
|
||||
printf("%s set timer time failed ret %d\n", __func__, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s success\n", __func__);
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TestTimer, soft timer test, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
/****************************************************************************
|
||||
* apps/examples/fb/fb_main.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
|
||||
#ifdef CONFIG_BSP_USING_TOUCH
|
||||
void TestTouch(void)
|
||||
{
|
||||
int fd;
|
||||
TouchDataParam point = {0, 0, 0};
|
||||
fd = PrivOpen("/dev/touch_dev", O_RDWR);
|
||||
while(1)
|
||||
{
|
||||
PrivRead(fd,&point,1);
|
||||
printf("Now touch point:(%d,%d)\n",point.x,point.y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
|
||||
#define NULL_PARAMETER 0
|
||||
#define LCD_DOT_TYPE 1
|
||||
#define LCD_SIZE 320
|
||||
|
||||
#elif defined ADD_XIZI_FETURES
|
||||
|
||||
int lcd_fd, touch_fd, pin_fd;
|
||||
|
||||
void DrawTouchPoint(struct TouchDataStandard *touch_pixel){
|
||||
// draw text
|
||||
uint16 color_select[LCD_SIZE];
|
||||
memset(color_select,0xff,sizeof(color_select));
|
||||
|
||||
LcdWriteParam graph_param;
|
||||
graph_param.type = LCD_DOT_TYPE;
|
||||
graph_param.pixel_info.pixel_color = &color_select;
|
||||
|
||||
printf("touch pixel position x:%d,y:%d\n",touch_pixel->x,touch_pixel->y);
|
||||
graph_param.pixel_info.x_startpos = touch_pixel->x-10>0?touch_pixel->x-10:0;
|
||||
graph_param.pixel_info.y_startpos = touch_pixel->y;
|
||||
graph_param.pixel_info.x_endpos = touch_pixel->x+10;
|
||||
graph_param.pixel_info.y_endpos = touch_pixel->y;
|
||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||
graph_param.pixel_info.x_startpos = touch_pixel->x;
|
||||
graph_param.pixel_info.y_startpos = touch_pixel->y-10>0?touch_pixel->y-10:0;
|
||||
graph_param.pixel_info.x_endpos = touch_pixel->x;
|
||||
graph_param.pixel_info.y_endpos = touch_pixel->y+10;
|
||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||
}
|
||||
|
||||
void ReadTouchData(void* pram){
|
||||
// printf("in touch int");
|
||||
struct TouchDataStandard *touch_data;
|
||||
memset(touch_data, 0, sizeof(touch_data));
|
||||
touch_data = malloc(sizeof(struct TouchDataStandard));
|
||||
if(0 > PrivRead(touch_fd, touch_data, NULL_PARAMETER)){
|
||||
printf("read touch error\n");
|
||||
return;
|
||||
}
|
||||
if(touch_data->x && touch_data->y)
|
||||
DrawTouchPoint(touch_data);
|
||||
free(touch_data);
|
||||
}
|
||||
|
||||
void TestTouch(void)
|
||||
{
|
||||
touch_fd = PrivOpen(TOUCH_DEV_DRIVER, O_RDWR);
|
||||
if (touch_fd < 0)
|
||||
{
|
||||
printf("open touch fd error:%d\n", touch_fd);
|
||||
return;
|
||||
}
|
||||
lcd_fd = PrivOpen(TOUCH_LCD_DEV_DRIVER, O_RDWR);
|
||||
if (lcd_fd < 0)
|
||||
{
|
||||
printf("open lcd fd error:%d\n", lcd_fd);
|
||||
return;
|
||||
}
|
||||
pin_fd = PrivOpen(GPIO_DEV_DRIVER, O_RDWR);
|
||||
if(pin_fd < 0) {
|
||||
printf("open pin fd error:%d\n",pin_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
// //config touch int pin in board
|
||||
// struct PinParam parameter;
|
||||
// parameter.cmd = GPIO_CONFIG_MODE;
|
||||
// parameter.pin = BSP_TOUCH_TP_INT;
|
||||
// parameter.mode = GPIO_CFG_INPUT;
|
||||
// struct PrivIoctlCfg ioctl_cfg;
|
||||
// ioctl_cfg.ioctl_driver_type = PIN_TYPE;
|
||||
// ioctl_cfg.args = (void *)¶meter;
|
||||
// if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
|
||||
// printf("ioctl config touch int pin error %d\n", pin_fd);
|
||||
// PrivClose(pin_fd);
|
||||
// return;
|
||||
// }
|
||||
// // register touch irq
|
||||
// parameter.cmd = GPIO_IRQ_REGISTER;
|
||||
// parameter.pin = BSP_TOUCH_TP_INT;
|
||||
// parameter.irq_set.irq_mode = GPIO_IRQ_EDGE_FALLING;
|
||||
// parameter.irq_set.hdr = ReadTouchData;
|
||||
// parameter.irq_set.args = NULL;
|
||||
// if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
|
||||
// printf("ioctl pin register touch irq error %d\n", pin_fd);
|
||||
// PrivClose(pin_fd);
|
||||
// return;
|
||||
// }
|
||||
// //enable irq
|
||||
// parameter.cmd = GPIO_IRQ_ENABLE;
|
||||
// parameter.pin = BSP_TOUCH_TP_INT;
|
||||
// if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
|
||||
// printf("ioctl pin enable irq error %d\n", pin_fd);
|
||||
// PrivClose(pin_fd);
|
||||
// return;
|
||||
// }
|
||||
|
||||
LcdWriteParam graph_param;
|
||||
uint16_t back_color[LCD_SIZE];
|
||||
|
||||
graph_param.type = LCD_DOT_TYPE;
|
||||
memset(back_color,0x00,sizeof(back_color));
|
||||
for (int i = 0; i < LCD_SIZE; i++){
|
||||
graph_param.pixel_info.pixel_color = &back_color;
|
||||
graph_param.pixel_info.x_startpos = 0;
|
||||
graph_param.pixel_info.y_startpos = i;
|
||||
graph_param.pixel_info.x_endpos = LCD_SIZE - 1;
|
||||
graph_param.pixel_info.y_endpos = i;
|
||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||
}
|
||||
while(1){
|
||||
MdelayKTask(100);
|
||||
ReadTouchData(NULL);
|
||||
}
|
||||
|
||||
PrivClose(lcd_fd);
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestTouch, a touch test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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: test_wdt.c
|
||||
* @brief: a application of wdt function
|
||||
* @version: 1.1
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/12/17
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
|
||||
void TestWDT(int argc, char *agrv[])
|
||||
{
|
||||
int wdt_fd = PrivOpen(WDT0_DEV_DRIVER, O_RDWR);
|
||||
if (wdt_fd < 0)
|
||||
{
|
||||
printf("open wdt_fd fd error:%d\n", wdt_fd);
|
||||
return;
|
||||
}
|
||||
printf("hw watchdog open!\n");
|
||||
|
||||
// init watchdog
|
||||
int wdt_time = 1000;
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = WDT_TYPE;
|
||||
ioctl_cfg.args = (void *)&wdt_time;
|
||||
|
||||
if (0 != PrivIoctl(wdt_fd, OPER_WDT_SET_TIMEOUT, &ioctl_cfg))
|
||||
{
|
||||
printf("ioctl wdt fd error %d\n", wdt_fd);
|
||||
PrivClose(wdt_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
int test_counter = 100;
|
||||
|
||||
// wdt feed or not according to argc,if argc!=1 then dog won't be feed
|
||||
while (test_counter--)
|
||||
{
|
||||
if (1 == argc)
|
||||
{
|
||||
printf("dog is feed\n");
|
||||
PrivIoctl(wdt_fd, OPER_WDT_KEEPALIVE, &ioctl_cfg); // feed dog
|
||||
}
|
||||
PrivTaskDelay(100);
|
||||
}
|
||||
PrivClose(wdt_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(TestWDT, a wdt test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 4g_app.c
|
||||
* @brief support get data from and send data to 4g server
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.12.12
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#include <adapter.h>
|
||||
|
||||
static uint8_t adapter_4g_status = 0;
|
||||
static pthread_t recv_4g_heart_task;
|
||||
struct Adapter *adapter_4g;
|
||||
|
||||
static const uint8_t server_addr[] = "xxx.xxx.xxx.xxx";
|
||||
static const uint8_t server_port[] = "xxx";
|
||||
|
||||
#define ADAPTER_4G_HEART "HEART"
|
||||
|
||||
int Adapter4GConnectFunction(struct Adapter *adapter, uint8_t reconnect)
|
||||
{
|
||||
int ret = 0;
|
||||
int baud_rate = BAUD_RATE_115200;
|
||||
|
||||
if (1 != reconnect) {
|
||||
ret = AdapterDeviceOpen(adapter);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
ret = AdapterDeviceConnect(adapter, CLIENT, server_addr, server_port, IPV4);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
if (ret < 0) {
|
||||
AdapterDeviceClose(adapter);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Adapter4gSend(uint8_t *send_data, size_t length)
|
||||
{
|
||||
if (adapter_4g_status) {
|
||||
AdapterDeviceSend(adapter_4g, send_data, length);
|
||||
}
|
||||
}
|
||||
|
||||
static void *Receive4gHeartTask(void* parameter)
|
||||
{
|
||||
char recv_msg[16] = {0};
|
||||
ssize_t recv_length = 0;
|
||||
uint8_t net_status_cnt = 0;
|
||||
|
||||
while (1) {
|
||||
|
||||
SetTaskStatus(0x01);
|
||||
|
||||
if (net_status_cnt > 5) {
|
||||
adapter_4g_status = 0;
|
||||
|
||||
while (Adapter4GConnectFunction(adapter_4g, 1) < 0) {
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
net_status_cnt = 0;
|
||||
}
|
||||
|
||||
adapter_4g_status = 1;
|
||||
|
||||
recv_length = AdapterDeviceRecv(adapter_4g, recv_msg, 6);
|
||||
if (recv_length > 0) {
|
||||
//if (0 == strcmp(recv_msg, ADAPTER_4G_HEART)) {
|
||||
net_status_cnt = 0;
|
||||
//}
|
||||
} else {
|
||||
printf("4G recv heart error re-recv cnt %d\n", net_status_cnt);
|
||||
net_status_cnt++;
|
||||
}
|
||||
memset(recv_msg, 0, sizeof(recv_msg));
|
||||
}
|
||||
}
|
||||
|
||||
int Adapter4GActive(void)
|
||||
{
|
||||
int ret = 0;
|
||||
adapter_4g = AdapterDeviceFindByName(ADAPTER_4G_NAME);
|
||||
|
||||
#ifdef ADAPTER_EC200T
|
||||
adapter_4g->socket.socket_id = 0;
|
||||
|
||||
ret = Adapter4GConnectFunction(adapter_4g, 0);
|
||||
if (ret < 0) {
|
||||
printf("Adapter4GConnect failed %d\n", ret);
|
||||
}
|
||||
|
||||
adapter_4g_status = 1;
|
||||
|
||||
pthread_attr_t attr;
|
||||
attr.schedparam.sched_priority = 22;
|
||||
attr.stacksize = 2048;
|
||||
|
||||
PrivTaskCreate(&recv_4g_heart_task, &attr, &Receive4gHeartTask, NULL);
|
||||
PrivTaskStartup(&recv_4g_heart_task);
|
||||
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := 4g_app.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
ifeq ($(CONFIG_SOCKET_DEMO),y)
|
||||
|
||||
include $(KERNEL_ROOT)/.config
|
||||
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
|
|
@ -10,6 +7,10 @@ endif
|
|||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
|
||||
SRC_DIR += 4g_app
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RESOURCES_LWIP),y)
|
||||
SRC_DIR += socket_demo
|
||||
endif
|
||||
|
|
@ -17,4 +18,3 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
|||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#include "sys_arch.h"
|
||||
#include <sys_arch.h>
|
||||
#include <lwip/sockets.h>
|
||||
#include "lwip/sys.h"
|
||||
#endif
|
||||
|
|
@ -33,9 +33,17 @@
|
|||
#include "stdio.h"
|
||||
#endif
|
||||
|
||||
#define TCP_DEMO_BUF_SIZE 65535
|
||||
#define TCP_DEMO_BUF_SIZE 65535
|
||||
#define TCP_DEMO_SEND_TIMES 20
|
||||
#define LWIP_TCP_DEMO_TASK_STACK_SIZE 4096
|
||||
#define LWIP_TCP_DEMO_TASK_PRIO 20
|
||||
|
||||
char tcp_socket_ip[] = {192, 168, 250, 252};
|
||||
static pthread_t tcp_client_task;
|
||||
static pthread_t tcp_server_task;
|
||||
|
||||
static char tcp_demo_ipaddr[] = {192, 168, 131, 77};
|
||||
static char tcp_demo_netmask[] = {255, 255, 254, 0};
|
||||
static char tcp_demo_gwaddr[] = {192, 168, 131, 1};
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#define lw_print printf
|
||||
|
|
@ -46,8 +54,8 @@ char tcp_socket_ip[] = {192, 168, 250, 252};
|
|||
#define LWIP_TARGET_PORT 4840
|
||||
#endif
|
||||
|
||||
uint16_t tcp_socket_port = LWIP_TARGET_PORT;
|
||||
char tcp_ip_str[128] = {0};
|
||||
static uint16_t tcp_socket_port = 8888;
|
||||
static char tcp_ip_str[128] = {0};
|
||||
|
||||
/******************************************************************************/
|
||||
void TcpSocketConfigParam(char *ip_str)
|
||||
|
|
@ -55,35 +63,23 @@ void TcpSocketConfigParam(char *ip_str)
|
|||
int ip1, ip2, ip3, ip4, port = 0;
|
||||
|
||||
if(ip_str == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port))
|
||||
{
|
||||
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port)) {
|
||||
printf("config ip %s port %d\n", ip_str, port);
|
||||
strcpy(tcp_ip_str, ip_str);
|
||||
tcp_socket_ip[0] = ip1;
|
||||
tcp_socket_ip[1] = ip2;
|
||||
tcp_socket_ip[2] = ip3;
|
||||
tcp_socket_ip[3] = ip4;
|
||||
if(port)
|
||||
tcp_socket_port = port;
|
||||
return;
|
||||
}
|
||||
|
||||
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4))
|
||||
{
|
||||
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4)) {
|
||||
printf("config ip %s\n", ip_str);
|
||||
tcp_socket_ip[0] = ip1;
|
||||
tcp_socket_ip[1] = ip2;
|
||||
tcp_socket_ip[2] = ip3;
|
||||
tcp_socket_ip[3] = ip4;
|
||||
strcpy(tcp_ip_str, ip_str);
|
||||
}
|
||||
}
|
||||
|
||||
static void TcpSocketRecvTask(void *arg)
|
||||
static void *TcpSocketRecvTask(void *arg)
|
||||
{
|
||||
int fd = -1, clientfd;
|
||||
int recv_len;
|
||||
|
|
@ -91,18 +87,15 @@ static void TcpSocketRecvTask(void *arg)
|
|||
struct sockaddr_in tcp_addr;
|
||||
socklen_t addr_len;
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(1) {
|
||||
recv_buf = (char *)malloc(TCP_DEMO_BUF_SIZE);
|
||||
if (recv_buf == NULL)
|
||||
{
|
||||
if (recv_buf == NULL) {
|
||||
lw_error("No memory\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0)
|
||||
{
|
||||
if (fd < 0) {
|
||||
lw_error("Socket error\n");
|
||||
free(recv_buf);
|
||||
continue;
|
||||
|
|
@ -113,8 +106,7 @@ static void TcpSocketRecvTask(void *arg)
|
|||
tcp_addr.sin_port = htons(tcp_socket_port);
|
||||
memset(&(tcp_addr.sin_zero), 0, sizeof(tcp_addr.sin_zero));
|
||||
|
||||
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1)
|
||||
{
|
||||
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1) {
|
||||
lw_error("Unable to bind\n");
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
|
|
@ -125,8 +117,7 @@ static void TcpSocketRecvTask(void *arg)
|
|||
lw_notice("\nLocal Port:%d\n", tcp_socket_port);
|
||||
|
||||
// setup socket fd as listening mode
|
||||
if (listen(fd, 5) != 0 )
|
||||
{
|
||||
if (listen(fd, 5) != 0 ) {
|
||||
lw_error("Unable to listen\n");
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
|
|
@ -137,13 +128,11 @@ static void TcpSocketRecvTask(void *arg)
|
|||
clientfd = accept(fd, (struct sockaddr *)&tcp_addr, (socklen_t*)&addr_len);
|
||||
lw_notice("client %s connected\n", inet_ntoa(tcp_addr.sin_addr));
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(1) {
|
||||
memset(recv_buf, 0, TCP_DEMO_BUF_SIZE);
|
||||
recv_len = recvfrom(clientfd, recv_buf, TCP_DEMO_BUF_SIZE, 0,
|
||||
(struct sockaddr *)&tcp_addr, &addr_len);
|
||||
if(recv_len > 0)
|
||||
{
|
||||
if(recv_len > 0) {
|
||||
lw_notice("Receive from : %s\n", inet_ntoa(tcp_addr.sin_addr));
|
||||
lw_notice("Receive data : %d - %s\n\n", recv_len, recv_buf);
|
||||
}
|
||||
|
|
@ -157,26 +146,33 @@ static void TcpSocketRecvTask(void *arg)
|
|||
|
||||
void TcpSocketRecvTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 2)
|
||||
{
|
||||
if(argc >= 2) {
|
||||
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
TcpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
||||
sys_thread_new("TcpSocketRecvTask", TcpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
lwip_config_tcp(0, tcp_demo_ipaddr, tcp_demo_netmask, tcp_demo_gwaddr);
|
||||
|
||||
pthread_attr_t attr;
|
||||
attr.schedparam.sched_priority = LWIP_TCP_DEMO_TASK_PRIO;
|
||||
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
|
||||
#endif
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
TcpSocketRecvTask(NULL);
|
||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||
attr.priority = LWIP_TCP_DEMO_TASK_PRIO;
|
||||
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
|
||||
#endif
|
||||
|
||||
PrivTaskCreate(&tcp_server_task, &attr, &TcpSocketRecvTask, NULL);
|
||||
PrivTaskStartup(&tcp_server_task);
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TcpSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
static void TcpSocketSendTask(void *arg)
|
||||
static void *TcpSocketSendTask(void *arg)
|
||||
{
|
||||
int cnt = LWIP_DEMO_TIMES;
|
||||
int cnt = TCP_DEMO_SEND_TIMES;
|
||||
int fd = -1;
|
||||
int ret;
|
||||
char send_msg[128];
|
||||
|
|
@ -186,10 +182,9 @@ static void TcpSocketSendTask(void *arg)
|
|||
|
||||
memset(send_msg, 0, sizeof(send_msg));
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0)
|
||||
{
|
||||
if (fd < 0) {
|
||||
lw_print("Socket error\n");
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct sockaddr_in tcp_sock;
|
||||
|
|
@ -200,17 +195,15 @@ static void TcpSocketSendTask(void *arg)
|
|||
memset(&(tcp_sock.sin_zero), 0, sizeof(tcp_sock.sin_zero));
|
||||
|
||||
ret = connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr));
|
||||
if (ret)
|
||||
{
|
||||
lw_print("Unable to connect %s = %d\n", tcp_ip_str, ret);
|
||||
if (ret < 0) {
|
||||
lw_print("Unable to connect %s:%d = %d\n", tcp_ip_str, tcp_socket_port, ret);
|
||||
close(fd);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lw_print("TCP connect %s:%d success, start to send.\n", tcp_ip_str, tcp_socket_port);
|
||||
|
||||
while (cnt --)
|
||||
{
|
||||
while (cnt --) {
|
||||
lw_print("Lwip client is running.\n");
|
||||
snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt);
|
||||
send(fd, send_msg, strlen(send_msg), 0);
|
||||
|
|
@ -219,24 +212,31 @@ static void TcpSocketSendTask(void *arg)
|
|||
}
|
||||
|
||||
close(fd);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TcpSocketSendTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 2)
|
||||
{
|
||||
if(argc >= 2) {
|
||||
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
TcpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
||||
sys_thread_new("Tcp Socket Send", TcpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
lwip_config_tcp(0, tcp_demo_ipaddr, tcp_demo_netmask, tcp_demo_gwaddr);
|
||||
|
||||
pthread_attr_t attr;
|
||||
attr.schedparam.sched_priority = LWIP_TCP_DEMO_TASK_PRIO;
|
||||
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
|
||||
#endif
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
TcpSocketSendTask(NULL);
|
||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||
attr.priority = LWIP_TCP_DEMO_TASK_PRIO;
|
||||
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
|
||||
#endif
|
||||
|
||||
PrivTaskCreate(&tcp_client_task, &attr, &TcpSocketSendTask, NULL);
|
||||
PrivTaskStartup(&tcp_client_task);
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TcpSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#include "sys_arch.h"
|
||||
#include <sys_arch.h>
|
||||
#include "lwip/sockets.h"
|
||||
#endif
|
||||
|
||||
|
|
@ -38,11 +38,20 @@
|
|||
#define lw_print printf
|
||||
#endif
|
||||
|
||||
#define UDP_BUF_SIZE 65536
|
||||
#define UDP_DEMO_BUF_SIZE 65535
|
||||
#define UDP_DEMO_SEND_TIMES 20
|
||||
#define LWIP_UDP_DEMO_TASK_STACK_SIZE 4096
|
||||
#define LWIP_UDP_DEMO_TASK_PRIO 20
|
||||
|
||||
char udp_socket_ip[] = {192, 168, 250, 252};
|
||||
char udp_ip_str[128] = {0};
|
||||
uint16_t udp_socket_port = LWIP_LOCAL_PORT;
|
||||
static pthread_t udp_client_task;
|
||||
static pthread_t udp_server_task;
|
||||
|
||||
static char udp_demo_ipaddr[] = {192, 168, 131, 77};
|
||||
static char udp_demo_netmask[] = {255, 255, 254, 0};
|
||||
static char udp_demo_gwaddr[] = {192, 168, 131, 1};
|
||||
|
||||
static char udp_ip_str[128] = {0};
|
||||
static uint16_t udp_socket_port = 8888;
|
||||
|
||||
/*****************************************************************************/
|
||||
void UdpSocketConfigParam(char *ip_str)
|
||||
|
|
@ -50,53 +59,38 @@ void UdpSocketConfigParam(char *ip_str)
|
|||
int ip1, ip2, ip3, ip4, port = 0;
|
||||
|
||||
if(ip_str == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port))
|
||||
{
|
||||
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port)) {
|
||||
printf("config ip %s port %d\n", ip_str, port);
|
||||
strcpy(udp_ip_str, ip_str);
|
||||
udp_socket_ip[0] = ip1;
|
||||
udp_socket_ip[1] = ip2;
|
||||
udp_socket_ip[2] = ip3;
|
||||
udp_socket_ip[3] = ip4;
|
||||
if(port)
|
||||
udp_socket_port = port;
|
||||
return;
|
||||
}
|
||||
|
||||
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4))
|
||||
{
|
||||
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4)) {
|
||||
printf("config ip %s\n", ip_str);
|
||||
udp_socket_ip[0] = ip1;
|
||||
udp_socket_ip[1] = ip2;
|
||||
udp_socket_ip[2] = ip3;
|
||||
udp_socket_ip[3] = ip4;
|
||||
strcpy(udp_ip_str, ip_str);
|
||||
}
|
||||
}
|
||||
|
||||
static void UdpSocketRecvTask(void *arg)
|
||||
static void *UdpSocketRecvTask(void *arg)
|
||||
{
|
||||
int fd = -1;
|
||||
char *recv_buf;
|
||||
struct sockaddr_in udp_addr, server_addr;
|
||||
int recv_len;
|
||||
|
||||
while(1)
|
||||
{
|
||||
recv_buf = (char *)malloc(UDP_BUF_SIZE);
|
||||
if(recv_buf == NULL)
|
||||
{
|
||||
while(1) {
|
||||
recv_buf = (char *)PrivMalloc(UDP_DEMO_BUF_SIZE);
|
||||
if(recv_buf == NULL) {
|
||||
lw_error("No memory\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if(fd < 0)
|
||||
{
|
||||
if(fd < 0) {
|
||||
lw_error("Socket error\n");
|
||||
free(recv_buf);
|
||||
continue;
|
||||
|
|
@ -107,8 +101,7 @@ static void UdpSocketRecvTask(void *arg)
|
|||
udp_addr.sin_port = htons(udp_socket_port);
|
||||
memset(&(udp_addr.sin_zero), 0, sizeof(udp_addr.sin_zero));
|
||||
|
||||
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1)
|
||||
{
|
||||
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1) {
|
||||
lw_error("Unable to bind\n");
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
|
|
@ -118,12 +111,10 @@ static void UdpSocketRecvTask(void *arg)
|
|||
lw_notice("UDP bind success, start to receive.\n");
|
||||
lw_notice("\n\nLocal Port:%d\n\n", udp_socket_port);
|
||||
|
||||
while(1)
|
||||
{
|
||||
memset(recv_buf, 0, UDP_BUF_SIZE);
|
||||
recv_len = recv(fd, recv_buf, UDP_BUF_SIZE, 0);
|
||||
if(recv_len > 0)
|
||||
{
|
||||
while(1) {
|
||||
memset(recv_buf, 0, UDP_DEMO_BUF_SIZE);
|
||||
recv_len = recv(fd, recv_buf, UDP_DEMO_BUF_SIZE, 0);
|
||||
if(recv_len > 0) {
|
||||
lw_notice("Receive from : %s\n", inet_ntoa(server_addr.sin_addr));
|
||||
lw_notice("Receive data : %s\n\n", recv_buf);
|
||||
}
|
||||
|
|
@ -137,36 +128,41 @@ static void UdpSocketRecvTask(void *arg)
|
|||
|
||||
void UdpSocketRecvTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 2)
|
||||
{
|
||||
if(argc >= 2) {
|
||||
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
UdpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
||||
sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL,
|
||||
LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
lwip_config_tcp(0, udp_demo_ipaddr, udp_demo_netmask, udp_demo_gwaddr);
|
||||
|
||||
pthread_attr_t attr;
|
||||
attr.schedparam.sched_priority = LWIP_UDP_DEMO_TASK_PRIO;
|
||||
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
|
||||
#endif
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
UdpSocketRecvTask(NULL);
|
||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||
attr.priority = LWIP_UDP_DEMO_TASK_PRIO;
|
||||
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
|
||||
#endif
|
||||
|
||||
PrivTaskCreate(&udp_server_task, &attr, &UdpSocketRecvTask, NULL);
|
||||
PrivTaskStartup(&udp_server_task);
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(UdpSocketRecvTest, a udp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
static void UdpSocketSendTask(void *arg)
|
||||
static void *UdpSocketSendTask(void *arg)
|
||||
{
|
||||
int cnt = LWIP_DEMO_TIMES;
|
||||
int cnt = UDP_DEMO_SEND_TIMES;
|
||||
char send_str[128];
|
||||
int fd = -1;
|
||||
|
||||
memset(send_str, 0, sizeof(send_str));
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if(fd < 0)
|
||||
{
|
||||
if(fd < 0) {
|
||||
lw_error("Socket error\n");
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct sockaddr_in udp_sock;
|
||||
|
|
@ -175,19 +171,17 @@ static void UdpSocketSendTask(void *arg)
|
|||
udp_sock.sin_addr.s_addr = inet_addr(udp_ip_str);
|
||||
memset(&(udp_sock.sin_zero), 0, sizeof(udp_sock.sin_zero));
|
||||
|
||||
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)))
|
||||
{
|
||||
lw_error("Unable to connect\n");
|
||||
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)) < 0) {
|
||||
lw_error("Unable to connect %s:%d\n", udp_ip_str, udp_socket_port);
|
||||
close(fd);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lw_print("UDP connect %s:%d success, start to send.\n",
|
||||
udp_ip_str,
|
||||
udp_socket_port);
|
||||
|
||||
while(cnt --)
|
||||
{
|
||||
while(cnt --) {
|
||||
snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt);
|
||||
send(fd, send_str, strlen(send_str), 0);
|
||||
lw_notice("Send UDP msg: %s ", send_str);
|
||||
|
|
@ -195,25 +189,31 @@ static void UdpSocketSendTask(void *arg)
|
|||
}
|
||||
|
||||
close(fd);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void UdpSocketSendTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 2)
|
||||
{
|
||||
if(argc >= 2) {
|
||||
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
UdpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
||||
sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE,
|
||||
LWIP_DEMO_TASK_PRIO);
|
||||
lwip_config_tcp(0, udp_demo_ipaddr, udp_demo_netmask, udp_demo_gwaddr);
|
||||
|
||||
pthread_attr_t attr;
|
||||
attr.schedparam.sched_priority = LWIP_UDP_DEMO_TASK_PRIO;
|
||||
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
|
||||
#endif
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
UdpSocketSendTask(NULL);
|
||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||
attr.priority = LWIP_UDP_DEMO_TASK_PRIO;
|
||||
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
|
||||
#endif
|
||||
|
||||
PrivTaskCreate(&udp_client_task, &attr, &UdpSocketSendTask, NULL);
|
||||
PrivTaskStartup(&udp_client_task);
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(UdpSocketSendTest, a udp send sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens
|
||||
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c
|
||||
SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c br_ppc2100.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
# 贝加莱 PPC2100通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 通信接线及参数设置
|
||||
|
||||
* 网口
|
||||
* 通过ETH1 RJ45 网口连接
|
||||
* 网口参数:IP:192.168.250.26 Port:502
|
||||
* 测试的协议:Modbus TCP
|
||||
|
||||
## 存储区
|
||||
|
||||
- 贝加莱PLC与其他PLC不同,没有明确类似M,D等这样的存储区的概念,Modbus地址取决于库函数中结构体变量索引。
|
||||
|
||||
## 通信测试
|
||||
|
||||
- 共测试BOOL,INT16,INT32,FLOAT,DOUBLE 共五种类型数据。
|
||||
- 测试BOOL型变量,用功能码01,测其他类型变量用功能码03。
|
||||
-
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 br_ppc2100.c
|
||||
* @brief PLC BR PPC2100 app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023.5.8
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
extern int Adapter4GActive(void);
|
||||
|
||||
void ControlBrTest_PPC2100(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
Adapter4GActive();
|
||||
#endif
|
||||
|
||||
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
|
||||
if (NULL == modbus_tcp_protocol) {
|
||||
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
|
||||
ControlProtocolOpen(modbus_tcp_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(modbus_tcp_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlBrTest_PPC2100, Delta ppc2100 Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "BR_PPC2100",
|
||||
"communication_type": 0,
|
||||
"socket_config": {
|
||||
"plc_ip": "192.168.250.26",
|
||||
"local_ip": "192.168.250.233",
|
||||
"gateway": "192.168.250.1",
|
||||
"netmask": "255.255.254.0",
|
||||
"port": 502
|
||||
},
|
||||
"protocol_type": 2,
|
||||
"read_period": 2000,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "motorrun",
|
||||
"value_type": 1,
|
||||
"function_code": 2,
|
||||
"start_address": 0,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "motorstop",
|
||||
"value_type": 1,
|
||||
"function_code": 2,
|
||||
"start_address": 1,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "valueopen",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 100,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "valueclose",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 101,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "step",
|
||||
"value_type": 3,
|
||||
"function_code": 4,
|
||||
"start_address": 100,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "temperature",
|
||||
"value_type": 9,
|
||||
"function_code": 4,
|
||||
"start_address": 101,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "status",
|
||||
"value_type": 4,
|
||||
"function_code": 4,
|
||||
"start_address": 103,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "mode",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 200,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "setTemperature",
|
||||
"value_type": 9,
|
||||
"function_code": 3,
|
||||
"start_address": 201,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "setConuter",
|
||||
"value_type": 4,
|
||||
"function_code": 3,
|
||||
"start_address": 203,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "LrealTest",
|
||||
"value_type": 8,
|
||||
"function_code": 3,
|
||||
"start_address": 205,
|
||||
"quantity": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_FILES := delta_as228t.c
|
||||
SRC_FILES := delta_as228t.c delta_as332t.c delta_dvp.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
# 台达 DVP通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 通信接线及参数设置
|
||||
|
||||
* 网口
|
||||
* 通过自带 RJ45 网口连接
|
||||
* 网口参数:IP:192.168.250.27 Port:502
|
||||
* 测试的协议:Modbus TCP
|
||||
|
||||
## 存储区
|
||||
|
||||
- 含M,D,X,Y。台达PLC中 各存储区地址和Modbus地址有明确的对应表,详见台达DVP协议解析测试文档。
|
||||
|
||||
## 通信测试
|
||||
|
||||
- 共测试BOOL,INT16,INT32,FLOAT 共四种类型数据。
|
||||
- 测试D区,M区和Y区。
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 delta_dvp.c
|
||||
* @brief PLC DELTA DVP app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
extern int Adapter4GActive(void);
|
||||
|
||||
void ControlDeltadvpTest(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
Adapter4GActive();
|
||||
#endif
|
||||
|
||||
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
|
||||
if (NULL == modbus_tcp_protocol) {
|
||||
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
|
||||
ControlProtocolOpen(modbus_tcp_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(modbus_tcp_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlDeltadvpTest, Delta dvp Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "DELTA_DVP",
|
||||
"communication_type": 0,
|
||||
"socket_config": {
|
||||
"plc_ip": "192.168.250.27",
|
||||
"local_ip": "192.168.250.233",
|
||||
"gateway": "192.168.250.1",
|
||||
"netmask": "255.255.254.0",
|
||||
"port": 502
|
||||
},
|
||||
"protocol_type": 2,
|
||||
"read_period": 2000,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "M20",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 2068,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M100",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address":2148,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "Y10",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 1288,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D200",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address":4296,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D201",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 4297,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D220",
|
||||
"value_type": 4,
|
||||
"function_code": 3,
|
||||
"start_address": 4316,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "D222",
|
||||
"value_type": 4,
|
||||
"function_code": 3,
|
||||
"start_address": 4318,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "D300",
|
||||
"value_type": 9,
|
||||
"function_code": 3,
|
||||
"start_address": 4396,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "D302",
|
||||
"value_type": 9,
|
||||
"function_code": 3,
|
||||
"start_address": 4398,
|
||||
"quantity": 2
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := ge_versamax001.c ge_cpe100.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
---
|
||||
typora-copy-images-to: upload
|
||||
---
|
||||
|
||||
# 艾默生(原GE) 通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 小型VersaMAX CPU001测试
|
||||
|
||||
### 通信接线及参数设置
|
||||
|
||||
* 串口
|
||||
* COM2为15孔D型 RS485。波特率:19200,数据位:8位,停止位:1位,校验:偶校验。接线按下图典型双线接法。
|
||||
|
||||

|
||||
|
||||
### 存储区
|
||||
|
||||
- 存储区 I,Q,AI,R区。其他内存区如M,AQ不能直接访问,要通过程序转换访问。
|
||||
|
||||
### 通信测试
|
||||
|
||||
- 共测试BOOL,INT16,FLOAT共三种类型数据。
|
||||
|
||||
|
||||
- 测试R区及Q区数据。
|
||||
|
||||
|
||||
- R区数据测试,用功能码03,以字为单位读取。配方中start_address字段为PLC地址直接减1。
|
||||
|
||||
|
||||
- Q区数据测试,用功能码01,以位为单位读取。配方中start_address字段为PLC地址直接减1。
|
||||
|
||||
## 中型PLC CPE100通信测试
|
||||
|
||||
### 通信接线及参数设置
|
||||
|
||||
- 网口
|
||||
- 网口RJ45,参数 IP:192.168.250.28 端口号:502
|
||||
|
||||
### 存储区
|
||||
|
||||
- 存储区 I,Q,AI,R区。其他内存区如M,AQ不能直接访问,要通过程序转换访问。
|
||||
|
||||
### 通信测试
|
||||
|
||||
- 共测试BOOL,INT16,INT32,FLOAT,DOUBLE共五种类型数据。
|
||||
|
||||
|
||||
- 测试R区及Q区数据。
|
||||
|
||||
|
||||
- R区数据测试,用功能码03,以字为单位读取。配方中start_address字段为PLC地址直接减1。
|
||||
|
||||
|
||||
- Q区数据测试,用功能码01,以位为单位读取。配方中start_address字段为PLC地址直接减1。
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 ge_cpe100.c
|
||||
* @brief PLC GE Versamax app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
extern int Adapter4GActive(void);
|
||||
|
||||
void ControlGecpe100Test(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
Adapter4GActive();
|
||||
#endif
|
||||
|
||||
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
|
||||
if (NULL == modbus_tcp_protocol) {
|
||||
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
|
||||
ControlProtocolOpen(modbus_tcp_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(modbus_tcp_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlGecpe100Test, ge cpe100 Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 ge_versamax001.c
|
||||
* @brief PLC GE Versamax app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
extern int Adapter4GActive(void);
|
||||
|
||||
void ControlGeversamaxTest(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
Adapter4GActive();
|
||||
#endif
|
||||
|
||||
ControlProtocolType modbus_rtu_protocol = ControlProtocolFind();
|
||||
if (NULL == modbus_rtu_protocol) {
|
||||
printf("%s get modbus rtu protocol %p failed\n", __func__, modbus_rtu_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get modbus rtu protocol %p successfull\n", __func__, modbus_rtu_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == modbus_rtu_protocol->protocol_status) {
|
||||
ControlProtocolOpen(modbus_rtu_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(modbus_rtu_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] modbus rtu data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(modbus_rtu_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlGeversamaxTest, ge versamax001 Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "GE_CPE100_TCP",
|
||||
"communication_type": 0,
|
||||
"socket_config": {
|
||||
"plc_ip": "192.168.250.28",
|
||||
"local_ip": "192.168.250.233",
|
||||
"gateway": "192.168.250.1",
|
||||
"netmask": "255.255.254.0",
|
||||
"port": 502
|
||||
},
|
||||
"protocol_type": 2,
|
||||
"read_period": 2000,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "Q001",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 0,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "Q010",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address":9,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "Q066",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 65,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "Q100",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address":99,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "R11",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 10,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "R12",
|
||||
"value_type": 9,
|
||||
"function_code": 3,
|
||||
"start_address": 11,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "R14",
|
||||
"value_type": 8,
|
||||
"function_code": 3,
|
||||
"start_address": 13,
|
||||
"quantity": 4
|
||||
},
|
||||
{
|
||||
"value_name": "R18",
|
||||
"value_type": 4,
|
||||
"function_code": 3,
|
||||
"start_address": 17,
|
||||
"quantity": 2
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "GE_VersaMAX_RTU",
|
||||
"communication_type": 1,
|
||||
"serial_config": {
|
||||
"station": 1,
|
||||
"baud_rate": 19200,
|
||||
"data_bits": 8,
|
||||
"stop_bits": 1,
|
||||
"check_mode": 2
|
||||
},
|
||||
"protocol_type": 3,
|
||||
"read_period": 2000,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "Q001",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 0,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "Q010",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 9,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "Q066",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 65,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "Q100",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 99,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "R11",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 10,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "R12",
|
||||
"value_type": 9,
|
||||
"function_code": 3,
|
||||
"start_address": 11,
|
||||
"quantity": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := inovance_am401_cpu1608tn_ethernet.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
# INOVANCE AM4011608TN通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 通信接线及参数设置
|
||||
|
||||
* 网口
|
||||
|
||||
* CN3 EtherNET,Mosbus TCP协议,IP:192.168.250.50,Port:502
|
||||
|
||||
* 串口
|
||||
* CN1 RS485,AM401只支持一路串口,AM600可支持两路串口。AM401接线:pin1:485-,pin2:485+。波特率:9600,数据位:8位,停止位:1位,校验:偶校验
|
||||
|
||||
## 存储区
|
||||
|
||||
- 存储区 I,Q,M区。
|
||||
|
||||
## 通信测试
|
||||
|
||||
(1)共测试BOOL,INT16,INT32,FLOAT共四种类型数据。
|
||||
|
||||
(2)测试M区及Q区数据。
|
||||
|
||||
(3)M区数据测试,用功能码03,以字为单位读取。如读MX0.3,则读取MW0,然后按位拆解。如读MW100,则配方文件中起始地址则直接写100即可。如读MDx,则配方文件中起始地址应为2*x,这是汇川的地址编码规则决定,如MD200,则对应400。
|
||||
|
||||
(4)Q区数据测试,用功能码01,以位为单位读取。如读QX.Y,则配方文件中起始地址为X*8+Y;如读QW,QD等,则需按位进行读取后然后组合得到。
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 inovance_am401_cpu1608tn_ethernet.c
|
||||
* @brief PLC inovance am401 app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023.4.25
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
extern int Adapter4GActive(void);
|
||||
|
||||
void ControlInovanceam401EthernetTest(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
Adapter4GActive();
|
||||
#endif
|
||||
|
||||
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
|
||||
if (NULL == modbus_tcp_protocol) {
|
||||
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
|
||||
ControlProtocolOpen(modbus_tcp_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(modbus_tcp_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlInovanceam401EthernetTest, inovance am401 ethernet Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "INOVANCE_AM401_TCP",
|
||||
"communication_type": 0,
|
||||
"socket_config": {
|
||||
"plc_ip": "192.168.250.50",
|
||||
"local_ip": "192.168.250.233",
|
||||
"gateway": "192.168.250.1",
|
||||
"netmask": "255.255.254.0",
|
||||
"port": 502
|
||||
},
|
||||
"protocol_type": 2,
|
||||
"read_period": 2000,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "q00",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 0,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "q01",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address":1,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "q10",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 8,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "mw100",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 100,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "mw101",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 101,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "md200",
|
||||
"value_type": 4,
|
||||
"function_code": 3,
|
||||
"start_address": 400,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "md201",
|
||||
"value_type": 4,
|
||||
"function_code": 3,
|
||||
"start_address": 402,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "md300",
|
||||
"value_type": 9,
|
||||
"function_code": 3,
|
||||
"start_address": 600,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "md301",
|
||||
"value_type": 9,
|
||||
"function_code": 3,
|
||||
"start_address": 602,
|
||||
"quantity": 2
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c
|
||||
SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c mitsubishi_fx2n.c mitsubishi_q02u.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
# 三菱 FX2N通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 通信接线及参数设置
|
||||
|
||||
* 串口
|
||||
* FX2N自带8针圆口422,用于程序的下载。全系列不支持网口,且需购买串口拓展模块FX2N-485-BD用于通信测试。
|
||||
* 接线:RDA和SDA短接,引出A;RDB与SDB短接,引出B。
|
||||
* 串口模块支持MC-1C协议,通信速率:9600;数据位:7bit;停止位:1bit;校验:偶校验
|
||||
|
||||
## 存储区
|
||||
|
||||
- 存储区 I,Q,M,D区。
|
||||
|
||||
## 通信测试
|
||||
|
||||
- 共测试BOOL,INT16,FLOAT共三种类型数据。
|
||||
|
||||
|
||||
- 测试M区及D区数据。
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 mitsubishi_fx2n.c
|
||||
* @brief PLC MITSUBISHI FX2N app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
extern int Adapter4GActive(void);
|
||||
|
||||
void ControlFx2nTest(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
Adapter4GActive();
|
||||
#endif
|
||||
|
||||
ControlProtocolType melsec_1c_protocol = ControlProtocolFind();
|
||||
if (NULL == melsec_1c_protocol) {
|
||||
printf("%s get melsec 1c protocol %p failed\n", __func__, melsec_1c_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get melsec 1c protocol %p successfull\n", __func__, melsec_1c_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == melsec_1c_protocol->protocol_status) {
|
||||
ControlProtocolOpen(melsec_1c_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(melsec_1c_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] melsec 1c data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(melsec_1c_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlFx2nTest, Mitsubishi FX2N Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
|
|
@ -18,6 +18,47 @@
|
|||
* @date 2022.9.27
|
||||
*/
|
||||
|
||||
|
||||
#include <control.h>
|
||||
|
||||
extern int Adapter4GActive(void);
|
||||
|
||||
void ControlFx3uTest(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
Adapter4GActive();
|
||||
#endif
|
||||
|
||||
ControlProtocolType melsec_1e_protocol = ControlProtocolFind();
|
||||
if (NULL == melsec_1e_protocol) {
|
||||
printf("%s get melsec 1e protocol %p failed\n", __func__, melsec_1e_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get melsec 1e protocol %p successfull\n", __func__, melsec_1e_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == melsec_1e_protocol->protocol_status) {
|
||||
ControlProtocolOpen(melsec_1e_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(melsec_1e_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] melsec 1e data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(modbus_tcp_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlFx3uTest, Mitsubishi fx3u Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 mitsubishi_q02u.c
|
||||
* @brief PLC MITSUBISHI Q02U app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
extern int Adapter4GActive(void);
|
||||
|
||||
void ControlQ02uTest(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
Adapter4GActive();
|
||||
#endif
|
||||
|
||||
ControlProtocolType melsec_3e_protocol = ControlProtocolFind();
|
||||
if (NULL == melsec_3e_protocol) {
|
||||
printf("%s get melsec 3e protocol %p failed\n", __func__, melsec_3e_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get melsec 3e protocol %p successfull\n", __func__, melsec_3e_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == melsec_3e_protocol->protocol_status) {
|
||||
ControlProtocolOpen(melsec_3e_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(melsec_3e_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] melsec 3c data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(melsec_3c_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlQ02uTest, Mitsubishi Q02U Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,331 @@
|
|||
{
|
||||
"device_id": 769,
|
||||
"device_name": "S01",
|
||||
"communication_type": 1,
|
||||
"serial_config": {
|
||||
"station": 1,
|
||||
"baud_rate": 9600,
|
||||
"data_bits": 7,
|
||||
"stop_bits": 1,
|
||||
"check_mode": 3
|
||||
},
|
||||
"protocol_type": 9,
|
||||
"read_period": 1000,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "启动",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "0",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "停止",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "1",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "使能",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "2",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "回零",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "3",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "急停",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "4",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "正限位",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "5",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "负限位",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "6",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "自动运行中",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "20",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "故障",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "21",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "待机",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "22",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "手动模式",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "23",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "自动模式",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "24",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "运行方向",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "25",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "复位",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "26",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "备用1",
|
||||
"value_type": 1,
|
||||
"device_code": "M",
|
||||
"head_device_number_string": "27",
|
||||
"device_points_count": 1,
|
||||
"command_type": 0,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "产量",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "0",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "整型1",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "1",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "整型2",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "2",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "整型3",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "3",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "整型4",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "4",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "整型5",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "5",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "整型6",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "50",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "整型7",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "51",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "整型8",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "52",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "整型9",
|
||||
"value_type": 3,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "53",
|
||||
"device_points_count": 1,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "速度",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "200",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "加速度",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "202",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "减速度",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "204",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "起始位置",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "206",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "终点位置",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "208",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "张力值",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "300",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "浮点型1",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "302",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "浮点型2",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "304",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "浮点型3",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "306",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
},
|
||||
{
|
||||
"value_name": "浮点型4",
|
||||
"value_type": 9,
|
||||
"device_code": "D",
|
||||
"head_device_number_string": "308",
|
||||
"device_points_count": 2,
|
||||
"command_type": 1,
|
||||
"monitoring_timer": 100
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c
|
||||
SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c omron_cp1h.c omron_cp1l.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
# OMRON_CP1L通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 通信接线及参数设置
|
||||
|
||||
* 本体无接口,增加CP1W-CIF41网络板卡
|
||||
|
||||
* FINS协议,PLC IP:192.168.250.31,Port:9600
|
||||
|
||||
## 存储区
|
||||
|
||||
- 存储区 W,D区。
|
||||
|
||||
## JSON配方设计
|
||||
|
||||
* 共测试BOOL,INT16共2种类型数据,以下为JSON文件解释。
|
||||
|
||||
- ```json
|
||||
{
|
||||
"device_id": 1, //设备ID默认是1,此参数无效
|
||||
"device_name": "CP1L", //设备名称,自定义
|
||||
"communication_type": 0, //通讯协议类型 0是以太网,1是串口
|
||||
"socket_config": { //以太网配置
|
||||
"plc_ip": "192.168.250.31", //PLC的IP地址
|
||||
"local_ip": "192.168.250.233", //矽达通IP地址设定
|
||||
"gateway": "192.168.250.1", //矽达通的网关地址设定
|
||||
"netmask": "255.255.255.0", //矽达通子网掩码设定
|
||||
"port": 9600 //端口号设定
|
||||
},
|
||||
"protocol_type": 5, //通讯协议,5代表FINS协议
|
||||
"read_period": 100, //交互周期ms
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "停止", //变量名称,自定义
|
||||
"value_type": 1, //变量类型,BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
|
||||
"area_char": "W", //变量功能块
|
||||
"data_type": 0, //数据传输类型,BOOL = 0,WORD = 1
|
||||
"start_address": 100, //起始地址
|
||||
"bit_address": 1, //BOOL地址偏移位,采集变量地址是W100.1
|
||||
"data_length": 1 //BOOL长度,默认是1,代表读取1个BOOL长度
|
||||
},
|
||||
{
|
||||
"value_name": "转速", //变量名称,自定义
|
||||
"value_type": 3, //变量类型,BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
|
||||
"area_char": "D", //变量功能块
|
||||
"data_type": 1, //数据传输类型,BOOL = 0,WORD = 1
|
||||
"start_address": 101, //起始地址
|
||||
"bit_address": 0, //以WORD采集方式时此参数无效,采集变量地址是D101
|
||||
"data_length": 1 //WORD长度,默认是1,代表读取1个WORD长度,2个字节
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 通信测试
|
||||
|
||||
(1) 新增1个通信demo,命名为omron_cp1l.c;
|
||||
|
||||
(2) 复制样例代码程序到omron_cp1l.c文件中;
|
||||
|
||||
(3) void **ControlOmronCP1LTest**(void) 更改函数名;
|
||||
|
||||
(4) PRIV_SHELL_CMD_FUNCTION(**ControlOmronCP1LTest**, **Omron Plc Cp1l Demo**, PRIV_SHELL_CMD_MAIN_ATTR);更改测试指令;
|
||||
|
||||
(5) 剪裁配置完成后,用过烧写器下载至矽达通中,重启后完成测试。
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -18,6 +18,32 @@
|
|||
* @date 2022.9.27
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
void ControlOmronTest(void)
|
||||
{
|
||||
int i = 0;
|
||||
uint16_t read_data_length = 0;
|
||||
uint8_t read_data[1024] = {0};
|
||||
ControlProtocolType fins_protocol = ControlProtocolFind();
|
||||
if (NULL == fins_protocol) {
|
||||
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
|
||||
ControlProtocolOpen(fins_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
|
||||
i++;
|
||||
PrivTaskDelay(100000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(fins_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlOmronTest, Omron Plc FINS Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 omron_cp1h.c
|
||||
* @brief PLC OMRON CP1H app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023.4.1
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
void ControlOmronCP1HTest(void)
|
||||
{
|
||||
int i = 0;
|
||||
uint16_t read_data_length = 0;
|
||||
uint8_t read_data[1024] = {0};
|
||||
ControlProtocolType fins_protocol = ControlProtocolFind();
|
||||
if (NULL == fins_protocol) {
|
||||
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
|
||||
ControlProtocolOpen(fins_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
|
||||
i++;
|
||||
PrivTaskDelay(100000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(fins_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlOmronCP1HTest, Omron Plc Cp1h Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 omron_.cp1l.c
|
||||
* @brief PLC OMRON CP1L app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023.2.10
|
||||
*/
|
||||
#include <control.h>
|
||||
|
||||
void ControlOmronCP1LTest(void)
|
||||
{
|
||||
int i = 0;
|
||||
uint16_t read_data_length = 0;
|
||||
uint8_t read_data[1024] = {0};
|
||||
ControlProtocolType fins_protocol = ControlProtocolFind();
|
||||
if (NULL == fins_protocol) {
|
||||
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
|
||||
ControlProtocolOpen(fins_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
|
||||
i++;
|
||||
PrivTaskDelay(100000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(fins_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlOmronCP1LTest, Omron Plc Cp1l Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
@ -18,6 +18,34 @@
|
|||
* @date 2022.9.27
|
||||
*/
|
||||
|
||||
|
||||
#include <control.h>
|
||||
|
||||
void ControlOmronNX102Test(void)
|
||||
{
|
||||
int i = 0;
|
||||
uint16_t read_data_length = 0;
|
||||
uint8_t read_data[1024] = {0};
|
||||
ControlProtocolType fins_protocol = ControlProtocolFind();
|
||||
if (NULL == fins_protocol) {
|
||||
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
|
||||
ControlProtocolOpen(fins_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
|
||||
i++;
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
// ControlProtocolClose(fins_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlOmronNX102Test, Omron Plc FINS Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "CP1H",
|
||||
"communication_type": 0,
|
||||
"socket_config": {
|
||||
"plc_ip": "192.168.250.46",
|
||||
"local_ip": "192.168.250.233",
|
||||
"gateway": "192.168.250.1",
|
||||
"netmask": "255.255.255.0",
|
||||
"port": 9600
|
||||
},
|
||||
"protocol_type": 5,
|
||||
"read_period": 100,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "启动",
|
||||
"value_type": 1,
|
||||
"area_char": "W",
|
||||
"data_type": 0,
|
||||
"start_address": 10,
|
||||
"bit_address": 0,
|
||||
"data_length": 1
|
||||
},
|
||||
{
|
||||
"value_name": "停止",
|
||||
"value_type": 1,
|
||||
"area_char": "W",
|
||||
"data_type": 0,
|
||||
"start_address": 10,
|
||||
"bit_address": 1,
|
||||
"data_length": 1
|
||||
},
|
||||
{
|
||||
"value_name": "暂停",
|
||||
"value_type": 1,
|
||||
"area_char": "W",
|
||||
"data_type": 0,
|
||||
"start_address": 10,
|
||||
"bit_address": 2,
|
||||
"data_length": 1
|
||||
},
|
||||
{
|
||||
"value_name": "整型1",
|
||||
"value_type": 3,
|
||||
"area_char": "D",
|
||||
"data_type": 1,
|
||||
"start_address": 100,
|
||||
"bit_address": 0,
|
||||
"data_length": 1
|
||||
},
|
||||
{
|
||||
"value_name": "整型2",
|
||||
"value_type": 3,
|
||||
"area_char": "D",
|
||||
"data_type": 1,
|
||||
"start_address": 101,
|
||||
"bit_address": 0,
|
||||
"data_length": 1
|
||||
},
|
||||
{
|
||||
"value_name": "浮点",
|
||||
"value_type": 9,
|
||||
"area_char": "D",
|
||||
"data_type": 1,
|
||||
"start_address": 110,
|
||||
"bit_address": 0,
|
||||
"data_length": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "CP1L",
|
||||
"communication_type": 0,
|
||||
"socket_config": {
|
||||
"plc_ip": "192.168.250.31",
|
||||
"local_ip": "192.168.250.233",
|
||||
"gateway": "192.168.250.1",
|
||||
"netmask": "255.255.255.0",
|
||||
"port": 9600
|
||||
},
|
||||
"protocol_type": 5,
|
||||
"read_period": 100,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "启动",
|
||||
"value_type": 1,
|
||||
"area_char": "W",
|
||||
"data_type": 0,
|
||||
"start_address": 100,
|
||||
"bit_address": 0,
|
||||
"data_length": 1
|
||||
},
|
||||
{
|
||||
"value_name": "停止",
|
||||
"value_type": 1,
|
||||
"area_char": "W",
|
||||
"data_type": 0,
|
||||
"start_address": 100,
|
||||
"bit_address": 1,
|
||||
"data_length": 1
|
||||
},
|
||||
{
|
||||
"value_name": "转速",
|
||||
"value_type": 3,
|
||||
"area_char": "D",
|
||||
"data_type": 1,
|
||||
"start_address": 101,
|
||||
"bit_address": 0,
|
||||
"data_length": 1
|
||||
},
|
||||
{
|
||||
"value_name": "产量",
|
||||
"value_type": 3,
|
||||
"area_char": "D",
|
||||
"data_type": 1,
|
||||
"start_address": 102,
|
||||
"bit_address": 0,
|
||||
"data_length": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "m241",
|
||||
"communication_type": 1,
|
||||
"serial_config": {
|
||||
"station": 1,
|
||||
"baud_rate": 9600,
|
||||
"data_bits": 8,
|
||||
"stop_bits": 1,
|
||||
"check_mode": 3
|
||||
},
|
||||
"protocol_type": 3,
|
||||
"read_period": 100,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "MW0",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 0,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "MW1",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 1,
|
||||
"quantity": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -15,9 +15,47 @@
|
|||
* @brief PLC SCHNEIDER M241 app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
* @date 2023.2.1
|
||||
*/
|
||||
|
||||
|
||||
#include <control.h>
|
||||
void ControlM241Test(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
Adapter4GActive();
|
||||
#endif
|
||||
|
||||
ControlProtocolType modbus_rtu_protocol = ControlProtocolFind();
|
||||
if (NULL == modbus_rtu_protocol) {
|
||||
printf("%s get modbus rtu protocol %p failed\n", __func__, modbus_rtu_protocol);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s get modbus rtu protocol %p successfull\n", __func__, modbus_rtu_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == modbus_rtu_protocol->protocol_status) {
|
||||
ControlProtocolOpen(modbus_rtu_protocol);
|
||||
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(modbus_rtu_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] modbus rtu data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
//ControlProtocolClose(modbus_rtu_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlM241Test, Schneider M241 Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
# SIEMENS - S7-1512通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 通信接线及参数设置
|
||||
|
||||
* 本体以太网口
|
||||
|
||||
* S7协议,PLC IP:192.168.250.2,Port:102
|
||||
|
||||
## 存储区
|
||||
|
||||
- 存储区 Q,DB区。
|
||||
|
||||
## JSON配方设计
|
||||
|
||||
* 共测试BOOL,INT16共2种类型数据,以下为JSON文件解释。
|
||||
|
||||
- ```json
|
||||
{
|
||||
"device_id": 1, //设备ID默认是1,此参数无效
|
||||
"device_name": "S7-1512", //设备名称,自定义
|
||||
"communication_type": 0, //通讯协议类型 0是以太网,1是串口
|
||||
"socket_config": { //以太网配置
|
||||
"plc_ip": "192.168.250.2", //PLC的IP地址
|
||||
"local_ip": "192.168.250.233", //矽达通IP地址设定
|
||||
"gateway": "192.168.250.1", //矽达通的网关地址设定
|
||||
"netmask": "255.255.255.0", //矽达通子网掩码设定
|
||||
"port": 102 //端口号设定
|
||||
},
|
||||
"protocol_type": 1, //通讯协议,5代表FINS协议
|
||||
"read_period": 100, //交互周期ms
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "布尔1", //变量名称,自定义
|
||||
"value_type": 1, //变量类型,BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
|
||||
"area": "Q", //变量功能块
|
||||
"wordlen": "Bit", //变量字长类型,有:Bit Byte Word DWord Real Counter Timer
|
||||
"db_number": 1, //如为DB区,填写对应的DB块编号,如不是DB区,无效
|
||||
"start": 1, //BOOL地址偏移位,采集变量地址是Q0.1
|
||||
"amount": 1 //BOOL长度,默认是1,代表读取1个BOOL长度
|
||||
},
|
||||
{
|
||||
"value_name": "整型", //变量名称,自定义
|
||||
"value_type": 3, //变量类型,BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
|
||||
"area": "DB", //变量功能块
|
||||
"wordlen": "Word", //变量字长类型,有:Bit Byte Word DWord Real Counter Timer
|
||||
"db_number": 18, //如为DB区,即DB18块
|
||||
"start": 2, //Word地址偏移位,采集变量地址是DB18.DBW2
|
||||
"amount": 1 //Word长度,默认是1,代表读取1个WORD长度,2个字节
|
||||
},
|
||||
{
|
||||
"value_name": "浮点数", //变量名称,自定义
|
||||
"value_type": 9, //变量类型,BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
|
||||
"area": "DB", //变量功能块
|
||||
"wordlen": "Real", //变量字长类型,有:Bit Byte Word DWord Real Counter Timer
|
||||
"db_number": 18, //如为DB区,即DB18块
|
||||
"start": 18, //Real地址偏移位,采集变量地址是DB18.DBD18
|
||||
"amount": 1 //Real长度,默认是1,代表读取1个Real长度,4个字节
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 通信测试
|
||||
|
||||
(1) 新增1个通信demo,命名为simens_s7_1500.c;
|
||||
|
||||
(2) 复制样例代码程序到simens_s7_1500.c文件中;
|
||||
|
||||
(3) void **ControlS71500Test**(void)更改函数名;
|
||||
|
||||
(4) PRIV_SHELL_CMD_FUNCTION(**ControlS71500Test, Siemens Plc S7_1512 Demo**, PRIV_SHELL_CMD_MAIN_ATTR);更改测试指令;
|
||||
|
||||
(5) 剪裁配置完成后,用过烧写器下载至矽达通中,重启后完成测试。
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -15,9 +15,6 @@
|
|||
* @brief PLC SIEMENS S7-1200 app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
* @date 2023.3.27
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,31 @@
|
|||
* @brief PLC SIEMENS S7-1500 app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
* @date 2023.3.27
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
void ControlS71500Test(void)
|
||||
{
|
||||
int i = 0;
|
||||
uint16_t read_data_length = 0;
|
||||
uint8_t read_data[1024] = {0};
|
||||
ControlProtocolType s7_protocol = ControlProtocolFind();
|
||||
if (NULL == s7_protocol) {
|
||||
printf("%s get s7 protocol %p failed\n", __func__, s7_protocol);
|
||||
return;
|
||||
}
|
||||
printf("%s get s7 protocol %p successfull\n", __func__, s7_protocol);
|
||||
if (CONTROL_REGISTERED == s7_protocol->protocol_status) {
|
||||
ControlProtocolOpen(s7_protocol);
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(s7_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] s7 data %d using receipe file\n", __func__, i, read_data_length);
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlS71500Test, Siemens Plc S7_1512 Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
@ -11,13 +11,10 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* @file siemens_s7_200_smart.c
|
||||
* @brief PLC SIEMENS S7-200 SMART app
|
||||
* @file siemens_s7_200 smart.c
|
||||
* @brief PLC SIEMENS S7-200 smart app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
* @date 2023.3.27
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
* @brief PLC SIEMENS S7-300 app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.9.27
|
||||
* @date 2023.3.27
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "S7-1512",
|
||||
"communication_type": 0,
|
||||
"socket_config": {
|
||||
"plc_ip": "192.168.250.2",
|
||||
"local_ip": "192.168.250.233",
|
||||
"gateway": "192.168.250.252",
|
||||
"netmask": "255.255.255.0",
|
||||
"port": 102
|
||||
},
|
||||
"protocol_type": 1,
|
||||
"read_period": 100,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "布尔1",
|
||||
"value_type": 1,
|
||||
"area": "Q",
|
||||
"wordlen": "Bit",
|
||||
"db_number": 1,
|
||||
"start": 1,
|
||||
"amount": 1
|
||||
},
|
||||
{
|
||||
"value_name": "布尔2",
|
||||
"value_type": 1,
|
||||
"area": "Q",
|
||||
"wordlen": "Bit",
|
||||
"db_number": 1,
|
||||
"start": 2,
|
||||
"amount": 1
|
||||
},
|
||||
{
|
||||
"value_name": "布尔3",
|
||||
"value_type": 1,
|
||||
"area": "Q",
|
||||
"wordlen": "Bit",
|
||||
"db_number": 1,
|
||||
"start": 3,
|
||||
"amount": 1
|
||||
},
|
||||
{
|
||||
"value_name": "布尔4",
|
||||
"value_type": 1,
|
||||
"area": "Q",
|
||||
"wordlen": "Bit",
|
||||
"db_number": 1,
|
||||
"start": 4,
|
||||
"amount": 1
|
||||
},
|
||||
{
|
||||
"value_name": "整型",
|
||||
"value_type": 3,
|
||||
"area": "DB",
|
||||
"wordlen": "Word",
|
||||
"db_number": 18,
|
||||
"start": 2,
|
||||
"amount": 1
|
||||
},
|
||||
{
|
||||
"value_name": "浮点数",
|
||||
"value_type": 9,
|
||||
"area": "DB",
|
||||
"wordlen": "Real",
|
||||
"db_number": 18,
|
||||
"start": 18,
|
||||
"amount": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := xdh_60t4_e.c xsdh_60a32_e.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
{
|
||||
"device_id": 1,
|
||||
"device_name": "OP01",
|
||||
"communication_type": 0,
|
||||
"socket_config": {
|
||||
"plc_ip": "192.168.250.32",
|
||||
"local_ip": "192.168.250.233",
|
||||
"gateway": "192.168.250.1",
|
||||
"netmask": "255.255.255.0",
|
||||
"port": 502
|
||||
},
|
||||
"protocol_type": 2,
|
||||
"read_period": 100,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "M19",
|
||||
"value_type": 1,
|
||||
"function_code": 5,
|
||||
"start_address": 19,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M20",
|
||||
"value_type": 1,
|
||||
"function_code": 5,
|
||||
"start_address":20,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D500",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 500,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D501",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 501,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D502",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 502,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D503",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 503,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D504",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 504,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M22",
|
||||
"value_type": 1,
|
||||
"function_code": 5,
|
||||
"start_address": 22,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D505",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 505,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D506",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 506,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D507",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 507,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D508",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 508,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D509",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 509,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D510",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 510,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D511",
|
||||
"value_type": 4,
|
||||
"function_code": 6,
|
||||
"start_address": 511,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M23",
|
||||
"value_type": 1,
|
||||
"function_code": 5,
|
||||
"start_address": 23,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M24",
|
||||
"value_type": 1,
|
||||
"function_code": 5,
|
||||
"start_address":24,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M25",
|
||||
"value_type": 1,
|
||||
"function_code": 5,
|
||||
"start_address": 25,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M26",
|
||||
"value_type": 1,
|
||||
"function_code": 5,
|
||||
"start_address": 26,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M29",
|
||||
"value_type": 1,
|
||||
"function_code": 5,
|
||||
"start_address": 29,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D513",
|
||||
"value_type": 4,
|
||||
"function_code": 3,
|
||||
"start_address": 513,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "D515",
|
||||
"value_type": 4,
|
||||
"function_code": 3,
|
||||
"start_address": 515,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M27",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address":27,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "M28",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address":28,
|
||||
"quantity": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
{
|
||||
"device_id": 255,
|
||||
"device_name": "GJ2",
|
||||
"communication_type": 0,
|
||||
"socket_config": {
|
||||
"plc_ip": "192.168.250.45",
|
||||
"local_ip": "192.168.250.233",
|
||||
"gateway": "192.168.250.1",
|
||||
"netmask": "255.255.255.0",
|
||||
"port": 502
|
||||
},
|
||||
"protocol_type": 2,
|
||||
"read_period": 100,
|
||||
"read_item_list": [
|
||||
{
|
||||
"value_name": "QX40.0",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address":0,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "QX40.1",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 1,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "QX40.2",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 2,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "QX40.3",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address":3,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "QX40.4",
|
||||
"value_type": 1,
|
||||
"function_code": 1,
|
||||
"start_address": 4,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"value_name": "QW0",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 0,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "QW1",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 1,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "QW2",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 2,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "QW3",
|
||||
"value_type": 3,
|
||||
"function_code": 3,
|
||||
"start_address": 3,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "QW10",
|
||||
"value_type": 3,
|
||||
"function_code": 4,
|
||||
"start_address": 0,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"value_name": "QW11",
|
||||
"value_type": 3,
|
||||
"function_code": 4,
|
||||
"start_address": 1,
|
||||
"quantity": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 xdh-60t4-e.c
|
||||
* @brief PLC XINJE XDH-60T4-E app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023.4.5
|
||||
*/
|
||||
|
||||
#include <control.h>
|
||||
|
||||
void ControlXDHTest(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
|
||||
if (NULL == modbus_tcp_protocol) {
|
||||
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
|
||||
return;
|
||||
}
|
||||
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
|
||||
ControlProtocolOpen(modbus_tcp_protocol);
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
//ControlProtocolClose(modbus_tcp_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlXDHTest, Xinje Plc XDH_60T4_E Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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 xsdh-60a32-e.c
|
||||
* @brief PLC XINJE XSDH-60A32-E app
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023.3.28
|
||||
*/
|
||||
|
||||
|
||||
#include <control.h>
|
||||
|
||||
void ControlXSDHTest(void)
|
||||
{
|
||||
int i, j = 0;
|
||||
int read_data_length = 0;
|
||||
uint8_t read_data[128] = {0};
|
||||
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
|
||||
if (NULL == modbus_tcp_protocol) {
|
||||
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
|
||||
return;
|
||||
}
|
||||
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
|
||||
|
||||
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
|
||||
ControlProtocolOpen(modbus_tcp_protocol);
|
||||
for (;;) {
|
||||
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
|
||||
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
|
||||
if (read_data_length) {
|
||||
for (j = 0; j < read_data_length; j ++) {
|
||||
printf("j %d data 0x%x\n", j, read_data[j]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
memset(read_data, 0, sizeof(read_data));
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
//ControlProtocolClose(modbus_tcp_protocol);
|
||||
}
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ControlXSDHTest, Xinje Plc XSDH_60A32_E Demo, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_DIR := list
|
||||
SRC_DIR := list circular_area
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += circular_area_app.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := circular_area_app.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import os
|
||||
from building import *
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
cwd = GetCurrentDir()
|
||||
DEPENDS = [""]
|
||||
|
||||
SOURCES = ['circular_area_app.c']
|
||||
path = [cwd]
|
||||
objs = DefineGroup('circular_area', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
||||
Return("objs")
|
||||
|
|
@ -0,0 +1,281 @@
|
|||
/*
|
||||
* 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: circular_area_app.c
|
||||
* @brief: circular area file for applications
|
||||
* @version: 3.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/11/21
|
||||
*
|
||||
*/
|
||||
|
||||
#include "circular_area_app.h"
|
||||
|
||||
/**
|
||||
* This function will return whether the circular_area is full or not
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
*/
|
||||
int CircularAreaAppIsFull(CircularAreaAppType circular_area)
|
||||
{
|
||||
CA_PARAM_CHECK(circular_area);
|
||||
|
||||
if((circular_area->readidx == circular_area->writeidx) && (circular_area->b_status)) {
|
||||
printf("the circular area is full\n");
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will return whether the circular_area is empty or not
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
*/
|
||||
int CircularAreaAppIsEmpty(CircularAreaAppType circular_area)
|
||||
{
|
||||
CA_PARAM_CHECK(circular_area);
|
||||
|
||||
if((circular_area->readidx == circular_area->writeidx) && (!circular_area->b_status)) {
|
||||
//printf("the circular area is empty\n");
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will reset the circular_area and set the descriptor to default
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
*/
|
||||
void CircularAreaAppReset(CircularAreaAppType circular_area)
|
||||
{
|
||||
circular_area->writeidx = 0;
|
||||
circular_area->readidx = 0;
|
||||
circular_area->b_status = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will release the circular_area descriptor and free the memory
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
*/
|
||||
void CircularAreaAppRelease(CircularAreaAppType circular_area)
|
||||
{
|
||||
circular_area->readidx = 0;
|
||||
circular_area->writeidx = 0;
|
||||
circular_area->p_head = NULL;
|
||||
circular_area->p_tail = NULL;
|
||||
circular_area->b_status = 0;
|
||||
circular_area->area_length = 0;
|
||||
|
||||
PrivFree(circular_area->data_buffer);
|
||||
PrivFree(circular_area);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will get the circual_area max length
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
*/
|
||||
uint32_t CircularAreaAppGetMaxLength(CircularAreaAppType circular_area)
|
||||
{
|
||||
CA_PARAM_CHECK(circular_area);
|
||||
|
||||
return circular_area->area_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will get the data length of the circular_area
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
*/
|
||||
uint32_t CircularAreaAppGetDataLength(CircularAreaAppType circular_area)
|
||||
{
|
||||
CA_PARAM_CHECK(circular_area);
|
||||
|
||||
if(CircularAreaAppIsFull(circular_area)) {
|
||||
return circular_area->area_length;
|
||||
} else {
|
||||
return (circular_area->writeidx - circular_area->readidx + circular_area->area_length) % circular_area->area_length;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will return whether it is need to divide the read data into two parts or not
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
* @param data_length output data length
|
||||
*/
|
||||
static uint32_t CircularAreaAppDivideRdData(CircularAreaAppType circular_area, uint32_t data_length)
|
||||
{
|
||||
CA_PARAM_CHECK(circular_area);
|
||||
|
||||
if(circular_area->readidx + data_length <= circular_area->area_length) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will return whether it is need to divide the write data into two parts or not
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
* @param data_length input data length
|
||||
*/
|
||||
static uint32_t CircularAreaAppDivideWrData(CircularAreaAppType circular_area, uint32_t data_length)
|
||||
{
|
||||
CA_PARAM_CHECK(circular_area);
|
||||
|
||||
if(circular_area->writeidx + data_length <= circular_area->area_length) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will read data from the circular_area
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
* @param output_buffer output data buffer poniter
|
||||
* @param data_length output data length
|
||||
*/
|
||||
int CircularAreaAppRead(CircularAreaAppType circular_area, uint8_t *output_buffer, uint32_t data_length)
|
||||
{
|
||||
CA_PARAM_CHECK(circular_area);
|
||||
CA_PARAM_CHECK(output_buffer);
|
||||
CA_CHECK(data_length > 0);
|
||||
|
||||
if(CircularAreaAppIsEmpty(circular_area)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int read_length = (data_length > CircularAreaAppGetDataLength(circular_area)) ? CircularAreaAppGetDataLength(circular_area) : data_length;
|
||||
// if (data_length > CircularAreaAppGetDataLength(circular_area)) {
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
if(CircularAreaAppDivideRdData(circular_area, read_length)) {
|
||||
uint32_t read_len_up = circular_area->area_length - circular_area->readidx;
|
||||
uint32_t read_len_down = read_length - read_len_up;
|
||||
|
||||
memcpy(output_buffer, &circular_area->data_buffer[circular_area->readidx], read_len_up);
|
||||
memcpy(output_buffer + read_len_up, circular_area->p_head, read_len_down);
|
||||
|
||||
circular_area->readidx = read_len_down;
|
||||
} else {
|
||||
memcpy(output_buffer, &circular_area->data_buffer[circular_area->readidx], read_length);
|
||||
circular_area->readidx = (circular_area->readidx + read_length) % circular_area->area_length;
|
||||
}
|
||||
|
||||
circular_area->b_status = 0;
|
||||
|
||||
return read_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will write data to the circular_area
|
||||
*
|
||||
* @param circular_area CircularAreaApp descriptor
|
||||
* @param input_buffer input data buffer poniter
|
||||
* @param data_length input data length
|
||||
* @param b_force whether to force to write data disregard the length limit
|
||||
*/
|
||||
int CircularAreaAppWrite(CircularAreaAppType circular_area, uint8_t *input_buffer, uint32_t data_length, int b_force)
|
||||
{
|
||||
CA_PARAM_CHECK(circular_area);
|
||||
CA_PARAM_CHECK(input_buffer);
|
||||
CA_CHECK(data_length > 0);
|
||||
|
||||
if(CircularAreaAppIsFull(circular_area) && (!b_force)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t write_data_length = circular_area->area_length - CircularAreaAppGetDataLength(circular_area);
|
||||
//data_length = (data_length > write_data_length) ? write_data_length : data_length;
|
||||
if (data_length > write_data_length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(CircularAreaAppDivideWrData(circular_area, data_length)) {
|
||||
uint32_t write_len_up = circular_area->area_length - circular_area->writeidx;
|
||||
uint32_t write_len_down = data_length - write_len_up;
|
||||
|
||||
memcpy(&circular_area->data_buffer[circular_area->writeidx], input_buffer, write_len_up);
|
||||
memcpy(circular_area->p_head, input_buffer + write_len_up, write_len_down);
|
||||
|
||||
circular_area->writeidx = write_len_down;
|
||||
} else {
|
||||
memcpy(&circular_area->data_buffer[circular_area->writeidx], input_buffer, data_length);
|
||||
circular_area->writeidx = (circular_area->writeidx + data_length) % circular_area->area_length;
|
||||
}
|
||||
|
||||
circular_area->b_status = 1;
|
||||
|
||||
if(b_force) {
|
||||
circular_area->readidx = circular_area->writeidx;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct CircularAreaAppOps CircularAreaAppOperations =
|
||||
{
|
||||
CircularAreaAppRead,
|
||||
CircularAreaAppWrite,
|
||||
CircularAreaAppRelease,
|
||||
CircularAreaAppReset,
|
||||
};
|
||||
|
||||
/**
|
||||
* This function will initialize the circular_area
|
||||
*
|
||||
* @param circular_area_length circular_area length
|
||||
*/
|
||||
CircularAreaAppType CircularAreaAppInit(uint32_t circular_area_length)
|
||||
{
|
||||
CA_CHECK(circular_area_length > 0);
|
||||
|
||||
circular_area_length = CA_ALIGN_DOWN(circular_area_length, 8);
|
||||
|
||||
CircularAreaAppType circular_area = PrivMalloc(sizeof(struct CircularAreaApp));
|
||||
if(NULL == circular_area) {
|
||||
printf("CircularAreaAppInit malloc struct circular_area failed\n");
|
||||
PrivFree(circular_area);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CircularAreaAppReset(circular_area);
|
||||
|
||||
circular_area->data_buffer = PrivMalloc(circular_area_length);
|
||||
if(NULL == circular_area->data_buffer) {
|
||||
printf("CircularAreaAppInit malloc circular_area data_buffer failed\n");
|
||||
PrivFree(circular_area->data_buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
circular_area->p_head = circular_area->data_buffer;
|
||||
circular_area->p_tail = circular_area->data_buffer + circular_area_length;
|
||||
circular_area->area_length = circular_area_length;
|
||||
|
||||
printf("CircularAreaAppInit done p_head %8p p_tail %8p length %u\n",
|
||||
circular_area->p_head, circular_area->p_tail, circular_area->area_length);
|
||||
|
||||
circular_area->CircularAreaAppOperations = &CircularAreaAppOperations;
|
||||
|
||||
return circular_area;
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* 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: circular_area_app.h
|
||||
* @brief: function declaration and structure defintion of circular area for applications
|
||||
* @version: 3.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/11/21
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CIRCULAR_AREA_APP_H
|
||||
#define CIRCULAR_AREA_APP_H
|
||||
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CA_CHECK(TRUE_CONDITION) \
|
||||
do \
|
||||
{ \
|
||||
if(!(TRUE_CONDITION)) { \
|
||||
printf("%s CHECK condition is false at line[%d] of [%s] func.\n", #TRUE_CONDITION, __LINE__, __func__);\
|
||||
while(1); \
|
||||
} \
|
||||
}while (0)
|
||||
|
||||
#define CA_PARAM_CHECK(param) \
|
||||
do \
|
||||
{ \
|
||||
if(param == NULL) { \
|
||||
printf("PARAM CHECK FAILED ...%s %d %s is NULL.\n", __func__, __LINE__, #param); \
|
||||
while(1); \
|
||||
} \
|
||||
}while (0)
|
||||
|
||||
#define CA_ALIGN_DOWN(size, align) ((size)/(align)*(align))
|
||||
|
||||
typedef struct CircularAreaApp *CircularAreaAppType;
|
||||
|
||||
struct CircularAreaAppOps
|
||||
{
|
||||
int (*read) (CircularAreaAppType circular_area, uint8_t *output_buffer, uint32_t data_length);
|
||||
int (*write) (CircularAreaAppType circular_area, uint8_t *input_buffer, uint32_t data_length, int b_force);
|
||||
void (*release) (CircularAreaAppType circular_area);
|
||||
void (*reset) (CircularAreaAppType circular_area);
|
||||
};
|
||||
|
||||
struct CircularAreaApp
|
||||
{
|
||||
uint8_t *data_buffer;
|
||||
|
||||
uint32_t readidx;
|
||||
uint32_t writeidx;
|
||||
|
||||
uint8_t *p_head;
|
||||
uint8_t *p_tail;
|
||||
|
||||
uint32_t area_length;
|
||||
int b_status;
|
||||
|
||||
struct CircularAreaAppOps *CircularAreaAppOperations;
|
||||
};
|
||||
|
||||
/*This function will return whether the circular_area is full or not*/
|
||||
int CircularAreaAppIsFull(CircularAreaAppType circular_area);
|
||||
|
||||
/*This function will return whether the circular_area is empty or not*/
|
||||
int CircularAreaAppIsEmpty(CircularAreaAppType circular_area);
|
||||
|
||||
/*This function will reset the circular_area and set the descriptor to default*/
|
||||
void CircularAreaAppReset(CircularAreaAppType circular_area);
|
||||
|
||||
/*This function will release the circular_area descriptor and free the memory*/
|
||||
void CircularAreaAppRelease(CircularAreaAppType circular_area);
|
||||
|
||||
/*This function will read data from the circular_area*/
|
||||
int CircularAreaAppRead(CircularAreaAppType circular_area, uint8_t *output_buffer, uint32_t data_length);
|
||||
|
||||
/*This function will write data to the circular_area*/
|
||||
int CircularAreaAppWrite(CircularAreaAppType circular_area, uint8_t *input_buffer, uint32_t data_length, int b_force);
|
||||
|
||||
/*This function will get the circual_area max length*/
|
||||
uint32_t CircularAreaAppGetMaxLength(CircularAreaAppType circular_area);
|
||||
|
||||
/*This function will get the data length of the circular_area*/
|
||||
uint32_t CircularAreaAppGetDataLength(CircularAreaAppType circular_area);
|
||||
|
||||
/*This function will initialize the circular_area*/
|
||||
CircularAreaAppType CircularAreaAppInit(uint32_t circular_area_length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,3 +1,15 @@
|
|||
SRC_DIR := mnist
|
||||
SRC_DIR :=
|
||||
|
||||
ifeq ($(CONFIG_APP_MNIST),y)
|
||||
SRC_DIR += mnist
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USING_NNOM_DEMOAPP),y)
|
||||
SRC_DIR += nnom_demo
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USING_CMSIS_5_DEMOAPP),y)
|
||||
SRC_DIR += cmsis_5_demo
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
SRC_DIR :=
|
||||
|
||||
ifeq ($(CONFIG_USING_CMSIS_5_NN_DEMOAPP),y)
|
||||
SRC_DIR += cmsisnn-cifar10
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USING_CMSIS_5_NN_DEMOAPP_VEG_CLASSIFY),y)
|
||||
SRC_DIR += cmsisnn_vegetable_classify
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := demo/cmsisnn_demo.c demo/tjpgd.c model/m4/nn.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# ISSUE
|
||||
|
||||
Code in Lib `tjpgd` might be redefined in RT-thread(which has not been tested). if occurs, please try to temporarily delete `tjpgd.c` in dir and `tjpgd.h` in ../model/m4/.
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,93 @@
|
|||
/*----------------------------------------------------------------------------/
|
||||
/ TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2019
|
||||
/----------------------------------------------------------------------------*/
|
||||
#ifndef DEF_TJPGDEC
|
||||
#define DEF_TJPGDEC
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* System Configurations */
|
||||
|
||||
#define JD_SZBUF 512 /* Size of stream input buffer */
|
||||
#define JD_FORMAT 1 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */
|
||||
#define JD_USE_SCALE 1 /* Use descaling feature for output */
|
||||
#define JD_TBLCLIP 1 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */
|
||||
|
||||
#define JD_SCALE 2 /* 0:1/1 1:1/2 2:1/4 3:1/8 */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) /* Main development platform */
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned long uint32_t;
|
||||
typedef long int32_t;
|
||||
#else
|
||||
#include "stdint.h"
|
||||
#endif
|
||||
|
||||
/* Error code */
|
||||
typedef enum
|
||||
{
|
||||
JDR_OK = 0, /* 0: Succeeded */
|
||||
JDR_INTR, /* 1: Interrupted by output function */
|
||||
JDR_INP, /* 2: Device error or wrong termination of input stream */
|
||||
JDR_MEM1, /* 3: Insufficient memory pool for the image */
|
||||
JDR_MEM2, /* 4: Insufficient stream input buffer */
|
||||
JDR_PAR, /* 5: Parameter error */
|
||||
JDR_FMT1, /* 6: Data format error (may be damaged data) */
|
||||
JDR_FMT2, /* 7: Right format but not supported */
|
||||
JDR_FMT3 /* 8: Not supported JPEG standard */
|
||||
} JRESULT;
|
||||
|
||||
|
||||
|
||||
/* Rectangular structure */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t left, right, top, bottom;
|
||||
} JRECT;
|
||||
|
||||
|
||||
|
||||
/* Decompressor object structure */
|
||||
typedef struct JDEC JDEC;
|
||||
struct JDEC
|
||||
{
|
||||
uint16_t dctr; /* Number of bytes available in the input buffer */
|
||||
uint8_t *dptr; /* Current data read ptr */
|
||||
uint8_t *inbuf; /* Bit stream input buffer */
|
||||
uint8_t dmsk; /* Current bit in the current read byte */
|
||||
uint8_t scale; /* Output scaling ratio */
|
||||
uint8_t msx, msy; /* MCU size in unit of block (width, height) */
|
||||
uint8_t qtid[3]; /* Quantization table ID of each component */
|
||||
int16_t dcv[3]; /* Previous DC element of each component */
|
||||
uint16_t nrst; /* Restart inverval */
|
||||
uint16_t width, height; /* Size of the input image (pixel) */
|
||||
uint8_t *huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
|
||||
uint16_t *huffcode[2][2]; /* Huffman code word tables [id][dcac] */
|
||||
uint8_t *huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
|
||||
int32_t *qttbl[4]; /* Dequantizer tables [id] */
|
||||
void *workbuf; /* Working buffer for IDCT and RGB output */
|
||||
uint8_t *mcubuf; /* Working buffer for the MCU */
|
||||
void *pool; /* Pointer to available memory pool */
|
||||
uint16_t sz_pool; /* Size of momory pool (bytes available) */
|
||||
uint16_t (*infunc)(JDEC *, uint8_t *, uint16_t); /* Pointer to jpeg stream input function */
|
||||
void *device; /* Pointer to I/O device identifiler for the session */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* TJpgDec API functions */
|
||||
JRESULT jd_prepare (JDEC *, uint16_t(*)(JDEC *, uint8_t *, uint16_t), void *, uint16_t, void *);
|
||||
JRESULT jd_decomp (JDEC *, uint16_t(*)(JDEC *, void *, JRECT *), uint8_t);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TJPGDEC */
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := cmsisnn_vegetable_classify.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
SRC_FILES :=
|
||||
ifeq ($(CONFIG_APP_MNIST),y)
|
||||
SRC_FILES := \
|
||||
main.cpp \
|
||||
mnistmain.c
|
||||
CPPPATHS += -I.
|
||||
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
ifeq ($(CONFIG_USING_NNOM_DEMOAPP),y)
|
||||
SRC_DIR := mnist_nnom
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := main.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -71,7 +71,9 @@ void mnist_nnom(int argc, char **argv)
|
|||
printf("Predicted label: %d\n", predic_label);
|
||||
printf("Probability: %d%%\n", (int)(prob * 100));
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
PRIV_SHELL_CMD_FUNCTION(mnist_nnom, a mnist_nnom test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(mnist_nnom, nnom mnist demo and image number should be followed);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ void HumiHs300x(void)
|
|||
int32_t humidity;
|
||||
struct SensorQuantity *humi = SensorQuantityFind(SENSOR_QUANTITY_HS300X_HUMIDITY, SENSOR_QUANTITY_HUMI);
|
||||
SensorQuantityOpen(humi);
|
||||
for (i = 0; i < 100; i ++) {
|
||||
for (i = 0; i < 10; i ++) {
|
||||
humidity = SensorQuantityReadValue(humi);
|
||||
printf("Humidity : %d.%d %%RH\n", humidity/10, humidity%10);
|
||||
PrivTaskDelay(5000);
|
||||
PrivTaskDelay(500);
|
||||
}
|
||||
SensorQuantityClose(humi);
|
||||
}
|
||||
|
|
@ -30,14 +30,14 @@ void TempHs300x(void)
|
|||
int32_t temperature;
|
||||
struct SensorQuantity *temp = SensorQuantityFind(SENSOR_QUANTITY_HS300X_TEMPERATURE, SENSOR_QUANTITY_TEMP);
|
||||
SensorQuantityOpen(temp);
|
||||
for (i = 0; i < 100; i ++) {
|
||||
for (i = 0; i < 10; i ++) {
|
||||
temperature = SensorQuantityReadValue(temp);
|
||||
if (temperature > 0)
|
||||
printf("Temperature : %d.%d ℃\n", temperature/10, temperature%10);
|
||||
else
|
||||
printf("Temperature : %d.%d ℃\n", temperature/10, -temperature%10);
|
||||
|
||||
PrivTaskDelay(5000);
|
||||
PrivTaskDelay(500);
|
||||
}
|
||||
|
||||
SensorQuantityClose(temp);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,14 @@ void WindDirectionQsFx(void)
|
|||
struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION);
|
||||
SensorQuantityOpen(wind_direction);
|
||||
PrivTaskDelay(2000);
|
||||
uint16_t result = SensorQuantityReadValue(wind_direction);
|
||||
printf("wind direction : %d degree\n", result);
|
||||
int result = 0;
|
||||
for(int i=0;i<2000;i++)
|
||||
{
|
||||
result = 0;
|
||||
PrivTaskDelay(1000);
|
||||
result = SensorQuantityReadValue(wind_direction);
|
||||
if(result > 0)
|
||||
printf("wind direction : %d degree\n", result);
|
||||
}
|
||||
SensorQuantityClose(wind_direction);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,14 @@ void WindSpeedQsFs(void)
|
|||
struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED);
|
||||
SensorQuantityOpen(wind_speed);
|
||||
PrivTaskDelay(2000);
|
||||
uint16_t result = SensorQuantityReadValue(wind_speed);
|
||||
printf("wind speed : %d.%d m/s\n", result/10, result%10);
|
||||
int result = 0;
|
||||
for(int i=0;i<2000;i++)
|
||||
{
|
||||
result = 0;
|
||||
PrivTaskDelay(1000);
|
||||
result = SensorQuantityReadValue(wind_speed);
|
||||
if(result > 0)
|
||||
printf("wind speed : %d.%d m/s\n", result/10, result%10);
|
||||
}
|
||||
SensorQuantityClose(wind_speed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := ttf_demo.c lv_example_tiny_ttf_1.c lv_example_tiny_ttf_2.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
## Tiny TTF font engine
|
||||
用于在触摸屏上渲染矢量字体,若要使用该引擎,需开启LVGL。
|
||||
### Usage
|
||||
在`lv_conf.h`中开启`LV_USE_TINY_TTF`,可以使用`lv_tiny_ttf_create_data(data, data_size, line_height)`创建字体,创建字体后像LVGL正常字体一样使用。
|
||||
默认情况下,TTF或者OTF文件必须作为数组嵌入到程序,见`ubuntu_font`,如果要从sd卡中读取文件,需开启`LV_TINY_TTF_FILE_SUPPORT`和`LV_USE_FS_POSIX`。
|
||||
|
||||
> 注意:从sd卡中读取字库文件会比较慢,请谨慎使用!
|
||||
|
||||
默认情况下,字体使用4KB缓存来加速渲染,可以使用`lv_tiny_ttf_create_data_ex(data, data_size, line_height, cache_size)`或者`lv_tiny_ttf_create_file_ex(path, line_height, cache_size)`更改此大小
|
||||
。
|
||||
### API
|
||||
见 xiuos/APP_Framework/lib/lvgl/src/extra/libs/tiny_ttf/lv_tiny_ttf.h
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* @file lv_example_tiny_ttf.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_EXAMPLE_TINY_TTF_H
|
||||
#define LV_EXAMPLE_TINY_TTF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_example_tiny_ttf_1(void);
|
||||
void lv_example_tiny_ttf_2(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_EXAMPLE_TINY_TTF_H*/
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#include <../../lib/lvgl/examples/lv_examples.h>
|
||||
#if LV_USE_TINY_TTF && LV_BUILD_EXAMPLES
|
||||
|
||||
#include "ubuntu_font_ch.h"
|
||||
/**
|
||||
* Load a font with Tiny_TTF
|
||||
*/
|
||||
void lv_example_tiny_ttf_1(void)
|
||||
{
|
||||
/*Create style with the new font*/
|
||||
static lv_style_t style;
|
||||
lv_style_init(&style);
|
||||
lv_font_t * font = lv_tiny_ttf_create_data(ubuntu_font, sizeof(ubuntu_font), 35);
|
||||
lv_style_set_text_font(&style, font);
|
||||
lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER);
|
||||
|
||||
/*Create a label with the new style*/
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_obj_add_style(label, &style, 0);
|
||||
lv_label_set_text(label, "你好世界\nI'm a font\ncreated\nwith Tiny TTF");
|
||||
lv_obj_center(label);
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue