Making progress but looking to understand what I am doing wrong with setting the variable.
Any advice welcome...
So... I have taken the advice from PaulS and nailed down the File structure.
The format of the text file is below:
1
0xDE,0xAD,0xBE,0xEF,0xFE,0xED
192,168,3,195
216,139,202,28
99
32
80
1
# ---------------------------------------------------------
# The file structure below must be followed exactly as the Arduino reads
# the first 8 lines of the file
# Line 1 = StationID ie: 1
# Line 2 = Arduino MAC Address
# Line 3 = Arduino IP Address ie: 192,168,3,195
# Line 4 = Mail Server IP Address ie: *,*,202,28
# Line 5 = Maximum Farenheit Temperature ie: 99
# Line 6 = Min Farenheit Temperature ie: 32
# Line 7 = Maximum Humidity ie: 80
# Line 8 = Min Humidity ie: 1
# Any questions regarding editing this file? - See Shane
Next I am reading the file line by line using the full code below.
But I cannot figure out how to set the var .... I continue to get
55: error: invalid array assignmentThis is the section of code where i am trying to set it...
if(line_number == 1)
{
Serial.print("Output in the if statement for line 1 is ");
Serial.println(buffer);
SensorID = buffer;
}
Full Code
// Ported to SdFat from the native Arduino SD library example by Bill Greiman
// On the Ethernet Shield, CS is pin 4. SdFat handles setting SS
const int chipSelect = 4;
/*
SD card read/write
This example shows how to read and write data to and from an SD card file
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
created Nov 2010
by David A. Mellis
updated 2 Dec 2010
by Tom Igoe
modified by Bill Greiman 11 Apr 2011
This example code is in the public domain.
*/
#include <SdFat.h>
SdFat sd;
void setup() {
Serial.begin(9600);
// Initialize SdFat or print a detailed error message and halt
// Use half speed like the native library.
// change to SPI_FULL_SPEED for more performance.
if (!sd.init(SPI_HALF_SPEED, chipSelect)) sd.initErrorHalt();
const int line_buffer_size = 50;
char buffer[line_buffer_size];
char SensorID[50];
ifstream sdin("CONFIG.TXT");
int line_number = 0;
Serial.println("... inside the Loop");
while (sdin.getline(buffer, line_buffer_size, '\n') || sdin.gcount())
{
int count = sdin.gcount();
count--; // Don’t include newline in count
++line_number;
if(line_number == 1)
{
Serial.print("Output in the if statement for line 1 is ");
Serial.println(buffer);
SensorID = buffer;
}
if(line_number == 2)
{
Serial.print("Output in the if statement for line 2 is ");
Serial.println(buffer);
}
} // end of while
Serial.println("did the sensor ID print below ?");
Serial.println(SensorID);
}
void loop() {
// nothing happens after setup
}
Thanks Shane