Added dynamic and static RAM file systems to use with file objects. (#1058)
* Added dynamic RAM file system to use with basic bacnet file object. * Added static RAM file system to use with basic bacnet file object. * Added check for read-only during AtomicWriteFile service API for BACnet File object. * Change stm32f4xx example to use static RAM file system. * Fixed bacfile_count() function return type
This commit is contained in:
+26
-4
@@ -15,7 +15,10 @@
|
||||
#include "stm32f4xx_rcc.h"
|
||||
#include "stm32f4xx_rng.h"
|
||||
#include "system_stm32f4xx.h"
|
||||
#include "bacnet/basic/object/bacfile.h"
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/object/program.h"
|
||||
#include "bacnet/basic/sys/bsramfs.h"
|
||||
#include "bacnet/basic/sys/mstimer.h"
|
||||
#include "bacnet/basic/sys/ringbuf.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
@@ -88,6 +91,7 @@ static const char *UBASIC_Program_3 =
|
||||
"end;";
|
||||
/* uBASIC data tree for each program running */
|
||||
static struct ubasic_data UBASIC_Data[3];
|
||||
static struct bacnet_file_sramfs_data Static_Files[3];
|
||||
|
||||
/**
|
||||
* @brief Called from _write() function from printf and friends
|
||||
@@ -105,6 +109,7 @@ int __io_putchar(int ch)
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
size_t i;
|
||||
/*At this stage the microcontroller clock setting is already configured,
|
||||
this is done through SystemInit() function which is called from startup
|
||||
file (startup_stm32f4xx.s) before to branch to application main.
|
||||
@@ -165,11 +170,28 @@ int main(void)
|
||||
}
|
||||
/* initialize application layer*/
|
||||
bacnet_init();
|
||||
/* configure a program */
|
||||
bacfile_sramfs_init();
|
||||
/* configure the program object and loop time */
|
||||
Program_UBASIC_Init(10);
|
||||
Program_UBASIC_Create(1, &UBASIC_Data[0], UBASIC_Program_1);
|
||||
Program_UBASIC_Create(2, &UBASIC_Data[1], UBASIC_Program_2);
|
||||
Program_UBASIC_Create(3, &UBASIC_Data[2], UBASIC_Program_3);
|
||||
/* create the uBASIC programs and link to file objects */
|
||||
Static_Files[0].data = (char *)UBASIC_Program_1;
|
||||
Static_Files[0].size = strlen(UBASIC_Program_1);
|
||||
Static_Files[0].pathname = "/program1.bas";
|
||||
Static_Files[1].data = (char *)UBASIC_Program_2;
|
||||
Static_Files[1].size = strlen(UBASIC_Program_2);
|
||||
Static_Files[1].pathname = "/program2.bas";
|
||||
Static_Files[2].data = (char *)UBASIC_Program_3;
|
||||
Static_Files[2].size = strlen(UBASIC_Program_3);
|
||||
Static_Files[2].pathname = "/program3.bas";
|
||||
for (i = 0; i < ARRAY_SIZE(Static_Files); i++) {
|
||||
bacfile_create(1 + i);
|
||||
bacfile_pathname_set(1 + i, Static_Files[i].pathname);
|
||||
bacfile_read_only_set(1 + i, true);
|
||||
bacfile_sramfs_add(&Static_Files[i]);
|
||||
Program_UBASIC_Create(1 + i, &UBASIC_Data[i], Static_Files[i].data);
|
||||
Program_Instance_Of_Set(1 + i, Static_Files[i].pathname);
|
||||
}
|
||||
/* loop forever */
|
||||
for (;;) {
|
||||
led_task();
|
||||
bacnet_task();
|
||||
|
||||
Reference in New Issue
Block a user