contiki:simple-udp-workshop
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| contiki:simple-udp-workshop [2015/05/27 17:46] – [5. Interaktion mit dem UDP-Service] admin | contiki:simple-udp-workshop [2018/12/03 14:53] (aktuell) – admin | ||
|---|---|---|---|
| Zeile 5: | Zeile 5: | ||
| * Die Installation von [[http:// | * Die Installation von [[http:// | ||
| * Anmeldung an //Instant Contiki// mit dem Passwort: '' | * Anmeldung an //Instant Contiki// mit dem Passwort: '' | ||
| - | * Die folgende Beschreibung bezieht sich immer auf das Quellcode-Verzeichnis: | + | * Die folgende Beschreibung bezieht sich immer auf das Quellcode-Verzeichnis: |
| ==== 2. Anpassungen des Quellcodes ==== | ==== 2. Anpassungen des Quellcodes ==== | ||
| Zeile 12: | Zeile 12: | ||
| === 2.1 Erstellen eines neuen Projekt-Verzeichnisses === | === 2.1 Erstellen eines neuen Projekt-Verzeichnisses === | ||
| - | - Erstellen Sie das Verzeichnis: | + | - Erstellen Sie das Verzeichnis: |
| - | === 2.2 Erstellen des Quellcodes | + | === 2.2 Erstellen des Makefiles |
| Für das Projekt werden eine C-Datei und ein Makefile benötigt. | Für das Projekt werden eine C-Datei und ein Makefile benötigt. | ||
| Zeile 44: | Zeile 44: | ||
| </ | </ | ||
| + | === 2.3 Erstellen des Quellcodes === | ||
| - Erstellen Sie die C-Datei '' | - Erstellen Sie die C-Datei '' | ||
| Zeile 57: | Zeile 58: | ||
| #include " | #include " | ||
| #include " | #include " | ||
| - | #include " | + | #include "net/ip/ |
| #include " | #include " | ||
| #include < | #include < | ||
| Zeile 173: | Zeile 174: | ||
| #include " | #include " | ||
| - | #include "contiki-net.h" | + | #include "sys/ |
| - | #include "contiki-lib.h" | + | #include " |
| - | #include < | + | #include "net/ip/uip.h" |
| + | #include "net/ | ||
| + | #include < | ||
| + | #include < | ||
| - | # | + | #include " |
| - | static struct | + | # |
| + | #define SEND_INTERVAL | ||
| + | |||
| + | static struct | ||
| / | / | ||
| - | PROCESS(hello_world_process, "Hello world process" | + | PROCESS(client_example_process, "UDP client example |
| - | AUTOSTART_PROCESSES(& | + | AUTOSTART_PROCESSES(& |
| / | / | ||
| - | PROCESS_THREAD(hello_world_process, ev, data) | + | static void |
| + | receiver(struct simple_udp_connection *c, | ||
| + | const uip_ipaddr_t *sender_addr, | ||
| + | | ||
| + | const uip_ipaddr_t *receiver_addr, | ||
| + | | ||
| + | const uint8_t *data, | ||
| + | | ||
| { | { | ||
| + | printf(" | ||
| + | | ||
| + | } | ||
| + | / | ||
| + | PROCESS_THREAD(client_example_process, | ||
| + | { | ||
| + | static struct etimer periodic_timer; | ||
| + | uip_ipaddr_t addr; | ||
| + | |||
| PROCESS_BEGIN(); | PROCESS_BEGIN(); | ||
| + | //ohne simple_udp_register funktioniert das Senden nicht! | ||
| + | simple_udp_register(& | ||
| + | NULL, UDP_PORT, receiver); | ||
| - | | + | |
| + | while(1) | ||
| + | { | ||
| + | PROCESS_WAIT_EVENT_UNTIL(etimer_expired(& | ||
| + | etimer_reset(& | ||
| - | char buf[MAX_PAYLOAD_LEN]; | + | printf(" |
| - | | + | |
| - | uip_ipaddr(& | + | // senden auf die eigene Adresse 172.18.0.2 funktioniert bei |
| - | | + | // Instant-Contiki nicht: arp auf tun0-Interface? |
| - | / | + | //uip_ipaddr(& |
| - | sprintf(buf, "Hello from the Client!\n | + | |
| - | /*Versende das Packet*/ | + | |
| - | int i; | + | |
| - | for (i=0; i<100; i++) | + | |
| - | uip_udp_packet_send(udpconn, buf, strlen(buf)); | + | |
| - | | + | |
| PROCESS_END(); | PROCESS_END(); | ||
| } | } | ||
| </ | </ | ||
contiki/simple-udp-workshop.1432748761.txt.gz · Zuletzt geändert: (Externe Bearbeitung)
