I'm running a script on a pyboard (V1.1) that logs solar data to an SD card. I've decided to (foolishly!) include a check to see if the card is present, and if not then stop the script and print a warning. It works to a point - the switch press works, but I can't find a way to mount the card in software and continue the script. If the card is present on boot, then everything works.
Code: Select all
try:
os.chdir('/sd')
except OSError:
print('No SD card detected! - insert card and press usr switch')
while switchpress == 0:
print('waiting for switchpress...')
utime.sleep(1)
else:
print('switchpress registered')
# need to mount SD card!
# switchpress=0
#
I've tried to use pyb.mount(sd,/sd) and some of the other obvious(?) commands with no luck. I'm trying to avoid running a reboot after inserting the card. I recall reading a way to do this in the forum, but can't seem to find it again.
Any suggestions appreciated.