RasPiArduino
RasPiArduino copied to clipboard
Using File variable twice results in error
trafficstars
Hi !
Maybe I´m doing something wrong but this code did not work:
File script = FileSystem.open("wlan-stats.sh", FILE_WRITE);
script.print("#!/bin/sh\n");
script.print("ifconfig wlan0 | grep 'RX bytes'\n");
script.close(); // close the file
script = FileSystem.open("wlan-stats2.sh", FILE_WRITE);
script.print("#!/bin/sh\n");
script.print("ifconfig wlan0 | grep 'RX bytes'\n");
script.close(); // close the file
It results in this error:
*** Error in `./FileWriteScript.ino.bplus.bin': double free or corruption (out): 0xb6300480 ***
Any idea what´s going wrong here ?
Dominik
Hi !
I think this is related to the destructor... With this code it works:
File::~File() {
//close();
}
I think there is some handling missing if the file was closed before or not. Maybe you can add some control structure for that?
Dominik