How to get a local library work?

Hi there,

I am trying to use micro sd cards working on a particle photon. For that, I’d like to use the SdFat library.
There is a version of SdFat on the library cloud, but for a reason I need this specific version (GitHub - greiman/SdFat-Particle: SD library for Particle.io devices) working on my photon.

Now, I am new to particle products (and Arduino), I am not quite sure how I can get it work.
So far I’ve tried

  1. downloading the entire library and copy/paste everything into the folder that contains the main info file (the project folder) - and it works. However, it is probably not a good solution from the file management perspective.

  2. copying and pasting everything into the ‘lib’ folder - does not work. When I try to include the SdFat.h file at the beginning of the .ino file, it cannot import the header.

So what would be the correct way to get the library working? Thank you.

Which version would you need?
If the Greiman-Repo is further on than the Particle repository it would be good to get the latest version uploaded which @whg usually does quite swiftly.

If you needed a previous version you can select them by clicking the (i) icon next to/below the library name
image

This will let you select one of the previously uploaded versions

However, in order to access a downloaded library it needs to sit in its own folder inside the ./lib folder
e.g.

localLibTest
├───lib
│   └───SdFat
│       ├───examples
│       │   ├───#attic
│       │   │   ├───AnalogLogger
│       │   │   ├───append
│       │   │   ├───average
│       │   │   ├───BaseExtCaseTest
│       │   │   ├───benchSD
│       │   │   ├───bufstream
│       │   │   ├───cin_cout
│       │   │   ├───eventlog
│       │   │   ├───fgetsRewrite
│       │   │   ├───HelloWorld
│       │   │   ├───MiniSerial
│       │   │   ├───PrintBenchmarkSD
│       │   │   ├───readlog
│       │   │   ├───SdFatSize
│       │   │   ├───SD_Size
│       │   │   └───StreamParseInt
│       │   ├───AnalogBinLogger
│       │   ├───bench
│       │   ├───dataLogger
│       │   ├───DirectoryFunctions
│       │   ├───fgets
│       │   ├───formatting
│       │   ├───getline
│       │   ├───LongFileName
│       │   │   └───testFiles
│       │   ├───LowLatencyLogger
│       │   ├───LowLatencyLoggerADXL345
│       │   ├───LowLatencyLoggerMPU6050
│       │   ├───OpenNext
│       │   ├───PrintBenchmark
│       │   ├───QuickStart
│       │   ├───RawWrite
│       │   ├───ReadCsv
│       │   ├───ReadCsvArray
│       │   ├───ReadCsvStream
│       │   ├───ReadWrite
│       │   ├───rename
│       │   ├───SdFormatter
│       │   ├───SdInfo
│       │   ├───SoftwareSpi
│       │   ├───StdioBench
│       │   ├───STM32Test
│       │   ├───TeensySdioDemo
│       │   ├───Timestamp
│       │   ├───TwoCards
│       │   ├───VolumeFreeSpace
│       │   └───wipe
│       ├───extras
│       │   ├───AnalogBinLoggerExtras
│       │   │   ├───ADCdocs
│       │   │   └───bintocsv
│       │   ├───html
│       │   │   └───search
│       │   ├───MainPage
│       │   └───SdFatTestSuite
│       │       └───examples
│       │           ├───ATS_SD_File
│       │           ├───ATS_SD_Files
│       │           ├───ATS_SD_Seek
│       │           ├───fstreamTest
│       │           ├───istreamTest
│       │           ├───lfnSize
│       │           ├───lfnTest
│       │           ├───lfnTestCout
│       │           ├───ostreamTest
│       │           ├───StressTest
│       │           ├───TestMkdir
│       │           └───TestRmdir
│       └───src
│           ├───FatLib
│           ├───SdCard
│           └───SpiDriver
│               └───boards
└───src

If you still have problems you may want to remove the examples folder(s) to prevent confusions with multiple .ino files in the project.

@ScruffR Thank you for your fast reply.

After copying and pasting the library into the lib folder, here is the directory tree I have now.

├── README.md
├── lib
│   ├── LICENSE
│   ├── README.md
│   ├── library.properties
│   └── src
│       ├── ArduinoFiles.h
│       ├── ArduinoStream.h
│       ├── FatApiConstants.h
│       ├── FatFile.cpp
│       ├── FatFile.h
│       ├── FatFileLFN.cpp
│       ├── FatFilePrint.cpp
│       ├── FatFileSFN.cpp
│       ├── FatFileSystem.h
│       ├── FatLib.h
│       ├── FatLibConfig.h
│       ├── FatStructs.h
│       ├── FatVolume.cpp
│       ├── FatVolume.h
│       ├── FmtNumber.cpp
│       ├── FmtNumber.h
│       ├── FreeStack.h
│       ├── SdFat
│       │   ├── ArduinoFiles.h
│       │   ├── ArduinoStream.h
│       │   ├── FatApiConstants.h
│       │   ├── FatFile.h
│       │   ├── FatFileSystem.h
│       │   ├── FatLib.h
│       │   ├── FatLibConfig.h
│       │   ├── FatStructs.h
│       │   ├── FatVolume.h
│       │   ├── FmtNumber.h
│       │   ├── FreeStack.h
│       │   ├── SdFat.h
│       │   ├── SdFatConfig.h
│       │   ├── SdInfo.h
│       │   ├── SdSpi.h
│       │   ├── SdSpiCard.h
│       │   ├── SoftSPIParticle.h
│       │   ├── StdioStream.h
│       │   ├── SysCall.h
│       │   ├── SystemInclude.h
│       │   ├── bufstream.h
│       │   ├── fstream.h
│       │   ├── ios.h
│       │   ├── iostream.h
│       │   ├── istream.h
│       │   └── ostream.h
│       ├── SdFat.cpp
│       ├── SdFat.h
│       ├── SdFatConfig.h
│       ├── SdInfo.h
│       ├── SdSpi.h
│       ├── SdSpiCard.cpp
│       ├── SdSpiCard.h
│       ├── SdSpiParticle.cpp
│       ├── SoftSPIParticle.h
│       ├── StdioStream.cpp
│       ├── StdioStream.h
│       ├── SysCall.h
│       ├── SystemInclude.h
│       ├── bufstream.h
│       ├── fstream.cpp
│       ├── fstream.h
│       ├── ios.h
│       ├── iostream.h
│       ├── istream.cpp
│       ├── istream.h
│       ├── ostream.cpp
│       └── ostream.h
├── photon_firmware_1608729066706.bin
├── project.properties
├── src
│   ├── badaf_photon.cpp
│   ├── badaf_photon.ino
│   └── badaf_photon_backup.txt
├── target
│   └── 2.0.1
│       └── photon
│           ├── badaf_photon.bin
│           ├── badaf_photon.bin.crc_block
│           ├── badaf_photon.bin.no_crc
│           ├── badaf_photon.dfu
│           ├── badaf_photon.elf
│           ├── badaf_photon.hex
│           ├── badaf_photon.lst
│           ├── badaf_photon.map
│           └── obj
│               └── src
│                   ├── module_info.o
│                   ├── module_info.o.d
│                   ├── newlib_stubs.o
│                   ├── newlib_stubs.o.d
│                   ├── user_export.o
│                   ├── user_export.o.d
│                   ├── user_module.o
│                   └── user_module.o.d
└── workspace.code-workspace

I’ve removed the examples folder as you suggested.
Yet, when I try to flash an example file, it gives the following error

Any help would be immensely appreciated. Thank you!

You are still missing one hierarchical level.

vs.

@ScruffR Man, now it works! I can flash those example files successfully. Thank you!

I have one more question though, if you don’t mind…

While it seems to work now, the error message still persists,

Do you have any clue why I am still getting this message?

IntelliSense is often getting a bit skittish about libraries and sometimes sees issues where there aren’t any.

Unfortunately that is a long standing issue @m_m has already ticked on the VS Code forum.

1 Like

Got it. Thank you!

@jwonlee fwiw, we have intellisense troubleshooting steps over here:

usually closing and re-opening the project fixes things though i recognize that's far from idea.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.