Go to Post You are not allowed to think outside of the box, but you are allowed to think diagonally in the box. - eugenebrooks [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 8 votes, 5.00 average. Display Modes
  #16   Spotlight this post!  
Unread 19-01-2010, 18:11
davidalln's Avatar
davidalln davidalln is offline
World's Worst Coder
AKA: David Allen
FRC #2415 (The Westminster Wiredcats)
Team Role: Programmer
 
Join Date: Mar 2009
Rookie Year: 2008
Location: Atlanta, GA
Posts: 108
davidalln is on a distinguished road
Send a message via AIM to davidalln
Re: ofstream (standard C++ file output) not working

Did you or anyone else successfully get a log running on their cRio? We are trying to do something similar, and we have had consistent success with creating the file but very spotty success when writing to it (depending on where the lines are added in the code). Sometimes it works sometimes it doesn't.
__________________
SANTOSH ANDREW DECKER RICK WYNNIE SEAN DEREK MATT
(alamo (semis), p'tree (CHAMPS!), nc (CHAMPS!), newton (quarters))


Best four years of my life. Thanks to everyone who made it happen.
Reply With Quote
  #17   Spotlight this post!  
Unread 25-01-2010, 14:37
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: ofstream (standard C++ file output) not working

I know this is quite a bump, but now I'm even having problems using C file I/O with FILE* pointers. I've called Priv_SetWriteAllowed(1) and still weird stuff happens. Sometimes things work fine, but there's a boat load of issues most of the time:
  • While some files write fine, others don't write at all, and still others write nothing but whitespace.
  • fwrite() reformats strings for some bizarre reason. Example: I wanted to print some formatted data into a .csv (comma seperated value) file. I used sprintf() to print some floats with some commas, carraige returns, and line feeds. Calling printf() on the string created with sprintf() yields what I would expect, but when I write the exact same string to the file with fwrite(), every float is smaller by two orders of magnitude.

Does anybody have any idea what could be causing this? It's making things very difficult and I can't imagine why it would be happening.
__________________

Last edited by slavik262 : 25-01-2010 at 19:47.
Reply With Quote
  #18   Spotlight this post!  
Unread 25-01-2010, 22:16
TheDominis TheDominis is offline
Registered User
FRC #2152
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Port Orange, Florida
Posts: 88
TheDominis has a spectacular aura aboutTheDominis has a spectacular aura about
Re: ofstream (standard C++ file output) not working

I've found that some parts of the STL do not work with well/at all Wind River. I tried to use std::fstream to store some packet data, but had to use c-style file I/O for it to work.
Reply With Quote
  #19   Spotlight this post!  
Unread 26-01-2010, 00:15
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: ofstream (standard C++ file output) not working

Quote:
Originally Posted by TheDominis View Post
I've found that some parts of the STL do not work with well/at all Wind River. I tried to use std::fstream to store some packet data, but had to use c-style file I/O for it to work.
C-style file I/O isn't working for me at all either...
__________________
Reply With Quote
  #20   Spotlight this post!  
Unread 26-01-2010, 13:35
TheDominis TheDominis is offline
Registered User
FRC #2152
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Port Orange, Florida
Posts: 88
TheDominis has a spectacular aura aboutTheDominis has a spectacular aura about
Re: ofstream (standard C++ file output) not working

Quote:
Originally Posted by slavik262 View Post
C-style file I/O isn't working for me at all either...
Interesting. What permissions are you using? I used "w".
Reply With Quote
  #21   Spotlight this post!  
Unread 26-01-2010, 16:37
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: ofstream (standard C++ file output) not working

I was using w. I guess I could try wb or w+, but I was just writing text...
__________________
Reply With Quote
  #22   Spotlight this post!  
Unread 31-01-2010, 19:57
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: ofstream (standard C++ file output) not working

I (finally!) got a chance to test this again.
code (in auto)
Code:
ofstream txt;
txt.open("test.txt");
txt<<"IT WORKS!!!"<<endl;
for some reason, (without the priv_setwrite stuff) it worked 2 of the three times i tested it. No difference except different flies
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #23   Spotlight this post!  
Unread 01-02-2010, 10:04
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: ofstream (standard C++ file output) not working

Exactly! That's what's so odd about it. It's not even that it doesn't work, but that it works inconsistantly with no changes except filenames. I have no idea what could be causing the problem. It's so frustrating.

On the note of standard library things failing, does anyone have issues with std::cout? printf() works fine, but cout refuses to print a thing. I'm using the VxWorks Target Console in WindRiver.
__________________
Reply With Quote
  #24   Spotlight this post!  
Unread 01-02-2010, 15:10
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: ofstream (standard C++ file output) not working

Quote:
Originally Posted by slavik262 View Post
Exactly! That's what's so odd about it. It's not even that it doesn't work, but that it works inconsistantly with no changes except filenames. I have no idea what could be causing the problem. It's so frustrating.

On the note of standard library things failing, does anyone have issues with std::cout? printf() works fine, but cout refuses to print a thing. I'm using the VxWorks Target Console in WindRiver.
cout is mis-directed most of the time (strange), but cerr is working fine for us. we rdbuf it though,
streambuf *cerbuf=cerr.rdbuf();
cout.rdbuf(cerbuf);

EDIT: now that I think about it, the getting started guided called it printf/cout output. strange they did not get it working with that title
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #25   Spotlight this post!  
Unread 02-02-2010, 18:10
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: ofstream (standard C++ file output) not working

Quote:
Originally Posted by slavik262 View Post
On the note of standard library things failing, does anyone have issues with std::cout? printf() works fine, but cout refuses to print a thing. I'm using the VxWorks Target Console in WindRiver.
This is a known issue with the Target Console. cout does not work, but printf does. If you are using the Serial console, I believe the cout will work. Probably with NetConsole as well, but I haven't tried it. I tend to completely avoid things that work "in certain cases".

It never bothered me, though since I like to format the things I print and inserting magic format objects feels like a lame hack compared to a concise format string. Oh well... preferences, I guess.

-Joe
Reply With Quote
  #26   Spotlight this post!  
Unread 02-02-2010, 18:14
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: ofstream (standard C++ file output) not working

Quote:
Originally Posted by byteit101 View Post
...for some reason, (without the priv_setwrite stuff) it worked 2 of the three times i tested it. No difference except different flies
This sounds like a race condition to me. I know there are several files in the vision code (and probably others) that call Priv_SetWriteFileAllowed in some cases. Perhaps in the test runs where it works, that code happened to win the race against your test code.

-Joe
Reply With Quote
  #27   Spotlight this post!  
Unread 03-02-2010, 08:37
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: ofstream (standard C++ file output) not working

I agree that behavior like this sounds like a race condition, but why would a race occur for a file stream, especially to a file that's not used by any other part of the system?
__________________

Last edited by slavik262 : 03-02-2010 at 10:37.
Reply With Quote
  #28   Spotlight this post!  
Unread 03-02-2010, 15:11
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: ofstream (standard C++ file output) not working

Quote:
Originally Posted by slavik262 View Post
I agree that behavior like this sounds like a race condition, but why would a race occur for a file stream, especially to a file that's not used by any other part of the system?
I was under the impression that Priv_SetWriteFileAllowed was a global system setting, not associated with any particular task or file handle. If the fopen is racing with Priv_SetWriteFileAllowed, it doesn't matter who is calling each of them.

-Joe
Reply With Quote
  #29   Spotlight this post!  
Unread 03-02-2010, 18:06
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: ofstream (standard C++ file output) not working

Quote:
Originally Posted by jhersh View Post
I was under the impression that Priv_SetWriteFileAllowed was a global system setting, not associated with any particular task or file handle. If the fopen is racing with Priv_SetWriteFileAllowed, it doesn't matter who is calling each of them.

-Joe
From my understanding, you call Priv_SetWriteFileAllowed(1) to allow a file write operation and then call fopen() as usual.
__________________
Reply With Quote
  #30   Spotlight this post!  
Unread 04-02-2010, 02:25
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: ofstream (standard C++ file output) not working

Quote:
Originally Posted by slavik262 View Post
From my understanding, you call Priv_SetWriteFileAllowed(1) to allow a file write operation and then call fopen() as usual.
Yes... and...

The way I understand it, it enables write access to the filesystem as a whole. In other words, if no one calls it, noone can write to the disk. If anyone calls it, then anyone can write to the disk (or open for write).
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
p2 not working? Lone_Wolf92c Programming 5 22-02-2008 08:49
IR Board Not Working (But NOT Fried) itsme Electrical 2 18-02-2008 06:11
Beware - transmission output shaft is not 5/8"! jskene Kit & Additional Hardware 30 13-02-2006 14:01
Drive() Not a Standard Toolset in EasyC? Chris_Elston Programming 3 08-02-2006 09:01
Beware - transmission output shaft is not 5/8"! jskene Technical Discussion 3 19-01-2006 14:24


All times are GMT -5. The time now is 13:37.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi