Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Low_Cost_PWM by
Ethernet.cpp@6:f97371e6bc3e, 2014-09-10 (annotated)
- Committer:
- Racer01014
- Date:
- Wed Sep 10 12:59:51 2014 +0000
- Revision:
- 6:f97371e6bc3e
- Parent:
- 3:77adbd7956b9
-
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Racer01014 | 3:77adbd7956b9 | 1 | |
| Racer01014 | 3:77adbd7956b9 | 2 | #include "mbed.h" |
| Racer01014 | 3:77adbd7956b9 | 3 | #include "EthernetInterface.h" |
| Racer01014 | 3:77adbd7956b9 | 4 | #include "USBSerial.h" |
| Racer01014 | 3:77adbd7956b9 | 5 | |
| Racer01014 | 3:77adbd7956b9 | 6 | |
| Racer01014 | 3:77adbd7956b9 | 7 | Serial pc(USBTX, USBRX); |
| Racer01014 | 3:77adbd7956b9 | 8 | |
| Racer01014 | 3:77adbd7956b9 | 9 | int main() |
| Racer01014 | 3:77adbd7956b9 | 10 | { |
| Racer01014 | 3:77adbd7956b9 | 11 | |
| Racer01014 | 3:77adbd7956b9 | 12 | EthernetInterface eth; |
| Racer01014 | 3:77adbd7956b9 | 13 | |
| Racer01014 | 3:77adbd7956b9 | 14 | int err = eth.init(); |
| Racer01014 | 3:77adbd7956b9 | 15 | if (err) |
| Racer01014 | 3:77adbd7956b9 | 16 | pc.printf("eth.init() failed. (%d)\n\r", err); |
| Racer01014 | 3:77adbd7956b9 | 17 | else |
| Racer01014 | 3:77adbd7956b9 | 18 | pc.printf("eth.init() successful.\n\r"); |
| Racer01014 | 3:77adbd7956b9 | 19 | |
| Racer01014 | 3:77adbd7956b9 | 20 | err = eth.connect(); |
| Racer01014 | 3:77adbd7956b9 | 21 | if (err) |
| Racer01014 | 3:77adbd7956b9 | 22 | pc.printf("eth.connect() failed. (%d)\n\r", err); |
| Racer01014 | 3:77adbd7956b9 | 23 | else |
| Racer01014 | 3:77adbd7956b9 | 24 | pc.printf("eth.connect() successful.\n\r"); |
| Racer01014 | 3:77adbd7956b9 | 25 | |
| Racer01014 | 3:77adbd7956b9 | 26 | char *ip_address = eth.getIPAddress(); |
| Racer01014 | 3:77adbd7956b9 | 27 | pc.printf("IP-Address: %s\n\r", ip_address); |
| Racer01014 | 3:77adbd7956b9 | 28 | |
| Racer01014 | 3:77adbd7956b9 | 29 | err = udp.init(); |
| Racer01014 | 3:77adbd7956b9 | 30 | if (err) |
| Racer01014 | 3:77adbd7956b9 | 31 | pc.printf("udp.init() failed. (%d)\n\r", err); |
| Racer01014 | 3:77adbd7956b9 | 32 | else |
| Racer01014 | 3:77adbd7956b9 | 33 | pc.printf("udp.init() successful.\n\r"); |
| Racer01014 | 3:77adbd7956b9 | 34 | |
| Racer01014 | 3:77adbd7956b9 | 35 | err = udp_dest.set_address("192.168.0.183", 1234); |
| Racer01014 | 3:77adbd7956b9 | 36 | if (err) |
| Racer01014 | 3:77adbd7956b9 | 37 | pc.printf("udp_dest.set_address() failed. (%d)\n\r", err); |
| Racer01014 | 3:77adbd7956b9 | 38 | else |
| Racer01014 | 3:77adbd7956b9 | 39 | pc.printf("udp_dest.set_address() successful.\n\r"); |
| Racer01014 | 3:77adbd7956b9 | 40 | |
| Racer01014 | 3:77adbd7956b9 | 41 | |
| Racer01014 | 3:77adbd7956b9 | 42 | } |
