Hi,
in the last weeks I played with the "official" Arduino ethernet shield and Arduino "uno".
My program works for some times then it crashes.
I looked inside the library and I found that problems arise always after the same write instruction.
This happen after a random number of iterations.
Here's the library code with the "write" function:
void W5100Class::send_data_processing(SOCKET s, uint8_t *data, uint16_t len)
{
uint16_t ptr = readSnTX_WR(s);
uint16_t offset = ptr & SMASK;
uint16_t dstAddr = offset + SBASE[s];
if (offset + len > SSIZE)
{
// Wrap around circular buffer
uint16_t size = SSIZE - offset;
write(dstAddr, data, size);
write(SBASE[s], data + size, len - size);
}
else {
write(dstAddr, data, len); [b]// <-- LOOK HERE ! this write is always the last correct instruction[/b]
}
ptr += len;
writeSnTX_WR(s, ptr);
}
When the problem arise all register are wrong and they seems to change very fast.
I have been trying to solve this problem for some days, but without any success.
I post a minimal code:
/*
* A simple sketch that uses Ethernet Shield to send some values (via POST) to GoogleDocs
* Minimal code for debugging, run for some minutes and it crashes.
* google file https://spreadsheets.google.com/spreadsheet/ccc?key=0ApEwiUcF9-9rdEV4NnNUekZNTFdRNjJGejhZZTd1SEE&hl=it#gid=0
* compiled with arduino 022
*/
#include "Ethernet.h"
#include "SPI.h"
//Ip configuration parameters ----------------------------------------
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x2C, 0x42 };
byte ip[] = { 192,168,1,0 };
byte gateway[] = { 192, 168, 1, 254 };
byte subnet[] = { 255, 255, 255, 0 };
// IP Address for spreadsheets.google.com
byte ipGoogle[] = {74,125,67,102};
// create a client that connects to Google
Client clientGoogle(ipGoogle,80);
void setup()
{
pinMode(10, OUTPUT);
}
void loop()
{
Ethernet.begin(mac, ip, gateway, subnet);
delay(1000);
clientGoogle.connect();
if (clientGoogle.connected()) {
clientGoogle.print("POST ");
clientGoogle.print("/formResponse?formkey=dEV4NnNUekZNTFdRNjJGejhZZTd1SEE6MQ");
clientGoogle.println(" HTTP/1.1");
clientGoogle.print("Host: ");
clientGoogle.println("spreadsheets.google.com");
clientGoogle.println("Content-Type: application/x-www-form-urlencoded");
clientGoogle.print("Content-Length: ");
clientGoogle.println("94");
clientGoogle.println("");
clientGoogle.println("entry.0.single=10&entry.1.single=10&entry.2.single=10&pageNumber=0&backupCache=&submit=Envoyer");
clientGoogle.println("");
clientGoogle.println("");
delay(4000);
clientGoogle.flush();
clientGoogle.stop();
}
delay (1000);
}
Help, ideas or advices are welcome!