Can't access the mbed

12 Feb 2010 . Edited: 12 Feb 2010

I can not access the mbed after adding the bin file which contains the following code.

#include "mbed.h"

AnalogIn xin(p20);
AnalogIn yin(p19);

LocalFileSystem local("local");               // Create the local filesystem under the name "local"

int main() {
float xval;
float yval;

while(1) {
xval=xin.read();
yval=yin.read();

FILE *fp = fopen("/local/out.txt", "w");  // Open "out.txt" on the local file system for writing
fprintf(fp, "x: %f, y: %f\n", xval, yval);
fclose(fp);
wait_ms(100);
}

}

I thought there is something wrong with the 'while' loop, because I can't access it after adding the while loop.

Does anyone know how to sort this out?

12 Feb 2010

Hi Xue,

Your code is accessing the LocalFileSystem, and whenever you have one or more files open, it will not be visible to the PC (you can't have two masters basically). As your program is always holding on to a file and hence the filesystem, you will never give it back to the PC.

The solution is simply to hold down the reset button. As the micro and hence the program won't be running, the PC will be able to see the Filesystem fine.

See http://mbed.org/handbook/LocalFileSystem for the full explanation.

Simon

12 Feb 2010

Simon Ford wrote:

Hi Xue,

Your code is accessing the LocalFileSystem, and whenever you have one or more files open, it will not be visible to the PC (you can't have two masters basically). As your program is always holding on to a file and hence the filesystem, you will never give it back to the PC.

The solution is simply to hold down the reset button. As the micro and hence the program won't be running, the PC will be able to see the Filesystem fine.

See http://mbed.org/handbook/LocalFileSystem for the full explanation.

Simon

Thanks for your help. I have solved that problem.

Would you do me another favor? I am recording the voltage information from the pin19 and pin20 as you can see from the code. What I am expecting is to record hundreds of voltage values a time rather than once a time. I was supposed to use a 'while' loop to perform it, well, actually I mess it up. Would you mind suggesting me a idea to work it out?

12 Feb 2010

What I am expecting is to record hundreds of voltage values a time rather than once a time. I was supposed to use a 'while' loop to perform it, well, actually I mess it up. Would you mind suggesting me a idea to work it out?

It seems that your program is reopening the file for each round so old values will be overwritten.

OMG, i almost died when my MBED wasn't visible, thanks for the warning :)