Hi,
I am running a fairly large program on a Teensy 3.0. I works perfectly for the most part but every once and a while it freezes up.
I saw the recommendations found at http://www.pjrc.com/teensy/troubleshoot.html and I converted all of my strings to const charArray[] = "", but that did not seem to help. I also frequently use code such as
void sendPosition(Amotor &motor)
{
char *revolutionCharArray, *stepsCharArray, *sendCharArray;
revolutionCharArray = (char*) calloc(14,sizeof(char));
stepsCharArray = (char*) calloc(14,sizeof(char));
sendCharArray = (char*) calloc(30,sizeof(char));
itoa(motor.motorPosition, revolutionCharArray, 10);
itoa(motor.steps, stepsCharArray, 10);
arrayIndex = 0;
sendCharArray[arrayIndex++] = (char) (motor.nameOfMotor + '0');
addAnArrayToAnotherArray(sendCharArray, positionCharArray, &arrayIndex);
addAnArrayToAnotherArray(sendCharArray, revolutionCharArray, &arrayIndex);
sendCharArray[arrayIndex++] = '.';
addAnArrayToAnotherArray(sendCharArray, stepsCharArray, &arrayIndex);
sendCharArray[arrayIndex++] = '\n';
sendCharArray[arrayIndex] = '\0';
Serial.print(sendCharArray);
free(revolutionCharArray);
free(stepsCharArray);
free(sendCharArray);
}
could the calloc be causing the crash?
I am running a fairly large program on a Teensy 3.0. I works perfectly for the most part but every once and a while it freezes up.
I saw the recommendations found at http://www.pjrc.com/teensy/troubleshoot.html and I converted all of my strings to const charArray[] = "", but that did not seem to help. I also frequently use code such as
void sendPosition(Amotor &motor)
{
char *revolutionCharArray, *stepsCharArray, *sendCharArray;
revolutionCharArray = (char*) calloc(14,sizeof(char));
stepsCharArray = (char*) calloc(14,sizeof(char));
sendCharArray = (char*) calloc(30,sizeof(char));
itoa(motor.motorPosition, revolutionCharArray, 10);
itoa(motor.steps, stepsCharArray, 10);
arrayIndex = 0;
sendCharArray[arrayIndex++] = (char) (motor.nameOfMotor + '0');
addAnArrayToAnotherArray(sendCharArray, positionCharArray, &arrayIndex);
addAnArrayToAnotherArray(sendCharArray, revolutionCharArray, &arrayIndex);
sendCharArray[arrayIndex++] = '.';
addAnArrayToAnotherArray(sendCharArray, stepsCharArray, &arrayIndex);
sendCharArray[arrayIndex++] = '\n';
sendCharArray[arrayIndex] = '\0';
Serial.print(sendCharArray);
free(revolutionCharArray);
free(stepsCharArray);
free(sendCharArray);
}
could the calloc be causing the crash?