Operating System

Dependencies:   UnitTest mDNS

This is an operating system for K64F. It includes ssh server, POST, a web-server and mDNS.

Revision:
2:453e73d66757
Parent:
1:4059ac7ebc65
Child:
3:351ee68a721d
--- a/main.cpp	Thu Jun 13 13:54:10 2019 +0000
+++ b/main.cpp	Thu Jun 13 14:20:16 2019 +0000
@@ -42,6 +42,22 @@
     }
 };
 
+void write(unsigned int n, unsigned int addressOfX, char X){
+    unsigned int address = n * SECTOR_SIZE; //Write in last sector     
+    char *data   = (char*)address;                     //Read     
+    // This works in C and C++
+    char b[SECTOR_SIZE];
+    b[addressOfX] = X;
+    memcpy(b, data, SECTOR_SIZE * sizeof(char));       // int is a POD                           
+    erase_sector(address);                
+    program_flash(address, b, SECTOR_SIZE);            //an integers has four bytes each.
+}
+
+char read(unsigned int address){
+    char *data = (char*)address;       //Read
+    return data[0];
+}
+
 int main() {
     red = 1;
     blue = 0;
@@ -105,29 +121,6 @@
         desktop.AddChild(&win2);
     #endif
 
-
-    /*
-    printf("\nS-ATA primary master: ");
-    AdvancedTechnologyAttachment ata0m(true, 0x1F0);
-    ata0m.Identify();
-
-    printf("\nS-ATA primary slave: ");
-    AdvancedTechnologyAttachment ata0s(false, 0x1F0);
-    ata0s.Identify();
-    ata0s.Write28(0, (uint8_t*)"http://www.AlgorithMan.de", 25);
-    ata0s.Flush();
-    ata0s.Read28(0, 25);
-
-    printf("\nS-ATA secondary master: ");
-    AdvancedTechnologyAttachment ata1m(true, 0x170);
-    ata1m.Identify();
-
-    printf("\nS-ATA secondary slave: ");
-    AdvancedTechnologyAttachment ata1s(false, 0x170);
-    ata1s.Identify();
-    // third: 0x1E8
-    // fourth: 0x168
-    */
     EthernetInterface interface;
     interface.disconnect();
     interface.connect();
@@ -136,13 +129,7 @@
     const char *ip = interface.get_ip_address();
     printf("IP address is: %s\n", ip ? ip : "No IP");
     
-    //AddressResolutionProtocol arp(&etherframe);
-
-    //InternetProtocolProvider ipv4(&etherframe, &arp, gip_be, subnet_be);
     //InternetControlMessageProtocol icmp(&ipv4);
-    //UserDatagramProtocolProvider udp(&ipv4);
-    //TransmissionControlProtocolProvider tcp(&ipv4);
-
 
     //interrupts.Activate();
 
@@ -169,20 +156,10 @@
     //icmp.RequestEchoReply(gip_be);
 
     //PrintfUDPHandler udphandler;
-    //UserDatagramProtocolSocket* udpsocket = udp.Connect(ip2_be, 1234);
-    //udp.Bind(udpsocket, &udphandler);
-    //udpsocket->Send((uint8_t*)"Hello UDP!", 10);
 
     //UserDatagramProtocolSocket* udpsocket = udp.Listen(1234);
     //udp.Bind(udpsocket, &udphandler);
-    
-    /*unsigned int addressId = 1;
-    unsigned int address = flash_size() - SECTOR_SIZE; //Write in last sector                                     
-    erase_sector(address);                
-    program_flash(address, (char*)&addressId, 4);      //an integers has four bytes each.
-    
-    unsigned int *data   = (unsigned int*)address;     //Read*/
-                    
+  
     while (true){
           //printf("\nCLIENT - Sending '%i' to server %s\r\n", screen[0], SERVER_IP);       //print message to send
           sockUDP.sendto(SERVER_IP, PORT, screen, sizeof(screen));