Hi all..
I am sure something like this came up before. I have even found a couple of related topics on the forum but couldn't make use of the suggestions given for my project.
I am trying to use the SD memory card as storage for variables (specific sensor static data, not measurements) which will be loaded at runtime for processing. The processor would then proceed to poll the sensors for measurements.
See below:
# SENSOR DATA
SENSORID=1
BUSID=100
LOCATION=LAB
CHANNELS=2
CH1=CHA
CH2=CHB
LOG=N
END
SENSORID=2
BUSID=90
LOCATION=A/V CABINET
CHANNELS=1
CH1=A/V CABINET
LOG=N
END
Each sensor is given a serial number (SENSORID)
Location is a char description, BUSID is a byte variable to store the sensor’s unique address on the RS485 bus etc
The ‘END’ signifies the end of the data for each sensor in order to assist the processing.
Ideally I need to develop a function that would fetch data for each sensor based on its ID and the specific variable needed. An issue is the fact that some variables are char types, some byte types and others Boolean (eg LOG)
I was thinking of something like :
int GetSDData (char *SDdata, byte Len, byte SENSORID) {
…
..
}
I thought that SDdata would store the variable name to fetch (eg BUSID), Len being the length of the variable name and SENSORID the serial number of the set of the sensor needed.
The function would then return either a number (int) in case of a numeric variable or, if its char variable, the data would be placed in the same array SDdata.
Any thoughts or suggestions on the above or alternative approach would be greatly appreciated.
Also any sample code examples how to efficiently process the text file to extract the needed variables would also be great help.
Thanks !