View unanswered posts | View active topics It is currently Fri May 24, 2013 3:55 am






Reply to topic  [ 15 posts ] 
NXT, filehandles question, RobotC v1.46 
Author Message
Rookie
User avatar

Joined: Wed Feb 21, 2007 12:23 am
Posts: 38
Location: Walla Walla, WA
Post NXT, filehandles question, RobotC v1.46
When I declare a filehandle variable:

TFileHandle OUTPUT;
TFileIOResult result;
string filename="test.dat";
int filesize = 400; //bytes

and open it for writing:

OpenWrite(OUTPUT,result,filename,filesize);

it's unclear from the documentation whether I need to assign a value to the OUTPUT variable (if so from what set?), e.g. OUTPUT=5, before I use the OpenWrite function or if the OpenWrite function is handling that for me, assuring that filehandles are unique.

Anybody know?

Albert


Sun Mar 29, 2009 6:36 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2864
Location: Rotterdam, The Netherlands
Post Re: NXT, filehandles question, RobotC v1.46
Hiya Albert,

OpenWrite() will assign a value to OUTPUT. This will be the number of the FH. Take a look at the "Nxt File IO Test.c" program in the "NXT Feature Samples" directory.

Regards,
Xander

_________________
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)

| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Mar 30, 2009 12:56 am
Profile WWW
Expert

Joined: Sun Aug 19, 2007 2:43 pm
Posts: 133
Location: New Jersey
Post Re: NXT, filehandles question, RobotC v1.46
I am currently using 2.25, none of the fileIO calls work, not even a simple call Delete()... This code worked fine with 1.46.

Anything new about 2.25 that I must include, perhaps!???


Sun Jul 03, 2011 8:33 pm
Profile WWW
Expert

Joined: Sun Aug 19, 2007 2:43 pm
Posts: 133
Location: New Jersey
Post Re: NXT, filehandles question, RobotC v1.46
I am currently using 2.25, none of the fileIO calls work, not even a simple call Delete()... This code worked fine with 1.46.

Anything new about 2.25 that I must include, perhaps!???

errors:
**Error**:ASM memory reference 'nIoResult' evaluates to undefined value
**Error**:ASM memory reference 'hFileHandle' evaluates to undefined value
**Error**:ASM memory reference 'nFileSize' evaluates to undefined value
**Error**:ASM memory reference 'nIoResult' evaluates to undefined value

If this is a real bug... wonder if any fix is coming soon!? Or I should simply forget about any sort of data logging using RobotC? ?


Sun Jul 03, 2011 8:33 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2864
Location: Rotterdam, The Netherlands
Post Re: NXT, filehandles question, RobotC v1.46
Can you attach your code?

- Xander

_________________
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)

| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Jul 04, 2011 12:37 am
Profile WWW
Expert

Joined: Sun Aug 19, 2007 2:43 pm
Posts: 133
Location: New Jersey
Post Re: NXT, filehandles question, RobotC v1.46
After further investigating into this, the problem is more serious than that . Once it compiles, it makes the RobotC app simply not usable. Any other programs compilation will fail until I restart the robotc, even with a simple task main with one simple motor command.

Code:
#pragma platform(NXT)
#define POINTSZ 27
#define MAX_FILESZ POINTSZ*10
const string sFileName="Points.txt";
short nFileSize=MAX_FILESZ;

task main(){
#ifdef WHATTHEHECK   
    TFileHandle hFileHandle;
    TFileIOResult ioStatus;
#endif
    int index=0;
    string fstr[MAX_FILESZ];

#ifdef WHATTHEHECK   
    CloseAllHandles(ioStatus);
#endif

    wait1Msec(500);

#ifdef WHATTHEHECK   
    Delete(sFileName,ioStatus);
    hFileHandle=0;
    OpenWrite(hFileHandle,ioStatus,sFileName,nFileSize);
#endif

    for (index=0; index<1000; index++)
    {
#ifdef WHATTHEHECK   
        StringFormat(str,"%2d)\n",++index);
#endif
        wait1Msec(50);
    }
#ifdef WHATTHEHECK   
    WriteString(hFileHandle,ioStatus,fstr);
    Close(hFileHandle,ioStatus);
#endif
    return;
}


Mon Jul 04, 2011 6:19 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2864
Location: Rotterdam, The Netherlands
Post Re: NXT, filehandles question, RobotC v1.46
I can confirm this with 2.26.1. Could you please send your program and a report of the error and the url of this thread to support@robotc.net? Thanks :)

