Hello! I am having an issue with reading a txt file on my Nucleo-f303k8. Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include “mbed.h”
#include <errno.h>
void file_read() { // array heeft lengte van array_size, elke array bevat 3 coordinaten
FILE *filepointer = fopen("C:\\test.txt", "r");
if (filepointer == NULL) {
printf("Can't open file\n");
} else {
int one_or_zero = 0;
int x = 0;
int y = 0;
while (!feof(filepointer)) {
fscanf(filepointer, "%d%d%d\n", &one_or_zero, &x, &y);
printf("%d %d %d\n", one_or_zero, x, y);
}
}
fclose(filepointer);
}
int main(){
file_read();
}
and this is what the txt file says:
1 100 20
0 30 40
1 20 60
When i compile this there are no problems. But when i load the code on to my NucleoF303K8, Realterm gives me the following error:
++ MbedOS Fault Handler ++
FaultType: HardFault
Context:
R0 : 080003AF
R1 : 016C8000
R2 : 08004456
R3 : 00000019
R4 : 00000000
R5 : 080002DF
R6 : 080002E5
R7 : FFFFFFFF
R8 : 080002DF
R9 : 00000000
R10 : 08006AF0
R11 : 08006AF0
R12 : 01010101
SP : 20002FB8
LR : 08000AD7
PC : 080013AA
xPSR : 01000000
PSP : 00000000
MSP : 20002F50
CPUID: 410FC241
HFSR : 40000000
MMFSR: 00000000
BFSR : 00000004
UFSR : 00000000
DFSR : 00000008
AFSR : 00000000
Mode : Thread
Priv : Privileged
Stack: MSP
– MbedOS Fault Handler –
++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x800519F
Error Value: 0x80013AA
For more info, visit: mbedos-error
– MbedOS Error Info –
I visited the links provided in the error message but they made me none the wiser. Can anyone see what’s wrong with my code?