Hi
I have just update to 1.6.8, and when I upload the below code i get this error.
i cannot find any help on google
avrdude: stk500v2_recv(): checksum error
avrdude: verification error, first mismatch at byte 0x313b
0x97 != 0x83
avrdude: verification error; content mismatch
If I remove the WiFi Shield there's no error.
Is it really necessary to remove this before upload??
#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
byte myMac[6];
byte myIP[4];
byte myNM[4];
byte myGW[4];
byte myDNS[4];
void setup() {
Serial.begin(115200);
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
delay(2000);
if(!SD.begin(4)) Serial.println("SD fail");
else Serial.println("SD ok");
File fh = SD.open("CONFIG.DAT",FILE_READ);
char netBuffer[32];
if(!fh)
{
Serial.println("SD open fail");
return;
}
int chPos = 0;
int lineNo = 0;
while(fh.available())
{
char ch = fh.read();
if(ch == '\n') {
chPos = 0;
switch(lineNo) {
case 0:
if(strstr(subStr(netBuffer, " ",1),"Enviroment")) Serial.println(F("Reed OK"));
// if(strstr(Env,"Test")){
break;
case 1:
if(getMAC(netBuffer,myMac)) Serial.println(F("mac ok"));
break;
case 2:
if(getIP(netBuffer,myIP)) Serial.println(F("ip ok"));
break;
case 3:
if(getIP(netBuffer,myNM)) Serial.println(F("netmask ok"));
break;
case 4:
if(getIP(netBuffer,myGW)) Serial.println(F("gateway ok"));
break;
case 5:
if(getIP(netBuffer,myDNS)) Serial.println(F("dns ok"));
break;
}
Serial.print(F("Line: "));
Serial.print(lineNo);
Serial.print(F(" "));
Serial.println(netBuffer);
lineNo++;
}
else if(ch == '/') {
// do nothing
}
else if(chPos < 31) {
netBuffer[chPos] = ch;
chPos++;
netBuffer[chPos] = 0;
}
}
fh.close();
int x;
Serial.print("\r\nmac ");
for(x=0;x<6;x++) {
Serial.print(myMac[x],HEX);
if(x<5) Serial.print(":");
}
Serial.print("\r\nip ");
for(x=0;x<4;x++) {
Serial.print(myIP[x],DEC);
if(x<3) Serial.print(".");
}
Serial.print("\r\nnetmask ");
for(x=0;x<4;x++) {
Serial.print(myNM[x],DEC);
if(x<3) Serial.print(".");
}
Serial.print("\r\ngateway ");
for(x=0;x<4;x++) {
Serial.print(myGW[x],DEC);
if(x<3) Serial.print(".");
}
Serial.print("\r\ndns ");
for(x=0;x<4;x++) {
Serial.print(myDNS[x],DEC);
if(x<3) Serial.print(".");
}
Serial.println("\r\nStarting ethernet");
Ethernet.begin(myMac,myIP,myDNS,myGW,myNM);
Serial.println(Ethernet.localIP());
}
void loop() {
}
byte getMAC(char* macBuf, byte* thisMAC) {
byte thisLen = strlen(macBuf);
byte thisOctet = 1;
thisMAC[0] = strtol(&macBuf[0],NULL,16);
for(int x = 0; x<thisLen; x++) {
if(macBuf[x] == ':') {
thisMAC[thisOctet] = strtol(&macBuf[x+1],NULL,16);
thisOctet++;
}
}
if(thisOctet == 6) return(1);
else return(0);
}
byte getIP(char* ipBuf, byte* thisIP) {
byte thisLen = strlen(ipBuf);
byte thisOctet = 1;
thisIP[0] = atoi(&ipBuf[0]);
for(int x = 0; x<thisLen; x++) {
if(ipBuf[x] == '.') {
thisIP[thisOctet] = atoi(&ipBuf[x+1]);
thisOctet++;
}
}
if(thisOctet == 4) return(1);
else return(0);
}
// Function to return a substring defined by a delimiter at an index
char* subStr (char* str, const char *delim, int index) {
#define MAX_STRING_LEN 30
char *act, *sub, *ptr;
static char copy[MAX_STRING_LEN];
int i;
// Since strtok consumes the first arg, make a copy
strcpy(copy, str);
for (i = 1, act = copy; i <= index; i++, act = NULL) {
////Serial.print(".");
sub = strtok_r(act, delim, &ptr);
if (sub == NULL) break;
}
Serial.print(F("Output from subStr: "));
Serial.println(sub);
return sub;
} //subStr