This program is published for a question I throw at the forum (https://os.mbed.com/questions/80658/HardFault-occurs-when-fopen-is-called-af/). I will thank you for answering my question. Abstract: LPC1768 freezes while processing this program, especially when fopen() is called after EthernetInterface.connect() P.S.' This problem is discussed here: https://github.com/ARMmbed/mbed-os/issues/6578
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 if(net->connect()) { 00014 printf("Error!@EthernetInterface::connect()\r\n"); 00015 } else { 00016 printf("IP Address is %s\r\n", net->get_ip_address()); 00017 } 00018 func(); 00019 } 00020 00021 00022 void func() 00023 { 00024 static int i = 1; 00025 printf("-------test of fopen()#%d----\r\n", i); 00026 if(fopen("/local/test.txt", "r")==NULL) 00027 printf("File could not open\r\n"); 00028 else 00029 printf("File was opened successfully.\r\n"); 00030 i++; 00031 }
Generated on Tue Jul 12 2022 22:53:43 by 1.7.2