Difference between revisions of "Component: File (SD/SDHC Card) (File)"
From Flowcode Help
Jump to navigationJump to search(2 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
==Component Source Code== | ==Component Source Code== | ||
− | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/ | + | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_File_SD_FAT.fcfx FC_Comp_Source_File_SD_FAT.fcfx] |
− | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/ | + | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_File_SD_FAT.fcfx FC_Comp_Source_File_SD_FAT.fcfx] |
==Detailed description== | ==Detailed description== | ||
Line 48: | Line 48: | ||
''<span style="color:red;">No additional examples</span>'' | ''<span style="color:red;">No additional examples</span>'' | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
Line 56: | Line 62: | ||
==Macro reference== | ==Macro reference== | ||
+ | |||
+ | ===AppendByteArrayToFile=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendByteArrayToFile''' | ||
+ | |- | ||
+ | | colspan="2" | Adds a binary byte array to the end of the file. Returns 0 for success. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Binary data array to append to the file | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Length | ||
+ | |- | ||
+ | | colspan="2" | Number of values to append | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
===AppendByteToFile=== | ===AppendByteToFile=== | ||
Line 70: | Line 100: | ||
|- | |- | ||
| colspan="2" | Data to append to the end of the file | | colspan="2" | Data to append to the end of the file | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===AppendFloatArrayToFile=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendFloatArrayToFile''' | ||
+ | |- | ||
+ | | colspan="2" | Adds a binary float array to the end of the file. Returns 0 for success. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Binary data array to append to the file | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Length | ||
+ | |- | ||
+ | | colspan="2" | Number of values to append | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===AppendINTArrayToFile=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendINTArrayToFile''' | ||
+ | |- | ||
+ | | colspan="2" | Adds a binary INT array to the end of the file. Returns 0 for success. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Binary data array to append to the file | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Length | ||
+ | |- | ||
+ | | colspan="2" | Number of values to append | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBFirst | ||
+ | |- | ||
+ | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===AppendLongArrayToFile=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendLongArrayToFile''' | ||
+ | |- | ||
+ | | colspan="2" | Adds a binary Long array to the end of the file. Returns 0 for success. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Binary data array to append to the file | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Length | ||
+ | |- | ||
+ | | colspan="2" | Number of values to append | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBFirst | ||
+ | |- | ||
+ | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
Line 153: | Line 265: | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | ||
|- | |- | ||
− | | colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns 0 | + | | colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns: 0=OK / 236 = MBR Invalid / 237 = MBR Fail / 254=No Response / 255=No Card |
|- | |- | ||
|- | |- | ||
Line 214: | Line 326: | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===ReadByteArrayFromFile=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteArrayFromFile''' | ||
+ | |- | ||
+ | | colspan="2" | Reads a binary byte array from the currently open file. Auto increments the position in the file. Returns the number of values read. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Data variable to populate with data | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Length | ||
+ | |- | ||
+ | | colspan="2" | Number of values to read | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
Line 327: | Line 463: | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===ReadFloatArrayFromFile=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFloatArrayFromFile''' | ||
+ | |- | ||
+ | | colspan="2" | Reads a binary Float array from the currently open file. Auto increments the position in the file. Returns the number of values read. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Data variable to populate with data | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Length | ||
+ | |- | ||
+ | | colspan="2" | Number of values to read | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBFirst | ||
+ | |- | ||
+ | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===ReadINTArrayFromFile=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadINTArrayFromFile''' | ||
+ | |- | ||
+ | | colspan="2" | Reads a binary INT array from the currently open file. Auto increments the position in the file. Returns the number of values read. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Data variable to populate with data | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Length | ||
+ | |- | ||
+ | | colspan="2" | Number of values to read | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBFirst | ||
+ | |- | ||
+ | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===ReadLongArrayFromFile=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadLongArrayFromFile''' | ||
+ | |- | ||
+ | | colspan="2" | Reads a binary Long array from the currently open file. Auto increments the position in the file. Returns the number of values read. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Data variable to populate with data | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Length | ||
+ | |- | ||
+ | | colspan="2" | Number of values to read | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBFirst | ||
+ | |- | ||
+ | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
Line 472: | Line 695: | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
− | |||
− | |||
Latest revision as of 10:26, 20 October 2023
Author | Matrix Ltd. |
Version | 3.0 |
Category | File |
Contents
- 1 File (SD/SDHC Card) component
- 2 Component Source Code
- 3 Detailed description
- 4 Examples
- 5 Macro reference
- 5.1 AppendByteArrayToFile
- 5.2 AppendByteToFile
- 5.3 AppendFloatArrayToFile
- 5.4 AppendINTArrayToFile
- 5.5 AppendLongArrayToFile
- 5.6 AppendStringToFile
- 5.7 CloseFile
- 5.8 CreateFile
- 5.9 DeleteFile
- 5.10 Initialise
- 5.11 MoveToNextFileSector
- 5.12 OpenFile
- 5.13 OpenFolder
- 5.14 ReadByteArrayFromFile
- 5.15 ReadByteFromBuffer
- 5.16 ReadByteFromFile
- 5.17 ReadByteFromIndex
- 5.18 ReadByteFromScan
- 5.19 ReadFileLength
- 5.20 ReadFileSector
- 5.21 ReadFileSize
- 5.22 ReadFloatArrayFromFile
- 5.23 ReadINTArrayFromFile
- 5.24 ReadLongArrayFromFile
- 5.25 ReadStringFromFile
- 5.26 ScanCurrentFolder
- 5.27 SetFileIndex
- 5.28 SetTimeAndDate
- 5.29 UpdateFileSector
- 5.30 WriteByteToBuffer
- 5.31 WriteFileSector
- 6 Property reference
File (SD/SDHC Card) component
File component allowing access to read and write files on a SD/SDHC card. Also compatible with micro SD/SDHC cards, please note the pin layout is subtely different for these. The component automatically detects the filesystem on the card on initialise so FAT16 and FAT32 are fully supported. When used in simulation provides read/write access to files on the local windows file system.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_File_SD_FAT.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_File_SD_FAT.fcfx
Detailed description
No detailed description exists yet for this component
Examples
No additional examples
Macro reference
AppendByteArrayToFile
AppendByteToFile
AppendFloatArrayToFile
AppendINTArrayToFile
AppendLongArrayToFile
AppendStringToFile
CloseFile
CloseFile | |
Closes the current open file | |
- VOID | Return |
CreateFile
DeleteFile
DeleteFile | |
Searches for and deletes a file in the current folder location on the card. Default = Root Returns 0 for success. | |
- STRING | Filename |
8.3 format filename e.g."file.txt" | |
- BYTE | Return |
Initialise
Initialise | |
Attempts to communicate with the SD card and if successful sets up the file system. Returns: 0=OK / 236 = MBR Invalid / 237 = MBR Fail / 254=No Response / 255=No Card | |
- BYTE | Return |
MoveToNextFileSector
OpenFile
OpenFolder
ReadByteArrayFromFile
ReadByteFromBuffer
ReadByteFromFile
ReadByteFromIndex
ReadByteFromScan
ReadFileLength
ReadFileSector
ReadFileSize
ReadFileSize | |
Reads the entire size of the current file in bytes. | |
- ULONG | Return |
ReadFloatArrayFromFile
ReadINTArrayFromFile
ReadLongArrayFromFile
ReadStringFromFile
ScanCurrentFolder
SetFileIndex
SetFileIndex | |
Sets the current file index and used to switch between several open file streams. Default = 0. | |
- BYTE | File_Index |
File index ranges from 0 to (Max Concurrent Files - 1) | |
- VOID | Return |
SetTimeAndDate
SetTimeAndDate | |
Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat | |
- UINT | Time |
Sets the current Time in FAT Time format hhhhhmmmmmmsssss - S=Secs/2 | |
- UINT | Date |
Sets the current Date in FAT Date format yyyyyyymmmmddddd - Y=Years since 1980 | |
- VOID | Return |
UpdateFileSector
UpdateFileSector | |
Updates a file sector with new data set from using WriteByteToBuffer. Note this cannot alter the size of the file. | |
- VOID | Return |
WriteByteToBuffer
WriteByteToBuffer | |
Writes a single byte to the current 512 byte local sector buffer. | |
- UINT | Address |
Address Range 0 - 511 | |
- BYTE | Data |
Data Byte to write to the buffer | |
- VOID | Return |
WriteFileSector