J-M-L:
with pleasure - always happy to contribute and help out members putting energy into trying and learning.
should not be too difficult to parse.
Please do not kill me

I prepared a code that probably is a mess, but it is my first attempt on this subject.
Please refer to the post number 3 where I explain what output I would like to achieve.
I am trying to get the whole buffer, create a temporary one for parsing, parsing parts of the buffer in several variables (date_month, time_hour, etc.) and then save these variables in different cells in the CSV file.
I put "together" what I understood of your code and of the examples 5 and 2 from that topic on "serial input basics".
// Code for receiving the data from my analytical scale through RS232 with parsing
// Libraries
#include <LiquidCrystal.h>
#include <SPI.h>
#include <SD.h>
// Interface and Objects definitions
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // Creates a LCD LiquidCrystal object
const int chipSelect = 10; // Assigns the pin for the SPI-SD chip selection
const byte bufferSize = 100; // enough for your max length of a message
static byte bufferPosition = 0;
char inputBuffer[bufferSize]; // my array of the data from the scale
char tempBuffer[bufferSize]; // temporary array for use when parsing
// variables to hold the parsed data
char date_month[bufferSize] = {0};
char date_day[bufferSize] = {0};
char date_year[bufferSize] = {0};
char time_hour[bufferSize] = {0};
char time_min[bufferSize] = {0};
char time_sec[bufferSize] = {0};
float reading = 0.0;
boolean newData = false;
//============
void setup()
{
Serial.begin(9600, SERIAL_7N1); // Includes the scale parameters
pinMode(chipSelect, OUTPUT); // Ensures that the SPI-SD selection pin is an output
lcd.begin(16, 2); // Initialises the interface to the LCD screen
lcd.clear(); // // Clears the LCD screen and positions the cursor in the upper-left corner
if (!SD.begin(chipSelect)) // Checks if the SD card is working
{
lcd.println("SD failed!");
delay(2000);
return;
}
bufferPosition = 0;
inputBuffer[0] = '\0'; // initialize with empty string
}
//============
void loop() {
recvWithEndMarker();
if (newData == true) {
strcpy(tempBuffer, inputBuffer);
// this temporary copy is necessary to protect the original data
// because strtok() used in parseData() replaces the commas with \0
parseData();
saveData();
newData = false;
}
}
//============
void recvWithEndMarker() {
char endMarker = '\n';
char receivedData;
while (Serial.available() > 0 && newData == false) {
receivedData = Serial.read();
if (receivedData != endMarker) {
inputBuffer[bufferPosition] = receivedData;
bufferPosition++;
if (bufferPosition >= bufferSize) {
bufferPosition = bufferSize - 1;
}
}
else {
inputBuffer[bufferPosition] = '\0'; // terminate the string
bufferPosition = 0;
newData = true;
}
}
}
//============
void parseData() { // split the data into its parts
char * strtokIndx; // this is used by strtok() as an index
strtokIndx = strtok(tempBuffer,","); // get the first bit
strcpy(date_month, strtokIndx); // copy it to month variable
strtokIndx = strtok(tempBuffer,","); // carry on...
strcpy(date_month, strtokIndx); // carry on copy this byte in the same variable
strtokIndx = strtok(tempBuffer,",");
strcpy(date_day, strtokIndx); // copy it to month variable
strtokIndx = strtok(tempBuffer,",");
strcpy(date_day, strtokIndx); // carry on copy this byte in the same variable, etc.
strtokIndx = strtok(tempBuffer,",");
strcpy(date_year, strtokIndx);
strtokIndx = strtok(tempBuffer,",");
strcpy(date_year, strtokIndx);
strtokIndx = strtok(NULL, ","); // I do the same with the time...
strcpy(time_hour, strtokIndx);
strtokIndx = strtok(NULL, ",");
strcpy(time_hour, strtokIndx);
strtokIndx = strtok(NULL, ",");
strcpy(time_min, strtokIndx);
strtokIndx = strtok(NULL, ",");
strcpy(time_min, strtokIndx);
strtokIndx = strtok(NULL, ",");
strcpy(time_sec, strtokIndx);
strtokIndx = strtok(NULL, ",");
strcpy(time_sec, strtokIndx);
strtokIndx = strtok(NULL, ",");
reading = atof(strtokIndx); // convert this part to a float for the reading cell
}
//============
void saveData()
{
// **********************************************************************
// here the inputBuffer has a full line, you could parse it for content
// I'm just saving the full line to the SD card
// **********************************************************************
File readings = SD.open("readings.csv", FILE_WRITE); // Opens the file on the SD card
if (readings) // If the file opened OK, write to it on SD card
{
readings.print(date_month);
readings.print(',');
readings.print(date_day);
readings.print(',');
readings.print(date_year);
readings.print(',');
readings.print(time_hour);
readings.print(',');
readings.print(time_min);
readings.print(',');
readings.print(time_sec);
readings.print(',');
readings.println(reading);
readings.close(); // Closes the file to save the data on the SD card
} else { // If the file didn't open, print an error
lcd.println("FILE NOT OPEN");
delay(2000);
lcd.clear();
}
}
Hope it is not too horrible...may you please troubleshoot or tell me where to improve it please?
It is complying anyway.
I will try now to see the output but I am concerned because at the end of compile process it says low on memory (84%)...
Thanks a lot.
M.