Need help understanding return value from object
Don M
Posts: 1,653
I am using FSRW in one of my programs. I wanted to modify my program to indicate if the sd card didn't mount.
I use this statement in my program:
to mount the card with the pins starting at P0.
In the fsrw object it mentions this:
My program hangs if the card doesn't mount. How do I acknowledge this "abort" ? I want to display a message indicating the problem and take alternate actions.
Thanks.
Don
I use this statement in my program:
sd.mount(0)
to mount the card with the pins starting at P0.
In the fsrw object it mentions this:
{{ ' Mount a volume. The address passed in is passed along to the block ' layer; see the currently used block layer for documentation. If the ' volume mounts, a 0 is returned, else abort is called. }}
My program hangs if the card doesn't mount. How do I acknowledge this "abort" ? I want to display a message indicating the problem and take alternate actions.
Thanks.
Don
Comments
The "SD card mounted OK" message works but not the fail message.
I'm new to the prop myself but from looking at the fsrw code, I don't think sd.mount will return anything.
I think you will need to use sd.mount_explicit if you want to get a return value.
I have seen an object somewhere that did do a check and reported back if there was an error but I'm afraid I can't remember what it was for (I thought it was sidcog but it's not)
Of course, being new to this, I might be completely wrong but I think you might want to use the mount_explicit version instead
Note the \ in front of the mount_explicit (which allows you to define the pins); this allows the abort mechanism in Spin to get back to this line cleanly.
Actually calling sd.mount(0) passes the the first pin (0) to the sd.mount_explicit method. mount_explicit is the method that contains the dialouge about a "0" being returned if it mounts and an abort if not that I mentioned above.
Like I said, I'm new to the prop and spin so I make most of it up in my head
Thanks. That works. At first I tried this:
but it didn't work. When I changed it to this:
then it does work.
So I guess it has to do with your comment "this allows the abort mechanism in Spin to get back to this line cleanly". Why does it work that way? Is it because the first way: sd.mount(0) goes through to sd.mount_explicit and the abort does not get passed back through the sd.mount?