Creating a file on the RoboRio filesystem

I am trying to create the file on the roborio flash file system using commands like:


file = fopen("setup.txt", "a"); 
file = fopen("/home/lvuser/setup.txt","a");

Following either of these lines, file comes back as null and *errno *has a value of 13. 13 would seem to indicate “Permission denied.” As I recall, the robot code runs as lvuser, and lvuser owns its home directory, so I would expect either of these lines to create setup.txt in lvuser’s home directory, yet… no file and an error.

In the past we have been able to create files from the C++ robot code using code similar to this. Has something changed?

To create a file on the roborio you must be logged into the roborio as an administrator. If you’re getting a “permission denied” error, I would guess the code is trying to create the file (you are in the correct folder) but is being rejected because no one is logged into the system. I’m not sure if you can log in through the robot code, but if you can you could just use the default admin account which is

username: admin
password:

Either that or you could log in through a web browser and create the file ahead of time, and then access the already present file in the code.

Not sure what’s up with your situation – this is working for us:

fopen("/home/lvuser/pathfinder.log", "a");

All programs run as processes “logged in” as a user, one way or another, whether someone is attached to the system via SSH or connected to the web server as a client or not at all. I finally was able to check with TOP from an SSH session and, indeed, lvuser is the user running the robot program.

Pre-creating the file from an SSH session is something I’ll try for the diagnostic value, but ideally we should be able to create one on the fly as we have done in past years.

Thanks. It’s got to be something obvious that I’m overlooking, and I’m going to hate myself when it comes to light.

Does the file exist on disk already? Did you create it with the admin account over ssh? Any file you want to access much both be created and accessed with the lvuser account. Even in /home/lvuser/, if the file was created with an admin account it couldn’t be accessed by robot code.

It is working now. I think we had several issues compounded by:
(1) creating a subfolder as admin,
(2) creating a subfolder with a mixed case name and not being careful about matching it,
(3) too many cooks in the kitchen :wink: