Multiple data over Serial port

We had a hardware failure and one of the controllers went kaboom. This controller receive serial data from a piece of software installed in one of the PC's. A co-worker years ago made a controller based on PIC and studied all the data coming from the software. Basically in a PC you type 54 different variables, hit send and the software spits out 225 variables in a format like this:

; ##### ; ### ; ## ; #### ; ##### ; ##### ; #### ; ..... ; # ; ##### ; FIN
are 224 random numbers based on the inputs on the PC. This are only numbers (0 to 9) and up to 5 numbers per variable (from 0 to 9999)

FIN is to indicate the end of the data transmission

I'm doing the controller in arduino and I do not know how to receive those 224 numbers (or 225 including the FIN) and assigned them to 224 variables in the arduino. I have the logic diagram my co-worker created, it is just a bunch of gates if's.. then's type of things.

Can somebody please help me with the communication part, once I have the variables in arduino I can do the rest...

Thanks a lot,

Cataina

From your description I think the output from the PC is in the form of text (ascii characters) rather than binary data.

If the Arduino is connect to the PC and the PC sends the text to the Arduino’s serial port, you can read that very easily. Your sketch just needs to call Serial.available() to find whether there is a character waiting to be read, and Serial.read() to read the next character.

You will need to keep receiving characters and put them in to a character array until you receive the “FIN” telling you the input is complete. Then split the character array into strings containing the separate numbers, and call atol() or similar to convert each string into a number. What you do with the number after that is up to you.

The below code posted by others might be a way to capture the string of data. You would need to adjust the capture code to your needs (replace the carrage return/line feed delimiters with the FIN characters, modify max length, etc.), then add the parsing of the captured string into the data you desire.

// how much serial data we expect before a newline
const unsigned int MAX_INPUT = 50;

void setup ()
{
  Serial.begin(9600);
} // end of setup

// here to process incoming serial data after a terminator received
void process_data (char * data) //function
  {
  // for now just display it
  Serial.println (data);
  }  // end of process_data
  

void loop()
{
static char input_line [MAX_INPUT];
static unsigned int input_pos = 0;

  if (Serial.available () > 0) 
    {
    char inByte = Serial.read ();

    switch (inByte)
      {

      case '\n':   // end of text
        input_line [input_pos] = 0;  // terminating null byte
        
        // terminator reached! process input_line here ...
        process_data (input_line); //return process_data to (input_line)
        
        // reset buffer for next time
        input_pos = 0;  
        break;
  
      case '\r':   // discard carriage return
        break;
  
      default:
        // keep adding if not full ... allow for terminating null byte
        if (input_pos < (MAX_INPUT - 1))
          input_line [input_pos++] = inByte;
        break;

      }  // end of switch

  }  // end of incoming data

  // do other stuff here like testing digital input (button presses) ...

}  // end of loop

Regular expressions might grab the numbers:

http://gammon.com.au/forum/?id=11063