Mobsya / aseba-target-thymio2

Thymio 2 firmware
8 stars 8 forks source link

New variable or native function to detect the presence of an SD card #20

Closed stephanemagnenat closed 7 years ago

stephanemagnenat commented 7 years ago

The firmware should provide a variable or a native function to detect the presence of an SD card. This would allow VPL2 to provide blocs that only make sense if the later is present.

If a variable, it could be named sd.present, if a function sd.ispresent or also sd.present.

Using a variable would make it easier to access from VPL, as a function would require to first load a small code to check it.

mbonani commented 7 years ago

I think it is possible to do it easily a start-up in openning a beta-file and store the result in a variable. But it will not manage if user remove or install the SD card after startup of the robot.

stephanemagnenat commented 7 years ago

I think it is possible to do it easily a start-up in openning a beta-file and store the result in a variable.

There should be a way to do it without having to write a file, as for sure before writing a file the filesystem has to check for the device.

But it will not manage if user remove or install the SD card after startup of the robot.

Is there an interrupt if the SD card is removed or installed?

mbonani commented 7 years ago

Hi, No interrupt for SD cards are available (there is no physical pin that says SD card here or not). I can try with the disk_status(fs->drv) function, but perhaps it is cleaner to pass through the filesystem. Could sd.present be a hidden variable?

stephanemagnenat commented 7 years ago

No interrupt for SD cards are available

Interesting... What a function using SD card is called, does it work if no SD card was present at robot boot time but now there is one?

Could sd.present be a hidden variable?

If checking for SD needs a specific operation, I guess a function is more clean than a variable.

What would be the reasons to make it hidden?

mbonani commented 7 years ago

At boot we controle if we see files like for the LOG or to launch the test procedure we have at production and also if there is an vmcodee.abo. So at that time the filesystem try to open these files. I wanted to add if it possible to open a new file because it return if it succeed, then store it in a variable that is accessible but hidden. So that people don't want to change it. In practice it is possible to put a sd card and make it works after power up, but you cannot hotunplug it and replug it, it breaks the filesystem status. Also it is not working if you try in aseba to open a file without card and then put one and retry. It only works if you powerup the robot, put an sdcard and then try to open a file. For me we have not to support that people plug and unplug the sdcard. So a variable that retain the status if there was a sd card on powerup is sufficient, in that case hidden could be enough for VPL2.

stephanemagnenat commented 7 years ago

For me we have not to support that people plug and unplug the sdcard. So a variable that retain the status if there was a sd card on powerup is sufficient, in that case hidden could be enough for VPL2.

I agree. I think that we could still name it sd.present, and document the limitation. I won't have it hidden, it is not a good idea that the code generated by VPL uses hidden variables and functions. You do not want to tell children "look at this code, but ignore this variable". It would be very bad pedagogically.

mbonani commented 7 years ago

ok I will implement in this direction

stephanemagnenat commented 7 years ago

Great! thank you!

mbonani commented 7 years ago

implement in e9cf7d71d803650244d86d6abcb0945a57051845