Page 1 of 2

List of programs in a Mindstorms NXT

PostPosted: Thu Dec 23, 2010 8:32 am
by Piero
Hi! There is a way to retrieve the list of programs downloaded in a Brick and manage them? Attention, NOT my programs in C#, programs written in others languages (NXT-G for example) and stored in the Brick memory. I've searched in the methods of the NXT class but i havent found nothing.
Thanks!

Re: List of programs in a Mindstorms NXT

PostPosted: Thu Dec 23, 2010 10:08 am
by andrew.kirillov
Hello,

Yes, it is possible, but you will need to write some code.

First you will need to go here. There you may find "Bluetooth Developer Kit" documents - these documents describe communication protocol with NXT over Bluetooth. These documents were used for writing AForge.NET code.

In Apendix 1, page 9-10, you may find description of FIND FIRST and FIND NEXT commands - these are the commands you need.

You may try using SendCommand() to simplify things. For some reasons this method is protected, but can access it if you inherit the class. (I think we need to make it public ... not sure why it was made protected).

Re: List of programs in a Mindstorms NXT

PostPosted: Thu Jan 13, 2011 8:46 am
by Piero
Hi! I've red bluetooth's documents but i don't understand the syntax. In appendix 2 there is the StartProgram's syntax (page 5), can you write an example in this discussion to start a program? I need an example to understand the syntax to send command.
Thanks!

Re: List of programs in a Mindstorms NXT

PostPosted: Sat Jan 15, 2011 2:36 pm
by andrew.kirillov
Hmmm, seems like programming is not for you, if cannot get that document. Did you try browsing AForge.NET framework's source code at least for a sample?

Here it is:
Code: Select all
byte[] command = new byte[22];
byte[] reply = new byte[28];

// prepare FIND FIRST command
command[0] = 0x01;
command[1] = 0x86;
System.Text.ASCIIEncoding.ASCII.GetBytes( "*.*", 0, 3, command, 2 );

SendCommand( command, reply );


As you can see, everything as in that document, isn't it?

Re: List of programs in a Mindstorms NXT

PostPosted: Mon Jan 17, 2011 7:58 am
by Piero
Thanks! Now i can try. :)

Re: List of programs in a Mindstorms NXT

PostPosted: Sat Jul 02, 2011 8:18 pm
by Piero
Hi! I'm working at the program, I can start and stop a program and read the first file on the brick, but, I don't understand how I can begin to read file form the first when i want to read all files.
This is the code:

Code: Select all
byte[] comando = new byte[22];


                comando[0] = (byte)0x01;
                comando[1] = (byte)0x87;
                comando[2] = (byte) ????

etc....


I don't understand this point: Handle number from the previous found file or from the Find First command

Can you help me for the byte 2? Thanks!

Re: List of programs in a Mindstorms NXT

PostPosted: Mon Jul 04, 2011 10:47 pm
by andrew.kirillov
Piero wrote:I don't understand this point: Handle number from the previous found file or from the Find First command

I believe you need to specify some "magic number" (handle), which was provided to you when you did the last Find First command (or the last find next ...) If so, then just take a look at description of the Find First command to see how this magic number is returned to you.

Re: List of programs in a Mindstorms NXT

PostPosted: Tue Jul 05, 2011 5:26 am
by Piero
Hi, the "magic number" :) is the byte 3 of the reply in the First Command. I call the First Commend and I pass the byte 3 to the byte 2 of Next Command, but, Next Command doesn't start at the first file in the brick. This is the point that I don't understand. :roll:

Re: List of programs in a Mindstorms NXT

PostPosted: Tue Jul 05, 2011 8:48 am
by andrew.kirillov
Piero wrote:but, Next Command doesn't start at the first file in the brick.

Hmmm ... Find First command should start from the first file, not Find Next. The name of the command already tells it will continue the search, so it will provide files other than the first one.

Re: List of programs in a Mindstorms NXT

PostPosted: Tue Jul 05, 2011 2:41 pm
by Piero
The goal of my program is to write a list of all NXT-G programs in the brick.
Now, the Find First command start from the first file, ok.
The Find Next command start every time from a different file, the next, I understand this.
When I turn on the brick and I launch the program, I have the complete list of programs, but, for retrieve another time the complete list, i have to turn off and turn on again the brick
My question at this point is: how I can have EVERY time I lauch my program, the complete list from the FIRST file?
Another question, how I can know when the list of files in the brick is ended? I have a null value?