Projectlab Elektronica-ICT KULeuven

Dependencies:   EthernetInterface TMP102 TextLCD mbed-rtos mbed

werking.pdf

Committer:
seppeduwe
Date:
Fri Mar 14 19:41:14 2014 +0000
Revision:
0:ae3af7d18c4a
Child:
1:635e76c52151
Nog voor klasse

Who changed what in which revision?

UserRevisionLine numberNew contents of line
seppeduwe 0:ae3af7d18c4a 1 #include "mbed.h"
seppeduwe 0:ae3af7d18c4a 2 #include "TCPServer.h"
seppeduwe 0:ae3af7d18c4a 3 //#include "TCPFrame.h"
seppeduwe 0:ae3af7d18c4a 4 #define MYMBED 07
seppeduwe 0:ae3af7d18c4a 5 #include "Frame.h"
seppeduwe 0:ae3af7d18c4a 6 #include "Tune.h"
seppeduwe 0:ae3af7d18c4a 7 #include "Display.h"
seppeduwe 0:ae3af7d18c4a 8
seppeduwe 0:ae3af7d18c4a 9 DigitalOut connectedLed(LED1); //connected
seppeduwe 0:ae3af7d18c4a 10 DigitalOut RecieveLed(LED2); //recieve
seppeduwe 0:ae3af7d18c4a 11 DigitalOut SendLed(LED3); //send
seppeduwe 0:ae3af7d18c4a 12 InterruptIn button(p8);
seppeduwe 0:ae3af7d18c4a 13 DigitalOut myled(LED1);
seppeduwe 0:ae3af7d18c4a 14 bool SendISR;
seppeduwe 0:ae3af7d18c4a 15
seppeduwe 0:ae3af7d18c4a 16 void flip()
seppeduwe 0:ae3af7d18c4a 17 {
seppeduwe 0:ae3af7d18c4a 18 SendISR=1;
seppeduwe 0:ae3af7d18c4a 19 }
seppeduwe 0:ae3af7d18c4a 20
seppeduwe 0:ae3af7d18c4a 21 int main()
seppeduwe 0:ae3af7d18c4a 22 {
seppeduwe 0:ae3af7d18c4a 23 button.rise(&flip); // attach the address of the flip function to the rising edge
seppeduwe 0:ae3af7d18c4a 24
seppeduwe 0:ae3af7d18c4a 25 //pb.mode(PullUp);
seppeduwe 0:ae3af7d18c4a 26 char testIDs[]= {0x08,0x09,0x0A};
seppeduwe 0:ae3af7d18c4a 27 char buf[256];
seppeduwe 0:ae3af7d18c4a 28 encodeTest(11,4000,2,5,3,testIDs,buf);
seppeduwe 0:ae3af7d18c4a 29
seppeduwe 0:ae3af7d18c4a 30 TCPServer server("192.168.0.107");
seppeduwe 0:ae3af7d18c4a 31
seppeduwe 0:ae3af7d18c4a 32 Display* display=new Display();
seppeduwe 0:ae3af7d18c4a 33 display->setText("dfnklsdnfsdnf\ntttt");
seppeduwe 0:ae3af7d18c4a 34
seppeduwe 0:ae3af7d18c4a 35 display->setText("Seppd");
seppeduwe 0:ae3af7d18c4a 36 /* while(1) {
seppeduwe 0:ae3af7d18c4a 37 if(!pb) {
seppeduwe 0:ae3af7d18c4a 38 myled = 1;
seppeduwe 0:ae3af7d18c4a 39 server.connect("192.168.0.102");
seppeduwe 0:ae3af7d18c4a 40 server.send(buf);
seppeduwe 0:ae3af7d18c4a 41 }
seppeduwe 0:ae3af7d18c4a 42 else{
seppeduwe 0:ae3af7d18c4a 43 wait(0.5);
seppeduwe 0:ae3af7d18c4a 44 myled = 1;
seppeduwe 0:ae3af7d18c4a 45 wait(0.5);
seppeduwe 0:ae3af7d18c4a 46 myled = 0;
seppeduwe 0:ae3af7d18c4a 47 }
seppeduwe 0:ae3af7d18c4a 48 //char buf1[]= {0xAA,0xBB,0x0F,0x0B,0x0F,0xA0,0x02,0x05,0x08,0x09,0x0A,0x4B,0x7C,0xCC,0xDD};
seppeduwe 0:ae3af7d18c4a 49
seppeduwe 0:ae3af7d18c4a 50 //char buf1[256];
seppeduwe 0:ae3af7d18c4a 51 }*/
seppeduwe 0:ae3af7d18c4a 52 while(1) {
seppeduwe 0:ae3af7d18c4a 53 if(server.read(buf)) {
seppeduwe 0:ae3af7d18c4a 54 server.connect("192.168.0.102");
seppeduwe 0:ae3af7d18c4a 55 server.send(buf);
seppeduwe 0:ae3af7d18c4a 56 }
seppeduwe 0:ae3af7d18c4a 57
seppeduwe 0:ae3af7d18c4a 58 if(SendISR) {
seppeduwe 0:ae3af7d18c4a 59 server.connect("192.168.0.102");
seppeduwe 0:ae3af7d18c4a 60 server.send(buf);
seppeduwe 0:ae3af7d18c4a 61 SendISR=0;
seppeduwe 0:ae3af7d18c4a 62 }
seppeduwe 0:ae3af7d18c4a 63 }
seppeduwe 0:ae3af7d18c4a 64 //TCPFrame frame(buf1);
seppeduwe 0:ae3af7d18c4a 65 //frame.decode();
seppeduwe 0:ae3af7d18c4a 66 //frame.print();
seppeduwe 0:ae3af7d18c4a 67
seppeduwe 0:ae3af7d18c4a 68
seppeduwe 0:ae3af7d18c4a 69
seppeduwe 0:ae3af7d18c4a 70
seppeduwe 0:ae3af7d18c4a 71 }