- Xander

_________________
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)

| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Jul 04, 2011 6:57 am
Profile WWW
Expert

Joined: Sun Aug 19, 2007 2:43 pm
Posts: 133
Location: New Jersey
Post Re: NXT, filehandles question, RobotC v1.46
I am using 2.25 (8.19) August 20, 2010 version. I am afraid to upgrade it to 2.26.1 because there is another very fundamental C semantic errors with it according to my students:

motor[motorA] = motor[motorB] = 0;

no longer works. They have do them in independent expressions. ie.

motor[motorA] = 0;
motor[motorB] = 0;

If this fundamental semantic goes wrong, I hate to think what else may be wrong. The last stable version I had was 1.46, except the poor structure and floating point handling support. :-(

Yes, please do see you can replicate these two issues in 2.26.1. Thank you!


Mon Jul 04, 2011 7:12 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2864
Location: Rotterdam, The Netherlands
Post Re: NXT, filehandles question, RobotC v1.46
Just mail these bugs to support@robotc.net, that will ensure the issues are entered into the ticketing system.

- Xander

_________________
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)

| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Jul 04, 2011 7:26 am
Profile WWW
Expert

Joined: Sun Aug 19, 2007 2:43 pm
Posts: 133
Location: New Jersey
Post Re: NXT, filehandles question, RobotC v1.46
Yes, I did, [#373623] . Since I do not have 2.26.1, I am anxious to know if this is fixed in 2.26.1.


Mon Jul 04, 2011 7:55 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2864
Location: Rotterdam, The Netherlands
Post Re: NXT, filehandles question, RobotC v1.46
This program works fine for me in 2.26:

Code:
task main(){
  motor[motorA] = motor[motorB] = 100;
  wait1Msec(1000);
  motor[motorA] = motor[motorB] = 0;
}


- Xander

_________________
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)

| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Jul 04, 2011 9:35 am
Profile WWW
Expert

Joined: Sun Aug 19, 2007 2:43 pm
Posts: 133
Location: New Jersey
Post Re: NXT, filehandles question, RobotC v1.46
Xander, is yours 2.26 or 2.26.1? The one the kids downloaded is 2.26.1.

When I get back with the kids, I'll look into it myself as well.

a lot of thanks as always.

By the way, away from the topic a bit. I have always meant to write you about the "HiTechnic Sensor Multiplexer" document that you wrote. It is an excellent document. I used it for writing the interface with Robolab too. :-)


Mon Jul 04, 2011 10:38 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2864
Location: Rotterdam, The Netherlands
Post Re: NXT, filehandles question, RobotC v1.46
I have 2.26.1

- Xander

_________________
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)

| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Jul 04, 2011 4:14 pm
Profile WWW
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 537
Post Re: NXT, filehandles question, RobotC v1.46
This worked fine for me in 2.26.1/Firmware 8.23 - I don't have 2.25 to address this specific error message.

I modified the original program some. The max size of an array of strings is 24 elements - after that, you're out of temporary variables. I'll see if there's anything we can do to increase this size.

Also, when referring to a string array, simply saying "str" will not print all results - I moved the write command inside of the for loop so that each array element will be written to the text file.

Code:
const string sFileName="Points.txt";

task main()
{
    TFileHandle hFileHandle;
    TFileIOResult ioStatus;
    const int numberOfStrings = 24;
    int nFileSize = numberOfStrings*20;

    int index = 0;
    string str[numberOfStrings];

    CloseAllHandles(ioStatus);
    wait1Msec(500);

    Delete(sFileName,ioStatus);
    hFileHandle=0;

    OpenWrite(hFileHandle,ioStatus,sFileName,nFileSize);

    for (index=0; index < numberOfStrings; index++)
    {
        StringFormat(str[index],"%2d)\n",index);
        WriteString(hFileHandle,ioStatus,str[index]);
        wait1Msec(50);
    }

    Close(hFileHandle,ioStatus);
}

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Sun Jul 10, 2011 5:26 pm
Profile
Expert

Joined: Sun Aug 19, 2007 2:43 pm
Posts: 133
Location: New Jersey
Post Re: NXT, filehandles question, RobotC v1.46
This has been reported to robotc bug report. I thought I would put it up at the forum to catch others' input.

I redownloaded the 2.26.1 as my version said 2.26 instead. I'll try it again and update for both the NXT file handling and motor errors.


Mon Aug 22, 2011 6:48 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 15 posts ] 

Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.