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@0:a1a5934e82aa, 2018-03-22 (annotated)
- Committer:
- aktk
- Date:
- Thu Mar 22 20:18:38 2018 +0000
- Revision:
- 0:a1a5934e82aa
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 | } |