Go Down

Topic: Split Serial Port Character Data to EEPROM (Read 2 times) previous topic - next topic

PaulS

Quote
please suggest what more can be done to optimize this.

Since you asked...

Code: [Select]
/*
Example to receive data from serial port in format <a,123456> and parse it to store in three eeprom location 10,11,12 by receiving as string then converting to integer.
Maximum number size to be received from serial port is six digits. for longer number add mode Cyclesint , epri and eprs.
 
*/

There is no extra charge for using the enter key. So, use it!

Code: [Select]
String cyclesStr; // Value part of the recieved string
String command;  // Command part of the recieved string

No! There is no reason to use this resource wasting class.

Code: [Select]
    text = inData;
    String  message = text; // holds text not yet split

No! No! No! The strtok() function is far better. There is no reason to copy the character data into a String object and then copy it into another String object.

Code: [Select]
int Cyclesint; //First two characters of value integer to be stored in EEPROM location 10
int Cyclesint1;//First two characters of value integer to be stored in EEPROM location 11
int Cyclesint2;//First two characters of value integer to be stored in EEPROM location 12
long int epri1;//EEPROM location 10 Value
long int epri2;//EEPROM location 11 Value
long int epri3;//EEPROM location 12 Value

If the data fits in an int when being stored, it's fit in an int when being read back.

Go Up