如何在VxWorks shell中编写文件

时间:2012-09-13 17:26:38

标签: file-io vxworks

我正在尝试使用类似

的东西在VxWorks中编写文件
saveFd = open("myfile.txt",0x102, 0777 )
oldFd = ioGlobalStdGet(1)
ioGlobalStdSet(1, saveFd)
d 0xfea00100, 4 
ioGlobalStdSet(1, oldFd)

但我无法执行文件创建/编写。 这是输出:

-> saveFd = open("myfile.txt",0x102, 0777 )
saveFd = 0x1fbfb040: value = -1 = 0xffffffff
-> ioGlobalStdSet(1, saveFd)
dvalue = -1 = 0xffffffff

如何创建具有所需输出的文件? 提前谢谢。

1 个答案:

答案 0 :(得分:2)

传递给'open'的'flags'参数有问题。正确的访问类型:

O_RDONLY (0)    (or READ)   - open for reading only.
O_WRONLY (1)    (or WRITE)  - open for writing only.
O_RDWR (2)  (or UPDATE) - open for reading and writing.
O_CREAT (0x0200)        - create a file.

传递给open的标志应该是'OR'标志。像这样:

O_CREAT | O_RDWR = 0x202

使用此参数,您可能会得到类似的内容(如果您正确连接了主机ftp):

-> saveFd = open("myfile.txt",0x202,0777)
New symbol "saveFd" added to kernel symbol table.
saveFd = 0x8a9bf90: value = 5 = 0x5
->

(确保您在ftp主机服务器上授予了写入权限。)