herrycxy
驱动牛犊
驱动牛犊
  • 注册日期2004-04-12
  • 最后登录2004-10-18
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2416回复:4

VxWorks中读写文件的问题

楼主#
更多 发布于:2004-08-03 10:25
初学VxWorks,我想在VxWorks Simulator里读写位于主机的文件,target server如何设置?fopen()函数所用的文件目录又是什么形式的?请高人指点,最好举个简单的例子,谢谢!!
ceiba
驱动牛犊
驱动牛犊
  • 注册日期2004-07-27
  • 最后登录2008-04-22
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2004-08-04 15:12
呵呵,我也是初学VxWorks,刚刚解决了这个问题。在target server---configure里面可以设置映射的路径,就是在
target server properties选择target server file system
在里面设置路径作为根目录,那么用open等函数创建的文件就可以在相应的目录中看到了。
不过对这个问题我也是一知半解, :)
herrycxy
驱动牛犊
驱动牛犊
  • 注册日期2004-04-12
  • 最后登录2004-10-18
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2004-08-04 17:59
多谢楼上,我也是这样做的,就是没有成功,
郁闷啊
herrycxy
驱动牛犊
驱动牛犊
  • 注册日期2004-04-12
  • 最后登录2004-10-18
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地板#
发布于:2004-08-06 15:20
楼上的麻烦说具体点,谢谢
ceiba
驱动牛犊
驱动牛犊
  • 注册日期2004-07-27
  • 最后登录2008-04-22
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2004-08-09 14:32
不知道你的问题具体是什么,下面是我的测试程序,运行成功的,你试试吧!
/*-
 * This is test program for Berkeley DB
 *
 *
 * by Chen Xiaowei at 2004/07/28 13:43:53
 */

#include <sys/types.h>
#include <ioLib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main()

{

int fd1,fd2;

char buffer[10] ={'a','b','c','d','e','f','g','h','i','j'} ;

fd1 = open ("host:/DB/temp.txt", O_CREAT|O_RDWR, 0644);
if(fd1 == ERROR){
printf("create file error and error is:%d\n",fd1);
}else{
writefile(buffer,fd1);
close(fd1);
}

fd2 = open ("host:/DB/temp.txt", 0, 0644);
if(fd2 == ERROR){
printf("open file error and error is:%d\n",fd2);
}else{
readfile(buffer,fd2);
close(fd2);
}

return 0;

}

writefile(char *buf,int fd)
{
  int h;
h = write(fd,buf,10);
if(h == ERROR)
printf("write error\n");
else
printf("write file\n");
printf("write h is %d\n",h);
return;
}

readfile(char *buf,int fd)
{
int h;
h = read(fd,buf,10);
if(h == ERROR)
printf("read error\n");
else{
printf("read h is %d\n",h);
printf("string is %s\n",buf);
}
return;
}

我现在也被VxWorks弄的焦头烂额呢,不知道该咋办好 :(
游客

返回顶部