Z-uno2 String function not working

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
yves
Posts: 50
Joined: 17 Sep 2021 18:05

Z-uno2 String function not working

Post by yves »

Hi,
It seems to me that there is a bug in String library (WString.cpp).

Environment:
  • ARDUINO IDE 1.8.15
    Z-Uno bootloader version:3.0.7
    Security:none
    Frequency:EU
    Device included:no
    Device included securely by controller:/no
    Controller:Fibaro HC2 in future time :-)
The code below does not work, it reboots not finishing loop()

Code: Select all

#include "Arduino.h"
#include "ArduinoTypes.h"
#include "ZUNO_Definitions.h"


#if (ZUNO_CORE_VERSION_MAJOR < 3)
#error "-------             This code should be complied for ZUNO 2 target"
#endif

//#define SPDBGSTART(X)   Serial.begin(X)
//#define SPDBG(...)      Serial.print(__VA_ARGS__)
//#define SPDBGLN(...)    Serial.println(__VA_ARGS__)
#define SPDBGSTART(X)  
#define SPDBG(...)      
#define SPDBGLN(...)    

String stgTemp;
String stgTutu;
String stgToto;
//_________________________________________________________________________________
//_________________________________________________________________________________
void setup() {
  SPDBGSTART(57600);SPDBGLN(" ");SPDBGLN("SetupStart");
 
 // blink led to see if we are here more than once (reboot)
  pinMode(LED_BUILTIN, OUTPUT);
	digitalWrite(LED_BUILTIN, HIGH); delay(1000);digitalWrite(LED_BUILTIN, LOW); 
}

uint32_t u32Count = 0;
//_________________________________________________________________________________
//  LOOP               LOOP               LOOP               LOOP               LOOP             
//_________________________________________________________________________________
void loop() {
  
  stgTutu = "<< 3456 >>" ;
  stgTemp = "abcd";

  //String stgTemp3 = stgTutu + stgTemp2;
  SPDBG (u32Count);
  SPDBGLN (" ");
  SPDBGLN(stgTutu);
  u32Count++;
  delay(1000);
}
This one loops normally that's the first strange point...

Code: Select all

void loop() {
  stgTutu = "<< 3456 >>" ;
  String stgTemp = "abcd";
  //String stgTemp3 = stgTutu + stgTemp2;
  SPDBG (u32Count);
  SPDBGLN (" ");
  SPDBGLN(stgTutu);
  u32Count++;
  delay(1000);
}
last (but not least!), if I uncomment the concat line then it doesn't loop normally again

Code: Select all

void loop() {
  stgTutu = "<< 3456 >>" ;
  String stgTemp = "abcd";
  String stgTemp3 = stgTutu + stgTemp;
  SPDBG (u32Count);
  SPDBGLN (" ");
  SPDBGLN(stgTutu);
  u32Count++;
  delay(1000);
}
I have tried various other concatenation methods without sucess.
Even stgTemp = String("<< 3456 >>") + String("abcd"); doesn't work

I have seen some other strange behaviors using WString.cpp but this one is simple.
It makes me think this is a pointer(s) issue, but may be I am doing something wrong?

Thanks
Yves
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: Z-uno2 String function not working

Post by p0lyg0n1 »

Hi,
Thank you for your code. I've tested it. The code works correctly with the latest beta version (3.0.9). To enable beta support, please add "https://z-uno.z-wave.me/files/z-uno2/pa ... beta_index .json" to your repository list. After installation, you can simply switch between beta and stable repositories.

Best regards,
    Alex.
yves
Posts: 50
Joined: 17 Sep 2021 18:05

Re: Z-uno2 String function not working

Post by yves »

Hi p0lyg0n1,

I have just retried the simplest of my tests with 3.0.9:

Code: Select all

void loop() {
  stgTemp = String("<< 3456 >>") + String("abcd");
  SPDBGLN(stgTemp);
  delay(1000);
}
It still doesn't work :-(.
It reboots somewhere after the serial.println(),
(the printed stgTemp value is correct: "<< 3456 >>abcd")

Thanks for your help
Post Reply