Hello, this is our teams first year competing in the FRC (so bear with me ;)) and we are very excited.
Straight to my question…
I have noticed that I am unable to read or write from files in the RoboRIO.
I first executed a writing program in Java. It returned a “Permission Denied.”
I ssh’ed and chmod -R 777 the root directory. This did not fix the problem.
Next I decided to write a bash script that could handle the reading and writing. It is called from the default Java program. Interestingly, the bash program works fine in an ssh portal, but fails to read or write from the Java program.
Calling the bash script:
try {
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("echo \"hello world\" >> /home/lvuser/log.txt");
final BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println("process_output: " + line);
}
reader.close();
} catch (IOException e) {
System.out.println("error " + e.getMessage());
}
Contents of writer.sh:
#!/bin/bash
if "$1" == 'clear' ]; then
rm -rf "log.txt"
elif "$1" == 'read' ]; then
cat "log.txt"
else
str="$*"
echo "$str" >> "log.txt"
echo $str
fi
So is the RoboRIO restricted from writing and reading files?
From the error message you reported, I’m guessing the working directory is “/” or some location that the roborio process does not have write access to.
Try using the full path the the location you want to write to:
As a side note, after creating these files, I think you should be able to quickly grab them off the roborio using a browser and a FTP URL like: ftp://10.8.68.2/home/lvuser (substitute your roboRIO’s name or IP address for 10.8.68.2).
I am not certain why you were unable to exec a process (though I have never tried that).
I’m actually having the same issue from C++ this year, using snippets of code that have worked in previous years. Has the user that the Robot Program runs under changed, I wonder?
We don’t have any problem writing files on the RoboRIO. In fact, we are writing our trace log files to /home/lvuser/tracelog for logging events during autonomous. Note that RoboRIO is running a Linux OS so depending on which folder you are writing your file to, in general, since your robot is “logon” to the lvuser, you should have write privilege in /home/lvuser. So try creating your file in that folder or a subfolder in it.
When robot code is started, the working directory is a directory that is not writable. So if you want to write or read from a file, as said before you need to specify the full path. Would definitely recommend somewhere in /home/lvuser