Core strange flashing behaviour

Hi again guys,
Over the last 2 days I’ve had problems flashing my core. Firstly the computer wouldn’t reigster the core was connected under device manager but I solved this after many factory resets. I then flashed known working code onto the cores to test them, it ran fine. then I flashed the code I wished to test (Onto two seperate cores) One seems to be running the correct code while the other is running the code I used to test the cores. I’ve reflashed that same core 3 times with the new code and each time it is still running the old code. It’s worth mentioning I earlier had a “Server error” when I tried to flash some code but it seemed to work fine when I flashed it again. The cores are flashing magenta as usual. I can provide code if needs be but I think this is a hardware issue.

Thanks, Oddie

Just to be on the safe side, it’d be best if you added your code. It’s easier to debug your software, than it is to debug your hardware, so lets try that first :wink:

Do you need the code I was using to test it, the code I really want to run or both?

The more, the merrier. Just clearly state which is which, and where the problems are :slight_smile:

Ok,
here’s the test code that after flashing the core with other code 3 times is still running:

byte serv[] = { 172, 16, 0, 222 }; //dos
//SYSTEM_MODE(MANUAL);
//TCPServer server = TCPServer(23);
TCPClient client;

void setup()
{
    Serial.begin(9600);
  // start listening for clients
    while(!Serial.available()) SPARK_WLAN_Loop();
  //  client.connect(serv,23);
    if (client.connect(serv, 80))
    {
        Serial.println("connected");
        client.println("We are all connected");
    }
    else
    {
        Serial.println("connection failed");
    }
}

void loop()
{
    if (client.connected())
    {
        Serial.print("Here");
        int c = client.read();
        Serial.print(c);
    }else{
        Serial.println();
        Serial.println("disconnecting.");
    //    client.stop();
    //    for(;;) {
    //         SPARK_WLAN_Loop;
    //            }
    } 
}

And here’s the code I want to run on it. I’m pretty sure it’s ok I only made a minor change before all this happened.


byte serv[] = { 172, 16, 0, 222 }; //dos
//SYSTEM_MODE(MANUAL);<
//TCPServer server = TCPServer(23);
TCPClient client;
#include <string.h>
#include <stdio.h>
void setup()
{
    Serial.begin(9600);
    // start listening for clients
    while(!Serial.available()) SPARK_WLAN_Loop();
    //  client.connect(serv,23);
    if (client.connect(serv, 80))
    {
        Serial.println("connected");
        client.println("We are all connected");
    }
    else
    {
        Serial.println("connection failed");
    }
}

String getValue(String data, char separator, int index)
{
  int found = 0;
  int strIndex[] = {0, -1};
  int maxIndex = data.length()-1;

  for(int i=0; i<=maxIndex && found<=index; i++){
    if(data.charAt(i)==separator || i==maxIndex){
        found++;
        strIndex[0] = strIndex[1]+1;
        strIndex[1] = (i == maxIndex) ? i+1 : i;
    }
  }

  return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
}

void loop()
{
    if (client.connected()){
            Serial.println("Here");
            Serial.println("Length is: ");
            int length = client.read();
            Serial.println(length);
            client.flush();
            String s4 = "";

            for (int i=0; i <= length; i++){
                delay(1000);
                char be = client.read();
                s4 += be;
                Serial.println(s4);
            }
        Serial.println("Post for loop");

        s4 += "\0";
        String word1 = getValue(s4, ' ', 0);
        String word2 = getValue(s4, ' ', 1);

        Serial.println("");
        Serial.println("The Unique ID of this packet is: ");
        Serial.print(word1);
        Serial.println("");
        Serial.println("The ZigBeeType of this packet is: ");
        Serial.println(word2);
        

    }
    else{
        Serial.println();
        Serial.println("disconnecting.");

    } 
}