strncpy() Failing
Posted: Mon Oct 19, 2015 12:17 pm
Hi. First post, and it's already help needed (maybe not a good sign!).
I am trying to list the first 5 found SSIDs using the ESP8266 Arduino, and it is failing on strncpy() operations with an exception. The code in question is below:
With CURRENT_SSID_CHAR_FULL being const char* and CURRENT_SSID_CHAR being char* which is supposed to be the truncated code. The code is on GitHub https://github.com/snowdenator/ESP8266_Stuff/commit/971242dce4a3705770b367927df142504fe461d2
I have tried things such as os_strncpy() to no avail.
The exception that is produced:
Any help would be appreciated.
I am trying to list the first 5 found SSIDs using the ESP8266 Arduino, and it is failing on strncpy() operations with an exception. The code in question is below:
Code: Select all
if (NETWORKS_FOUND != 0) {
for (int i = 0; i < NETWORKS_FOUND; i++) {
if (i > 5) {
break; //We only want 5 on the OLED
}
CURRENT_SSID_CHAR_FULL = WiFi.SSID(i); //Copy to variable
Serial.println(CURRENT_SSID_CHAR_FULL); //Prints SSID fine
os_strncpy(CURRENT_SSID_CHAR, CURRENT_SSID_CHAR_FULL, 15); //This is where the code fails with an exception, trying to truncate the string to 15 chars
Serial.print("SSID #"); Serial.print(i); Serial.print(": "); Serial.println(CURRENT_SSID_CHAR);
//sendStrXY(CURRENT_SSID_CHAR, i, 0);
delay(10);
}
}
With CURRENT_SSID_CHAR_FULL being const char* and CURRENT_SSID_CHAR being char* which is supposed to be the truncated code. The code is on GitHub https://github.com/snowdenator/ESP8266_Stuff/commit/971242dce4a3705770b367927df142504fe461d2
I have tried things such as os_strncpy() to no avail.
The exception that is produced:
Code: Select all
WiFi network scan complete
No. of networks found: 5
SKY1AB19
Exception (29):
epc1=0x4000c081 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
ctx: cont
sp: 3ffea5f0 end: 3ffea7c0 offset: 01a0
>>>stack>>>
3ffea790: 00000000 00000000 00000000 3ffea7ec
3ffea7a0: 3fffdc20 00000000 3ffea7e4 40201cca
3ffea7b0: 00000000 00000000 3ffe97a0 40100378
<<<stack<<<
ets Jan 8 2013,rst cause:4, boot mode:(1,7)
wdt reset
Any help would be appreciated.