1

我正在尝试使用类似的东西在 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

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

4

1 回答 1

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 的标志应该“或”标志。像这样:

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 主机服务器上授予了写入权限。)

于 2012-12-20T09:40:43.290 回答