summaryrefslogtreecommitdiff
path: root/bsp/mini2440
diff options
context:
space:
mode:
authorqiuyiuestc <[email protected]>2010-04-21 16:59:06 +0000
committerqiuyiuestc <[email protected]>2010-04-21 16:59:06 +0000
commit38c432620f3c1df2e88dc892dbd24ef19a198bd2 (patch)
treefa99ba53b1b63c04aaba7d701e391bcddf88ae6b /bsp/mini2440
parent146d88b0507c173919e1e8f8dee9f5c9157731fc (diff)
module developing
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@663 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp/mini2440')
-rw-r--r--bsp/mini2440/run_module.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/bsp/mini2440/run_module.c b/bsp/mini2440/run_module.c
index d7fd62e2bf..41452821f4 100644
--- a/bsp/mini2440/run_module.c
+++ b/bsp/mini2440/run_module.c
@@ -14,6 +14,7 @@
#include <rtthread.h>
#include <dfs_posix.h>
+#include "string.h"
#ifdef RT_USING_FINSH
#include <finsh.h>
@@ -22,18 +23,21 @@ static char buffer[4096];
void run_module(const char* filename)
{
int fd, length;
- struct dfs_stat s;
-
+ char *module_name;
+
+ rt_memset(buffer, 0, 4096);
fd = open(filename, O_RDONLY, 0);
length = read(fd, buffer, 4096);
- if (length == 0)
+ if (length <= 0)
{
rt_kprintf("check: read file failed\n");
close(fd);
return;
}
-
- rt_module_load(buffer, filename);
+ rt_kprintf("read %d bytes from file\n", length);
+ module_name = strrchr(filename, '/');
+ rt_module_load(buffer, ++module_name);
+ close(fd);
}
FINSH_FUNCTION_EXPORT(run_module, run module from file);