How can I write a file in VxWorks shell

I am trying to write a file in VxWorks using something like

saveFd = open("myfile.txt",0x102, 0777 )
oldFd = ioGlobalStdGet(1)
ioGlobalStdSet(1, saveFd)
d 0xfea00100, 4 
ioGlobalStdSet(1, oldFd)

But I am unnable to perform the file creation / writing. Here is the output:

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

How can I create a file with the desired output? Thanks in advance.

Upvotes: 1

Views: 9779

Answers (1)

Knight of Ni
Knight of Ni

Reputation: 1830

You have something wrong with 'flags' parameter passed to 'open'. Correct type of accesses:

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.

The flags passed to open should 'OR' the flags. Like this:

O_CREAT | O_RDWR = 0x202

With this parameter you may get something like this (if you have a host ftp properly connected):

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

(Make sure you have a write permission granted on the ftp host server.)

Upvotes: 2

Related Questions