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@0:a1a5934e82aa, 2018-03-22 (annotated)
- Committer:
- aktk
- Date:
- Thu Mar 22 20:18:38 2018 +0000
- Revision:
- 0:a1a5934e82aa
- Child:
- 1:4de86c361e68
mbed freezes when fopen() after (EthernetInterface*)net->connet();
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 | 0:a1a5934e82aa | 13 | if(net->connect()) { |
aktk | 0:a1a5934e82aa | 14 | printf("Error!@EthernetInterface::connect()\r\n"); |
aktk | 0:a1a5934e82aa | 15 | } else { |
aktk | 0:a1a5934e82aa | 16 | printf("IP Address is %s\r\n", net->get_ip_address()); |
aktk | 0:a1a5934e82aa | 17 | } |
aktk | 0:a1a5934e82aa | 18 | func(); |
aktk | 0:a1a5934e82aa | 19 | } |
aktk | 0:a1a5934e82aa | 20 | |
aktk | 0:a1a5934e82aa | 21 | |
aktk | 0:a1a5934e82aa | 22 | void func() |
aktk | 0:a1a5934e82aa | 23 | { |
aktk | 0:a1a5934e82aa | 24 | static int i = 1; |
aktk | 0:a1a5934e82aa | 25 | printf("-------test of fopen()#%d----\r\n", i); |
aktk | 0:a1a5934e82aa | 26 | if(fopen("/local/test.txt", "r")==NULL) |
aktk | 0:a1a5934e82aa | 27 | printf("File could not open\r\n"); |
aktk | 0:a1a5934e82aa | 28 | else |
aktk | 0:a1a5934e82aa | 29 | printf("File was opened successfully.\r\n"); |
aktk | 0:a1a5934e82aa | 30 | i++; |
aktk | 0:a1a5934e82aa | 31 | } |