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

P.S.' This problem is discussed here: https://github.com/ARMmbed/mbed-os/issues/6578

main.cpp

Committer:
aktk
Date:
2018-03-22
Revision:
0:a1a5934e82aa

File content as of revision 0:a1a5934e82aa:

#include "mbed.h"
#include "EthernetInterface.h"

LocalFileSystem local("local");
void func();
EthernetInterface *net;

int main()
{
    func();
    net = new EthernetInterface();
    func();
    if(net->connect()) {
        printf("Error!@EthernetInterface::connect()\r\n");
    } else {
        printf("IP Address is %s\r\n", net->get_ip_address());
    }
    func();
}


void func()
{
    static int i = 1;
    printf("-------test of fopen()#%d----\r\n", i);
    if(fopen("/local/test.txt", "r")==NULL)
        printf("File could not open\r\n");
    else
        printf("File was opened successfully.\r\n");
    i++;
}