Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Very simple question on open() and fopen() failure

869 views
Skip to first unread message

Marco Zandonadi

unread,
Mar 4, 2000, 3:00:00 AM3/4/00
to
Hello,
I have VXWorks 5.4 and my target is VXSim for Windows. My problem is
that open() and fopen() always fail. Here's what I did.

- I created a new project
- I double clicked "Create a bootable VXWorks image (custom configured)"
- I pressed Next
- I selected "An existing project" and pressed Next
- I pressed Finish

- I double clicked on userAppInit.c and modified it as follows:

#include <stdio.h>
...
void usrAppInit (void)
{
...
FILE * f = fopen ("myfile", "r");
if (!f)
printf ("File not found!\n");
else
printf ("File found!\n");
}

- I selected Build (compilation works ok)
- I opened Object Modules, right clicked on vxWorks.exe and selected
Start 'vxWorks.exe'

The simulator starts properly and prints out File not found! even though
myfile is in the same directory as vxWorks.exe. I also tried opening
other files like c:/autoexec.bat but the result is the same. Note that I
didn't touch the default VxWorks component configuration.

Does anybody know what I'm missing?

Thanks very much in advance.

Marco Zandonadi

joke

unread,
Mar 6, 2000, 3:00:00 AM3/6/00
to
you can use fopen("host:/YourFileDirectory/YourFile","r").

ntPassFileSystem is needed.
type iosDevShow in the shell
host = your disk that tornado installed .

Marco Zandonadi <myr...@pacbell.net> wrote in message
news:38C19191...@pacbell.net...

Marco Zandonadi

unread,
Mar 6, 2000, 3:00:00 AM3/6/00
to
> you can use fopen("host:/YourFileDirectory/YourFile","r").
>
> ntPassFileSystem is needed.
> type iosDevShow in the shell
> host = your disk that tornado installed .

Thank you very much, that's what I needed.

I still have one more problem, though. I can successfully create files
with creat() but I can't write() to them. Every write() call on a file
descriptor returned by creat() returns -1.

Any suggestions will be greatly appreciated.

Thank you

Marco

Marco Zandonadi

unread,
Mar 6, 2000, 3:00:00 AM3/6/00
to
Hi Harvey,

> You should create the file by window NT command at first, then you can use
> creat() and write() functions.

what do you mean by "create the file by window NT command"? If you mean
that I should use a DOS shell I can't do it because I need to open
several tens of files each time I run my program, so it definitely has
to be done inside the program (also these files have different names
each time I run my program).

Thanks.

Marco

Mario Semo

unread,
Mar 6, 2000, 3:00:00 AM3/6/00
to
hello,

for some information (regarding VxWorks / VxSim bugs) to this topic see me
about 5 days old reply to someone here to the subject:

Pass Through Filesystem for VxSim

you have to use the correct fixes and patches at least.

--
regards, Mario Semo. http://www.kirchnersoft.com
Marco Zandonadi wrote in message <38C19191...@pacbell.net>...

Harvey Tang

unread,
Mar 7, 2000, 3:00:00 AM3/7/00
to
You should create the file by window NT command at first, then you can use
creat() and write() functions.
I haven't used creat() and write(),I used fopen() and fprintf() etc.

Marco Zandonadi <myr...@nospampacbell.net> wrote in message
news:38C41184...@nospampacbell.net...

Harvey Tang

unread,
Mar 7, 2000, 3:00:00 AM3/7/00
to
Yes, you must create the file by DOS shell command ,It seems a bug of
VxSim.If your program running at real target board ,It should be ok ,but
"host" need be replaced by your hostname that Tornado2 is running .

Marco Zandonadi <myr...@nospampacbell.net> wrote in message
news:38C461D6...@nospampacbell.net...
> Hi Harvey,

>
> > You should create the file by window NT command at first, then you can
use
> > creat() and write() functions.
>

Mario Semo

unread,
Mar 7, 2000, 3:00:00 AM3/7/00
to
isnt this exactly what i wrote?

ok, here is the patch description:

SPR 27918

IDE:
Component: tornado-vxsim
RTOS: Version:
Product Name: Tornado Release#: 2.0 Release Status: FCS
Products Affected: Tornado
Host: Intel x86/Pentium HostOs: HostOSRev: 4.0
Arch Family: SIM NT Arch CPU: SIM NT BSP: Ver:

DESCRIPTION

Using Tornado 2 FCS on Windows NT, simpc target.

The open flags values which VxWorks uses differ from those used by
Windows NT, and ntPassFsLib does not convert between them. For
instance, the O_CREAT flag has value 0x200 in VxWorks, but
value 0x100 in Windows NT. This causes both open (...,O_CREAT | ..., ...)


and creat() to fail on the host: ntPassFsLib device.


WORKAROUND

A patch for this SPR may be downloaded via the Web from the
patches section on WindSurf, or by contacting WRS Customer
Support. The patch title is,
"27918 ntPassFsLib file creation patch".


--
regards, Mario Semo. http://www.kirchnersoft.com

Marco Zandonadi wrote in message <38C41184...@nospampacbell.net>...

0 new messages