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 Akifumi Takahashi

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "EthernetInterface.h"
00003 
00004 LocalFileSystem local("local");
00005 void func();
00006 EthernetInterface *net;
00007 
00008 int main()
00009 {
00010     func();
00011     net = new EthernetInterface();
00012     func();
00013     net->init();
00014     if(net->connect()) {
00015         printf("Error!@EthernetInterface::connect()\r\n");
00016     } else {
00017         printf("IP Address is %s\r\n", net->getIPAddress());
00018     }
00019     func();
00020 }
00021 
00022 
00023 void func()
00024 {
00025     static int i = 1;
00026     printf("-------test of fopen()#%d----\r\n", i);
00027     if(fopen("/local/test.txt", "r")==NULL)
00028         printf("File could not open\r\n");
00029     else
00030         printf("File was opened successfully.\r\n");
00031     i++;
00032 }