der er flere under den slutter rigtigt!
her kommer koden med din stump kode!
- #include <SPI.h>
- #include <Ethernet.h>
-
- char str[256];
- char * dst;
- int numbers[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
- int count = 5;
- int i;
-
-
- byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
- IPAddress ip(192,168,1,207);
- IPAddress gateway(192, 168, 1, 1);
- IPAddress subnet(255, 255, 255, 0);
-
-
- IPAddress server(192, 168, 1, 21);
-
- EthernetClient client;
- int totalCount = 0;
- int loopCount = 0;
- char params[32];
-
- void setup() {
- Serial.begin(9600);
-
- pinMode(4,OUTPUT);
- digitalWrite(4,HIGH);
-
- Ethernet.begin(mac, ip, gateway, gateway, subnet);
- delay(2000);
- Serial.println("Ready");
- }
-
- void loop()
- {
- /*******************************************************************************/
- /*******************************************************************************/
- /****************** Kode stump fra Robert larsen *******************************/
-
- strcpy(str, "systemID=12345&data=");
- dst = str + strlen(str);
- for (i = 0; i < count; i++) {
- if (i > 0) {
- *(dst++) = ',';
- }
- dst += sprintf(dst, "%d", numbers[i]);
- }
- printf("%s\n", str);
- return 0;
-
- /**********************************************************************************/
- if(loopCount < 30)
- {
- delay(1000);
- }
- else
- {
- loopCount = 0;
- sprintf(params,str,totalCount);
- if(!postPage(server,"/insert.php",params)) Serial.print("Fail ");
- else Serial.print("Pass ");
- totalCount++;
- Serial.println(totalCount,DEC);
- }
-
- loopCount++;
- }
-
-
- byte postPage(IPAddress ipBuf,char *page,char* thisData)
- {
- int inChar;
- char outBuf[128];
-
- Serial.print("connecting...");
-
- if(client.connect(ipBuf,8000))
- {
- Serial.println("connected");
-
- client.println("POST /insert.php HTTP/1.0");
- client.println("Content-Type: application/x-www-form-urlencoded");
-
- sprintf(outBuf,"Content-Length: %u\r\n",strlen(thisData));
-
- client.println(outBuf);
- client.print(thisData);
- }
- else
- {
- Serial.println("failed");
- return 0;
- }
-
- int connectLoop = 0;
-
- while(client.connected())
- {
- while(client.available())
- {
- inChar = client.read();
- Serial.write(inChar);
- connectLoop = 0;
- }
-
- delay(1);
- connectLoop++;
- if(connectLoop > 10000)
- {
- Serial.println();
- Serial.println("Timeout");
- client.stop();
- }
-
- }
-
- Serial.println();
-
- Serial.println("disconnecting.");
- client.stop();
-
- return 1;
- }
Den fejl meddellelse jeg får er:
In function 'void loop()':
error: return-statement with a value, in function returning 'void'
Indlæg senest redigeret d. 30.11.2012 09:05 af Bruger #17451