LPC1768 DOESN'T freeze while processing this program, even when fopen() is called after EthernetInterface.connect() (with MBED OS 2) see also https://os.mbed.com/users/aktk/code/eth-filesystem-sample/
Dependencies: EthernetInterface mbed-rtos mbed
Fork of eth-filesystem-sample by
main.cpp@1:4de86c361e68, 2018-03-22 (annotated)
- Committer:
- aktk
- Date:
- Thu Mar 22 21:06:00 2018 +0000
- Revision:
- 1:4de86c361e68
- Parent:
- 0:a1a5934e82aa
mbed os 2 ver.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aktk | 0:a1a5934e82aa | 1 | #include "mbed.h" |
aktk | 0:a1a5934e82aa | 2 | #include "EthernetInterface.h" |
aktk | 0:a1a5934e82aa | 3 | |
aktk | 0:a1a5934e82aa | 4 | LocalFileSystem local("local"); |
aktk | 0:a1a5934e82aa | 5 | void func(); |
aktk | 0:a1a5934e82aa | 6 | EthernetInterface *net; |
aktk | 0:a1a5934e82aa | 7 | |
aktk | 0:a1a5934e82aa | 8 | int main() |
aktk | 0:a1a5934e82aa | 9 | { |
aktk | 0:a1a5934e82aa | 10 | func(); |
aktk | 0:a1a5934e82aa | 11 | net = new EthernetInterface(); |
aktk | 0:a1a5934e82aa | 12 | func(); |
aktk | 1:4de86c361e68 | 13 | net->init(); |
aktk | 0:a1a5934e82aa | 14 | if(net->connect()) { |
aktk | 0:a1a5934e82aa | 15 | printf("Error!@EthernetInterface::connect()\r\n"); |
aktk | 0:a1a5934e82aa | 16 | } else { |
aktk | 1:4de86c361e68 | 17 | printf("IP Address is %s\r\n", net->getIPAddress()); |
aktk | 0:a1a5934e82aa | 18 | } |
aktk | 0:a1a5934e82aa | 19 | func(); |
aktk | 0:a1a5934e82aa | 20 | } |
aktk | 0:a1a5934e82aa | 21 | |
aktk | 0:a1a5934e82aa | 22 | |
aktk | 0:a1a5934e82aa | 23 | void func() |
aktk | 0:a1a5934e82aa | 24 | { |
aktk | 0:a1a5934e82aa | 25 | static int i = 1; |
aktk | 0:a1a5934e82aa | 26 | printf("-------test of fopen()#%d----\r\n", i); |
aktk | 0:a1a5934e82aa | 27 | if(fopen("/local/test.txt", "r")==NULL) |
aktk | 0:a1a5934e82aa | 28 | printf("File could not open\r\n"); |
aktk | 0:a1a5934e82aa | 29 | else |
aktk | 0:a1a5934e82aa | 30 | printf("File was opened successfully.\r\n"); |
aktk | 0:a1a5934e82aa | 31 | i++; |
aktk | 0:a1a5934e82aa | 32 | } |