I believe I have found a couple of issues with the Teensy 4.0 operation.
1) We had some code that stripped leading space from a string. If the string consisted of only spaces, it would eventually get to a null string. The code is this:
String command=inputBuffer.substring(url_start,url_end);
while (command[0]==' ') command=command.substring(1);
On the Teensy 3.2, if the string that was passed in is only spaces, eventually this leads to command becoming the null string. On the Teensy 4.0, this crashes and it never reaches the next line of code. The workaround is to replace that line with this:
while (command[0]==' ') { if (command.length() > 1) { command=command.substring(1);} else {command = ""; } }
which works fine. But every other Arduino compiler/library combination accepts the first one and does not cause a failure.
2) Returning null string from a string function causes a crash.
The function:
String WebServer::arg(String id) {
return "";
}
never returns to the calling function. If you add any characters inside the quote marks, it does return that value to the calling routine. Again this is different from every other Arduino compiler/ library operation that does return the null string to the calling routing.
John Petterson
john@petterson.me
1) We had some code that stripped leading space from a string. If the string consisted of only spaces, it would eventually get to a null string. The code is this:
String command=inputBuffer.substring(url_start,url_end);
while (command[0]==' ') command=command.substring(1);
On the Teensy 3.2, if the string that was passed in is only spaces, eventually this leads to command becoming the null string. On the Teensy 4.0, this crashes and it never reaches the next line of code. The workaround is to replace that line with this:
while (command[0]==' ') { if (command.length() > 1) { command=command.substring(1);} else {command = ""; } }
which works fine. But every other Arduino compiler/library combination accepts the first one and does not cause a failure.
2) Returning null string from a string function causes a crash.
The function:
String WebServer::arg(String id) {
return "";
}
never returns to the calling function. If you add any characters inside the quote marks, it does return that value to the calling routine. Again this is different from every other Arduino compiler/ library operation that does return the null string to the calling routing.
John Petterson
john@petterson.me