Hi
I have updated my IDE from 1.0.6 to 1.6.5r5. Now i get a wrong filename when using itoa.
I have attached a sample code that produces the error on a MEGA2560
Time was set to 2016/4/2 06:09:32
Correct output from IDE 1.0.6
2016
2016
4
LT2016
From IDE 1.6.5r5 the the digit "4" are added.
2016
20164
4
LT20164
and if time are set to 2016/2/24 06:08 the out put are
2016
20162
2
LT20162
I think it is a kind of buffer overrun because if I remove
itoa(yeaat,charbufferyeaat,10);
itoa(monat,charbuffermonat,10);
The out put on IDE 1.6.5.r5 are
2016
2016
4
#include <RTClib.h>
#include <Wire.h>
//Set up the RTC, pint A8 and A9 used for power
RTC_DS1307 RTC;
DateTime now;
void setup() {
pinMode (A8,OUTPUT); // Power for RTC
digitalWrite(A8,LOW); // Power for RTC
pinMode (A9,OUTPUT); // Power for RTC
digitalWrite(A9,HIGH); // Power for RTC
RTC.begin();
Wire.begin();
Serial.begin(115200); //enable serial data print
now = RTC.now();
// put your setup code here, to run once:
int yeaat,monat;
char charbufferyeaat[4],charbuffermonat[2];
char filename2[13]="LT"; //file prefix
yeaat = now.year(); // convert byte to int
monat = now.month(); // convert byte to int
itoa(yeaat,charbufferyeaat,10);
itoa(monat,charbuffermonat,10);
Serial.println(yeaat);
Serial.println(charbufferyeaat);
Serial.println(monat);
strcat(filename2, charbufferyeaat); //append the year to the prefix
Serial.println(filename2);
}
void loop() {
// put your main code here, to run repeatedly:
}