Hello,
I am trying to open a TXT file on my SD card using the FatFS libraries.
I have included all of the needed files in my code for a simple f_open operation where i create a TXT file on my SD card. However, it says it can not find f_open (see image below).
This makes no sense to me. I have included the files in my code and when i ctr+click on the #include line it opens the ff.h library perfectly fine, which is where it defines the f_open function.
I have included my code below. The lines relevant for this issue are line 30-32 and line 205.
Why am I getting this error?
Kind regards,
Mirte H
/***** Includes *****/ /* Standard C Libraries */ #include <stdlib.h> #include<stdio.h> #include<string.h> #include <math.h> /* TI Drivers */ #include <ti/drivers/rf/RF.h> #include <ti/drivers/PIN.h> #include <ti/display/Display.h> /* Driverlib Header files */ #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h) /* Board Header files */ #include "Board.h" /* Application Header files */ #include "RFQueue.h" #include "smartrf_settings/smartrf_settings.h" /* BIOS Header files */ #include <ti/sysbios/BIOS.h> #include <ti/sysbios/knl/Semaphore.h> #include <ti/sysbios/knl/Task.h> #include <ti/drivers/UART.h> #include <third_party/fatfs/ff.h> #include <third_party/fatfs/diskio.h> #include <file.h> /* Custom header files */ #include <CRC8.h> #include <Manchester.h> /***** Defines *****/ /* Packet RX Configuration */ #define DATA_ENTRY_HEADER_SIZE 9 /* Constant header size of a Generic Data Entry */ #define MAX_LENGTH 19 /* Max length byte the radio will accept */ #define NUM_DATA_ENTRIES 2 /* NOTE: Only two data entries supported at the moment */ #define NUM_APPENDED_BYTES 2 /* The Data Entries data field will contain: * 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1) * Max 30 payload bytes * 1 status byte (RF_cmdPropRx.rxConf.bAppendStatus = 0x1) */ /***** Prototypes *****/ static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e); /***** Variable declarations *****/ static RF_Object rfObject; static RF_Handle rfHandle; /* Pin driver handle */ static PIN_Handle ledPinHandle; static PIN_State ledPinState; /* Buffer which contains all Data Entries for receiving data. * Pragmas are needed to make sure this buffer is 4 byte aligned (requirement from the RF Core) */ #if defined(__TI_COMPILER_VERSION__) #pragma DATA_ALIGN (rxDataEntryBuffer, 4); static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES, MAX_LENGTH, NUM_APPENDED_BYTES)]; #elif defined(__IAR_SYSTEMS_ICC__) #pragma data_alignment = 4 static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES, MAX_LENGTH, NUM_APPENDED_BYTES)]; #elif defined(__GNUC__) static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES, MAX_LENGTH, NUM_APPENDED_BYTES)] __attribute__((aligned(4))); #else #error This compiler is not supported. #endif /* Receive dataQueue for RF Core to fill in data */ static dataQueue_t dataQueue; static rfc_dataEntryGeneral_t* currentDataEntry; static uint8_t packetLength; static uint8_t* packetDataPointer; static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */ /* Custom raw and decoded payloads */ uint8_t payload[19]; uint8_t decoded[MAX_LENGTH]; /* RX Semaphore */ static Semaphore_Struct rxSemaphore; static Semaphore_Handle rxSemaphoreHandle; float twodecround(float var); float twodecround(float var){ var = (var*100); int value = round(var); var = value; var /= 100; //TODO: ROUND TO TWO DECIMALS return var; } /* * Application LED pin configuration table: * - All LEDs board LEDs are off. */ PIN_Config pinTable[] = { Board_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, PIN_TERMINATE }; /***** Function definitions *****/ void *mainThread(void *arg0) { RF_Params rfParams; RF_Params_init(&rfParams); /* Initialize RX semaphore */ Semaphore_construct(&rxSemaphore, 0, NULL); rxSemaphoreHandle = Semaphore_handle(&rxSemaphore); Display_Params params; Display_Params_init(¶ms); params.lineClearMode = DISPLAY_CLEAR_BOTH; Display_Handle uartDisplayHandle = Display_open(Display_Type_UART, ¶ms); /* Open LED pins */ ledPinHandle = PIN_open(&ledPinState, pinTable); if (ledPinHandle == NULL) { while(1); } if( RFQueue_defineQueue(&dataQueue, rxDataEntryBuffer, sizeof(rxDataEntryBuffer), NUM_DATA_ENTRIES, MAX_LENGTH + NUM_APPENDED_BYTES)) { /* Failed to allocate space for all data entries */ while(1); } /* Modify CMD_PROP_RX command for application needs */ /* Set the Data Entity queue for received data */ RF_cmdPropRx.pQueue = &dataQueue; /* Discard ignored packets from Rx queue */ RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1; /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */ RF_cmdPropRx.maxPktLen = MAX_LENGTH; RF_cmdPropRx.pktConf.bRepeatOk = 1; RF_cmdPropRx.pktConf.bRepeatNok = 1; /* Request access to the radio */ #if defined(DeviceFamily_CC26X0R2) rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams); #else rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); #endif// DeviceFamily_CC26X0R2 /* Set the frequency */ RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0); /* Enter RX mode and stay forever in RX */ RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone); while(1) { FIL fil; /* File object */ char line[100]; /* Line buffer */ FRESULT fr; /* FatFs return code */ fr = f_open(&fil, "message.txt", FA_CREATE_NEW | FA_WRITE); Semaphore_pend(rxSemaphoreHandle, BIOS_WAIT_FOREVER); uint8_t CRC_OK_NOK = 0; float DataCalc = 0; float degC = 0; float hum = 0; float vbat = 0; uint8_t LENGTH =0; uint8_t ID0=0; uint8_t ID1=0; uint8_t ID2=0; uint32_t ID_FULL = 0; uint8_t TYPE=0; uint8_t DATA0=0; uint8_t DATA1=0; uint16_t DATA_FULL = 0; uint8_t CRC=0; uint8_t nCRC=0; uint32_t temp_id = 0; uint16_t temp_id5 = 0; int c = 0; for (c = 0; c < 19; c++) { payload[c] = manDecode(packet[c]); } LENGTH |= payload[0]; LENGTH <<= 4; LENGTH |= payload[1]; if(LENGTH == 5){ ID0 |= payload[4]; ID0 <<= 4; ID0 |= payload[5]; ID1 |= payload[2]; ID1 <<= 4; ID1 |= payload[3]; DATA0 |= payload[6]; DATA0 <<= 4; DATA0 |= payload[7]; DATA1 |= payload[8]; DATA1 <<= 4; DATA1 |= payload[9]; CRC |= payload[10]; CRC <<= 4; CRC |= payload[11]; CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, 0, 0, DATA0, DATA1, CRC, 0); DATA_FULL |= DATA0; DATA_FULL <<=8; DATA_FULL |= DATA1; DataCalc = DATA_FULL; ID_FULL |= ID0; ID_FULL <<=8; ID_FULL |= ID1; if(CRC_OK_NOK == 1) { DataCalc /= 100; DataCalc *=0.78125; // IF LAATSTE BIT ID 1 IS DAN IS HET TEMP temp_id5 = ID_FULL; temp_id5 <<= 15; temp_id5 >>= 15; if(temp_id5 == 1) { degC = twodecround(DataCalc); } else { hum = twodecround(DataCalc); } } } if(LENGTH == 7) { ID0 |= payload[6]; ID0 <<= 4; ID0 |= payload[7]; ID1 |= payload[4]; ID1 <<= 4; ID1 |= payload[5]; ID2 |= payload[2]; ID2 <<= 4; ID2 |= payload[3]; TYPE |= payload[8]; TYPE <<= 4; TYPE |= payload[9]; DATA0 |= payload[10]; DATA0 <<= 4; DATA0 |= payload[11]; DATA1 |= payload[12]; DATA1 <<= 4; DATA1 |= payload[13]; CRC |= payload[14]; CRC <<= 4; CRC |= payload[15]; nCRC |= payload[16]; nCRC <<= 4; nCRC |= payload[17]; CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, ID2, TYPE, DATA0, DATA1, CRC, nCRC); DATA_FULL |= DATA0; DATA_FULL <<=8; DATA_FULL |= DATA1; ID_FULL |= ID0; ID_FULL <<=8; ID_FULL |= ID1; ID_FULL <<=8; ID_FULL |= ID2; if(CRC_OK_NOK == 1) { switch (TYPE) { case 32: //20, CHECKED: TC77 OR MCP9808 DATA_FULL <<= 3; degC = DATA_FULL; degC /= 100; degC *= 0.09765625; degC = twodecround(degC); break; case 0x48: //30, NOT CHECKED: T6613 // not used break; case 64: //40, CHECKED: SHT10 temp_id = 0; temp_id = ID_FULL; temp_id <<= 31; temp_id >>= 31; // IF LAATSTE BIT ID 1 IS DAN IS HET HUM if(temp_id == 1) { //IF HUM: float tempHum = DATA_FULL * DATA_FULL; tempHum *=1.5955E-6; hum = DATA_FULL; hum *= 0.0367; hum -= 2.0468; hum -= tempHum; hum = twodecround(hum); } else{ degC = DATA_FULL; degC *= 0.01; degC -= 39.6; degC = twodecround(degC); } break; case 80: //50, NOT CHECKED //HDS1080 // //IF HUM: // hum = DATA; // hum *= 0.152587890625; // // // IF TEMP: // degC = DATA; // degC *= 0.25177001953125; // degC -= 4000; break; case 224: //E0 CHECKED: temp pt100 degC = DATA_FULL; degC /= 100; degC *= 0.390625; degC = twodecround(degC); break; case 240: //F0, CHECKED bat volt vbat = 2097.152; vbat /= DATA_FULL; vbat = twodecround(vbat); break; default: // UNKNOWN DataCalc = 69420; break; } } } } } void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e) { if (e & RF_EventRxEntryDone) { /* Toggle pin to indicate RX */ PIN_setOutputValue(Board_PIN_RLED, CC1310_LAUNCHXL_PIN_RLED , !PIN_getOutputValue(Board_PIN_RLED )); /* Get current unhandled data entry */ currentDataEntry = RFQueue_getDataEntry(); /* Handle the packet data, located at ¤tDataEntry->data: * - Length is the first byte with the current configuration * - Data starts from the second byte */ packetLength = 19; packetDataPointer = (uint8_t*)(¤tDataEntry->data + 1); /* Copy the payload + the status byte to the packet variable */ memcpy(packet, packetDataPointer, (packetLength + 1)); RFQueue_nextEntry(); Semaphore_post(rxSemaphoreHandle); } }