Go to Post how can anyone Not Notice An entierly Pink Team? - Tytus Gerrish [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-03-2004, 19:59
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
stdlib.h for Dashboard Program

So yeah, SBPLI is tomorrow, still ironing the bugs out of that Dashboard I have .

I think it's working perfectly, except for one tiny error. After a seemingly random (although rather precise) number of loops, fopen just doesn't work.

I have a line like this...

data = fopen("data.txt","w");

It's supposed to open a string to a file, works great, most of the time. After a certain number of loops though, it stops working, until I restart my program. This takes no more than 30 seconds to pop up, unacceptable for a Dashboard (5 minutes would be, but less than two minutes, no).

So, my question is, what other way (besides fstream) is there to output to a file? I need something that's rather generic and easy to implement, but at the moment, I'm open to any suggestions just so this thing will work. I'll even try using fstream again, but that took so long to convert everything from fstream to stdlib.h...

Speedy answers make me happy, cause I don't want to be up all night working on this :-p.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #2   Spotlight this post!  
Unread 17-03-2004, 20:55
JimWright949's Avatar
JimWright949 JimWright949 is offline
The Owen Day of Seattle
AKA: Jim Wright
FRC #4542 (Titanium Talons)
Team Role: Mentor
 
Join Date: Sep 2003
Rookie Year: 2003
Location: Redmond, WA
Posts: 94
JimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to behold
Re: stdlib.h for Dashboard Program

fopen opens a file for writing (in your case). You will only need to perform this once. To write a string into a file I would use fprintf(data,"Hello world");.
At the end of your program use a fclose(data); to close the file and flush the buffers out.

In other words you need a fclose(data); command for every fopen command you have. An nether fopen nor fclose is writting any data to a file.

-Jim
  #3   Spotlight this post!  
Unread 17-03-2004, 21:26
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: stdlib.h for Dashboard Program

Is this what you are trying to do (in psuedo code)?

Read data from dashboard port (once every 1/38 second)
open file
write data to file
close file
repeat

It's possible after a thousand or so times of this, you are overflowing the buffer.

it may work better if you

open file
read data from dashboard port (once every 1/38 second)
write data to file
flush data (fflush)
repeat
close file
  #4   Spotlight this post!  
Unread 17-03-2004, 21:29
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
Re: stdlib.h for Dashboard Program

Yeah, that's probably the answer.

I just converted it all over to fstream (and learned a bit about vs.NET), so I think it'll work like this for now. If I have any errors, I'll come back and try that fflush thing, cause I was running out of memory, so I'd bet that's the reason.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #5   Spotlight this post!  
Unread 17-03-2004, 22:40
Neal Turett Neal Turett is offline
Registered User
#0201
 
Join Date: Nov 2002
Location: Rochester Hills
Posts: 34
Neal Turett is on a distinguished road
Re: stdlib.h for Dashboard Program

Assuming you're using Windows, you could use API calls as an alternate to fstream. Fstream is probably simpler, this is just in case you can't use fstream for some strange reason.

The relevant functions are CreateFile, SetFilePointerEx, WriteFile, and CloseFile. All of these are in kernel32.lib and defined in winbase.h. To access them, simply include windows.h.
  #6   Spotlight this post!  
Unread 17-03-2004, 23:44
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
Re: stdlib.h for Dashboard Program

Quote:
Originally Posted by Neal Turett
Assuming you're using Windows, you could use API calls as an alternate to fstream. Fstream is probably simpler, this is just in case you can't use fstream for some strange reason.

The relevant functions are CreateFile, SetFilePointerEx, WriteFile, and CloseFile. All of these are in kernel32.lib and defined in winbase.h. To access them, simply include windows.h.
I can use fstream, I had just redone my program to get rid of it cause it was acting funny, but by rewriting all of that code it fixed whatever problems I was having. Plus, I have about 9 or 10 hours till I have to use the program, so simpler is better :-).
__________________
AIM --> Woloi
Email --> ian@woloschin.com
Closed Thread


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
2-week FIRST summer program @ WPI ColleenShaver General Forum 20 31-05-2009 03:02
how to add steps in the provided encoder program for the edu Zaramel2002 Programming 3 11-02-2004 08:35
Fried program slots? Jeff Waegelin Programming 18 19-03-2003 18:08
Ahh! Program trick confusing! archiver 2001 9 24-06-2002 02:26
Credits for FIRST program. archiver 2000 6 24-06-2002 00:16


All times are GMT -5. The time now is 02:53.

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