Writing on external file

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
raspadafruit
 
Posts: 62
Joined: Mon Aug 13, 2018 6:00 am

Writing on external file

Post by raspadafruit »

Hi,

I'm using a Adafruit Feather M0 with RFM95 LoRa Radio - 900MHz - RadioFruit
and I'm looking to write data into files located in my computer (the feather is connected to the computer).

I tried :
fichier = open("/home/user/data.txt", "a")
fichier.write("Hello world")
fichier.close()

in my main.py file but I get "OSError: [Errno 30]" error (seems to be read only).

Is it possible to write into files ?

Thanks

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Writing on external file

Post by tannewt »

Its totally possible but requires you to change the drive to writable from circuitpython and read-only from the computer. This reduces the risk of corrupting the filesystem.

Check out this guide for details: https://learn.adafruit.com/cpu-temperat ... n?view=all

User avatar
raspadafruit
 
Posts: 62
Joined: Mon Aug 13, 2018 6:00 am

Re: Writing on external file

Post by raspadafruit »

Thank you so much ! I will try it tomorrow and get back if there is any issues !

Thanks

User avatar
raspadafruit
 
Posts: 62
Joined: Mon Aug 13, 2018 6:00 am

Re: Writing on external file

Post by raspadafruit »

Hi,

Just to be sure, the tutorial shows how to write files in the device and read it from the computer, however, is it possible de write files directly located in the computer (to avoid memory issues)?

Thanks

User avatar
danhalbert
 
Posts: 4652
Joined: Tue Aug 08, 2017 12:37 pm

Re: Writing on external file

Post by danhalbert »

No, there's no way to write a host computer file directly. You could send the data to the host over UART or similar and have a program on the host read the data and write it to a file.

User avatar
raspadafruit
 
Posts: 62
Joined: Mon Aug 13, 2018 6:00 am

Re: Writing on external file

Post by raspadafruit »

Ok, thanks !!

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”