PLC

Dependencies:   EthernetInterface TCPSocket_HelloWorld TextLCD mbed-rtos mbed

Fork of TCPSocket_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
twinkling
Date:
Mon May 12 04:59:42 2014 +0000
Parent:
13:3f8407714419
Commit message:
PLC;

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
PLC_client.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Tue Jun 04 16:07:37 2013 +0100
+++ b/EthernetInterface.lib	Mon May 12 04:59:42 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PLC_client.lib	Mon May 12 04:59:42 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/TCPSocket_HelloWorld/#3f8407714419
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Mon May 12 04:59:42 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- a/main.cpp	Tue Jun 04 16:07:37 2013 +0100
+++ b/main.cpp	Mon May 12 04:59:42 2014 +0000
@@ -1,31 +1,72 @@
 #include "mbed.h"
+#include "TextLCD.h"
 #include "EthernetInterface.h"
+Serial pc(USBTX, USBRX);
+DigitalOut led1(LED1);
+DigitalOut led4(LED4);
+TextLCD lcd(p24, p26, p27, p28, p29, p30);
+EthernetInterface eth;
+
+TCPSocketConnection sock;
+    char http_cmd[] = "GET /test.txt";
+    char buffer[200];
 
 int main() {
-    EthernetInterface eth;
-    eth.init(); //Use DHCP
-    eth.connect();
-    printf("IP Address is %s\n", eth.getIPAddress());
-    
-    TCPSocketConnection sock;
-    sock.connect("mbed.org", 80);
-    
-    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
-    sock.send_all(http_cmd, sizeof(http_cmd)-1);
-    
-    char buffer[300];
-    int ret;
-    while (true) {
+    eth.init("192.168.11.10", "255.255.255.0", "192.168.11.1");
+   
+    while (1)
+    {
+        int i, j, k, ret;
+        eth.connect();
+        sock.connect("192.168.11.26", 80);
+        sock.send_all(http_cmd, sizeof(http_cmd)-1);
         ret = sock.receive(buffer, sizeof(buffer)-1);
+        lcd.cls();
+        lcd.locate(0,0);
+        led4=1; wait(0.5); led4=0; wait(0.5);
         if (ret <= 0)
-            break;
-        buffer[ret] = '\0';
-        printf("Received %d chars from server:\n%s\n", ret, buffer);
-    }
-      
+        {
+            lcd.printf("error %d \n",ret);
+        }
+        else
+        {   
+        led4=1;
+            lcd.printf("success \n");
+            buffer[ret] = '\0';
+            k=0;
+            for (i=0 ; buffer[i]!='\0' ; i++)
+            {
+                if (buffer[i]=='l' && buffer[i+1]=='e')
+                {
+                    for (j=i+3; buffer[j]!='\0'; j++)
+                    {
+                        lcd.locate(k,1);
+                        lcd.printf("%s",buffer[j]);
+                        k++;
+                    }
+                    break;
+/*                    for(int j=i; buffer[j]!='\0' ; j++)
+                    {
+                    lcd.printf("%s",buffer);
+                    }
+                    lcd.locate(0,1);
+                    if(buffer[i+3]=='d')
+                    {   led4 = 1;
+                        //lcd.printf("Detect \n");
+                    }
+                    else if(buffer[i+3]=='u')
+                    {   led4 = 0;
+                        //lcd.printf("Undetect \n");
+                    }
+                    else break;*/
+                }
+            }
+        }      
     sock.close();
-    
     eth.disconnect();
-    
-    while(1) {}
+    led4=0;
+        wait(1);
+        
+        //pc.printf("Received %d chars from server:\n%s\n", ret, buffer);
+    }  
 }
--- a/mbed-rtos.lib	Tue Jun 04 16:07:37 2013 +0100
+++ b/mbed-rtos.lib	Mon May 12 04:59:42 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed-rtos/#4ef72665e2c8
--- a/mbed.bld	Tue Jun 04 16:07:37 2013 +0100
+++ b/mbed.bld	Mon May 12 04:59:42 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file