Serial read, print to lcd, sort data recieved

This is probably so simple to most people, but i'm really bad at programming and understanding the language, and the way i hope to do this is to start from the beginning, and i will learn as i make it more complicated.

i'm using a bus simulator type game (Omsi2) with real parts from a bus, and connecting them so that the real bus parts (dashboard, ticket printer, ibis (information display controller, basically an LCD with buttons) mimic the simulated items on the bus in the game, i.e. when a light on the bus dashboard comes on in game, the light on the real dashboard comes on, and so on.

There is an interface program (komsi) that starts up along with the bus simulator program, then a server program which takes the data from the simulator's interface and sends it to multiple arduino's, one for the dashboard lights, one for the gauges, one for ibis display, one for the ticket printer and finally one for the interior 'next stop' display. so a total of 6 arduinos can be connected at once.

The person who wrote the komsi interface program has moved onto other things, so the way the interface program handles the data is basically set in stone, i can't alter that, but i can alter the arduino sketches to make it work with my real bus hardware... i hope.

The dashboard part is fairly simple and working, a 'string?' of letters with either a 1 or a 0 after them separated by commas (CSV's?) are sent to the arduino on com1, and they set which pins to turn on or off, and hence the lights on the dash turn on and off as needed.

For the ticket printer i am using the included 'serial display' sketch from the examples folder in the arduino IDE,
this reads the data for the ticket printer and sends it direct to my LCD on com4, this is working ok for now.

But the bit i really need help with is the data for the ibis unit (destination display controller, and it tells you if your late, name of next stop etc),
I wish to use a 24 x 2 LCD for the ibis unit (the one in my real ibis has a slightly odd display, with larger characters on the last 3 lines that sit between the 2 lines, with a - or + symbol above those larger digits,
so maybe that is handled as a 3rd lcd line, or a custom LCD controller in the ibis unit... i'll figure that out at another date when i take it apart, for now i'm using a bog standard 24 x 2 LCD.

Now komsi unfortunately does not simply read what is showing on the in game ibis LCD and send it out, instead it extracts data from various triggers and sends it as a string, with more data than is actually on the ibis display in game.

So this data needs then moving to the right places to display in the real LCD i think. hopefully there's an attachment showing what the display should look like (or the real ibis LCD should, those last characters will be displayed on the end of line 2 of the 24 x 2 LCD.

A typical string will be like this:

1,76,2,0,19:31,- 6.0,E.-dorf Krkhaus,24,107,1,07601,

it's updated every 500 milliseconds.

On the 1st line of the real LCD, it needs to display the 7th item of that string.. in this case 'E.-dorf Krkhaus'
and there are 20 characters available on the lcd for that bit.
But, if there is nothing to display there, the string will be ' 0.0' so i need to blank the top line when that is the case?

Then on the 2nd line,
For the first 5 characters:
Display the 11th string .. in this case '07601'

Then always a space for character 6

The 7th and 8th character:
Display the 3rd string .. in this case '2'
BUT, if it's a single number, it needs a 0 putting in-front of it so it reads '02' in this case, but if it's say '11' then don't put a zero in front of it.

Then always a space for the 9th character,

For characters 10, 11 and 12:
Display the 9th string .. in this case '107'

Then always a space for the 13th character,

Characters 14, 15, 16, and 17 are for the 8th string, in this case '24'
This can be a 1 to 4 digit number, BUT it has blank spaces BEFORE the numbers when less than 4, not even sure if that can be done?

Allways a space for character 18.

Character 19:
Display the 10th string, in this case '1'.
Now, this gets displayed as 'A' or 'B' on the lcd, so if string 10 is '0' display A, if it's '1' display B... however, if nothing is to be displayed there, the string will show '-1'

In the real Ibis lcd there would then be a space, then then those large digits at the end (as shown in the attachment)
But for using a readily available 24 x 2 character LCD, i'd need to omit that space....

So carrying on the same bottom line of the LCD,
Character 20, 21, 22, 23 and 24:
Display the 6th string. in this case '- 6.0'
This is the early / late display,

and the numbers should be a maximum of '+99.0' the output string gets weird when you're more than 99.9 minutes late, and will display a # symbol for the 3rd digit, screwing the display up, so is there a way to stop displaying numbers past '+99.9' ?

i know i've typed so much, but only way i can explain it,
can anyone help me figure out what i need to do?

sorry if i got the terms wrong, csv and string and all that,

There are other bits of data in that CSV that i'd like to use elsewhere later, like the time thats on the 5th string, i'd like to take that and display it on a different lcd, but i wont attempt that untill i get this one working well.

To be honest, I am not sure the help that you want.

Here is tested example code showing how to separate out all of the pieces of the string using the strtok() function.

char array[] = "1,76,2,0,19:31,- 6.0,E.-dorf Krkhaus,24,107,1,07601";
char *strings[16]; // an array of pointers to the pieces of the above array after strtok()
char *ptr = NULL;

void setup()
{
   Serial.begin(9600);
   //Serial.print(array);
   byte index = 0;
   ptr = strtok(array, " ,");  // delimiters space and comma
   while (ptr != NULL)
   {
      strings[index] = ptr;
      index++;
      ptr = strtok(NULL, ",");
   }
   //Serial.println(index);
   // print all the parts
   Serial.println("The Pieces separated by strtok()");
   for (int n = 0; n < index; n++)
   {
      Serial.print("piece ");
      Serial.print(n);
      Serial.print(" = ");
      Serial.println(strings[n]);
   } 
  
}

void loop()
{
   // step away, nothing to see here.
}

That gives you the pieces in string form. If you want to convert to numbers the atoi() and atof() functions would be useful.

The rest is using setCursor and print functions to place the text where you want it. Don't use clear() in loop. Print spaces over old data or overwrite it.

Thankyou, i think i understand what needs doing a little better now,

there is a sketch for an arduino due provided with the komsi program, but it is too complicated for me to understand, as it combines an ibis, printer, clock and temperature display into one 40 x 2 lcd, with a matrix keypad and keyboard output functions, plus a function to replace text from a folder with a list of alternative text strings.

i wanted to strip that sketch down to just the lcd reading bits, then once i understand all that, begin thinking about adding in the other functions if i need them.

your reply helps me read that sketch a little better, but it's still double dutch in places to me, i'll post that sketch if it's any use / help.

komsi printer ibis clock temp display sketch.zip (2.7 KB)

This can be a 1 to 4 digit number, BUT it has blank spaces BEFORE the numbers when less than 4, not even sure if that can be done?

// replace the "0"s with spaces to print blanks.

char numberStr[] = "153";

void setup()
{
   Serial.begin(115200);
   int number = atoi(numberStr);
   if(number > 999)
   {
      Serial.print(number);
   }
   else if(number > 99)
   {
      Serial.print("0");
      Serial.print(number);
   }
   else if(number > 9)
   {
      Serial.print("00");
      Serial.print(number);
   }
   else
   {
       Serial.print("000");
      Serial.print(number);
   }   
}

void loop()
{   
}

I don't know if this follows all of your rules nor if the LCD interface will work but you can try this:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 24, 2);
 
char *pszString = "1,76,2,0,19:31,- 6.0,E.-dorf Krkhaus,24,107,1,07601,";
char *tok;

char
    szStr[30];   

HardwareSerial *serConsole = (HardwareSerial *)&Serial;

void setup() 
{
    float
        fVal;
    int
        val;
    uint8_t
        idx;
    
    serConsole->begin( 115200 );
    lcd.init();
    lcd.backlight();

    idx = 0;
    tok = strtok( pszString, "," );
    while( tok != NULL )
    {
        switch( idx )
        {
            case    0:
                //1
                serConsole->println( tok );
            break;

            case    1:
                //76
                serConsole->println( tok );
            break;

            case    2:
                //2
                if( strlen( tok ) == 1 )
                    sprintf( szStr, "0%s ", tok );
                else
                    sprintf( szStr, "%s ", tok );
                lcd.setCursor( 6, 1 );
                lcd.print( szStr );
                serConsole->print( "Item 2: " ); serConsole->println( szStr );
            break;

            case    3:
                //0
                serConsole->println( tok );
            break;

            case    4:
                //19:31
                serConsole->println( tok );
            break;

            case    5:                
                //- 6.0
                //need to fix space in value between '-' and first digit if it exists               
                //because atof will stop at first non-# char (' ')
                if( tok[0] == '-' && tok[1] == ' ' )
                {
                    tok[0] = ' ';
                    tok[1] = '-';
                }                                

                //limit display values to +/-99.0
                fVal = atof( tok );                                

                if( fVal >= 99.0 )
                    fVal = 99.0;
                if( fVal <= -99.0 )
                    fVal = -99.0;
                dtostrf( fVal, 5, 1, szStr );

                //restore original form if necessary (e.g. give "- 6.0")
                if( szStr[0] == ' ' && szStr[1] == '-' )
                {
                    szStr[0] = '-';
                    szStr[1] = ' ';
                }                                
                
                lcd.setCursor( 19, 1 );
                lcd.print( szStr );
                serConsole->println( szStr );
            break;

            case    6:
                //E.-dorf Krkhaus
                lcd.setCursor( 0, 0 );                
                if( strcmp( tok, "0.0" ) == 0 )                
                    sprintf( szStr, "                        " );                    
                else
                    sprintf( szStr, "%s", tok );
                lcd.print( szStr );
                serConsole->print( "Item 6: " ); serConsole->println( szStr );
            break;

            case    7:
                //24
                val = atoi( tok );
                sprintf( szStr, "%4d", val );   //give 4 chars width to ensure leading spaces
                lcd.setCursor( 13, 1 );
                lcd.print( szStr );
                lcd.setCursor( 17, 1 );
                lcd.write( ' ' );
                serConsole->print( "Item 7: " ); serConsole->println( szStr );
            break;

            case    8:
                //107
                lcd.setCursor( 9, 1 );
                lcd.print( tok );
                lcd.setCursor( 12, 1 );
                lcd.write( ' ' );
                serConsole->print( "Item 8: " ); serConsole->println( tok );
            break;

            case    9:
                //1
                lcd.setCursor( 18, 1 );
                serConsole->print( "Item 9: " );
                val = atoi( tok );
                switch( val )
                {
                    case    0:
                        lcd.write( 'A' );
                        serConsole->write( 'A' ); serConsole->write( '\n' );
                    break;
                    case    1:
                        lcd.write( 'B' );
                        serConsole->write( 'B' ); serConsole->write( '\n' );
                    break;
                    case    -1:
                        lcd.write( ' ' );
                        serConsole->write( ' ' ); serConsole->write( '\n' );
                    break;
                }
            break;

            case    10:
                //07601
                sprintf( szStr, "%s ", tok );
                lcd.setCursor( 0, 1 );
                lcd.print( szStr );                 
                serConsole->print( "Item 10: " ); serConsole->println( szStr );
    
            break;                                   
            
        }//switch
        
        idx++;        
        tok = strtok( NULL, "," );
        
    }//while

}//setup

void loop() 
{

}//loop

thankyou for helping me,

i will work through the suggestions and try to understand what each bit does,

i might have to try and break it down into little chunks, and at first get the top line data sent to the right place on the lcd, then add the data to the lower line bit by bit, that way i get to understand what each piece is doing.

the code i posted (ziped as it's so darn long) is the included suggestion script the komsi bloke includes with his program, i think he did it to get all the bits of data out, and people with enough programing skills can remove the bits they don't need, and add bits they do,

But when i try to put that code onto the arduino, it gives an error :
warning: unknown escape sequence: ';' [enabled by default]
if (inChar == ';') {

So i wonder if that's part of why the lcd doesn't get any data to if when trying that... not that i want to use a 40 x 2 lcd anyway,

but i'm making things complex again, if i could get that original code working i'd have tried to strip out all the keyboard input bits, and the alternative text bits etc, and just leave the lcd bit.
but then i wouldnt really learn anything.

But when i try to put that code onto the arduino, it gives an error :
warning: unknown escape sequence: ';' [

Where did you get that code?

The error? or the actual arduino script that's in the zip i posted,

as thats from a German guy who wrote the komsi software (that gets the data out of the bus simulator, omsi)

Who wrote the code with the ';' ?

Lars Jobst, the bloke who wrote komsi,
the code was included with the downloadable package, to be used as an example on an arduino Due,

only it keeps showing that error, and unfortunately i cant seem to get in contact with Lars to ask about it.

Change ';' to '\n', and ensure the serial monitor's line-ending is set to "newline" .

Sorry i was quiet, life got complicated for a bit again, i've just had a couple of days to play with this.

I decided i would strip out the code provided by Lars Jobst... the writer of the komsi program that sends the string data to the arduino here.

i have sort of got it working, i need to comment out a ''stringComplete = false;'' line, i wonder if this is something to do with that /; statement that needed changing to /n,

However, to get the lcd to display stuff from the simulator, I must send a string to the arduino using serial monitor... after that i can connect komsi's serial output to the arduino, and it will update the lcd,

I know i need to add a way to clear the text in certaintian areas before writing new data to it, i also sometimes get corrupted data that displays random characters on the lcd, and they don't get overwritten with data if they are where a space should be etc, but for now i want to work out how to get it to start working without me having to send a string via the serial monitor first.

/*Partially striped down code written by Lars Jobst, writer of Komsi (www.omsideluxe.de), originaly code was for a
  keypad which sent keyboard strokes to the computer, and changed text for different sized lcd's and so on,
  i am just trying to get the lcd part working on it's own first */

#include <LiquidCrystal.h>  //LCD display 
#include <String.h> //For strings

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Sets pins for lcd

String inputString = "";  //string to hold incoming data
boolean stringComplete = false; //is the string complete?

String linie_alt = ""; //for alternative bus stop names if over so many characters (for smaller lcd's)

String text1;
String text2;
String text3;
String text4;
String text5;
String text6;
String text7;
String text8;   //sets up 16 possible strings to read?
String text9;
String text10;
String text11;
String text12;
String text13;
String text14;
String text15;
String text16;


int cursor_an = 0; //integer to check cursor position?
int cursor_an_linie = 0; //linie means line in german, refering to bus line number
int speicher_stelle_linie = 7; //Memory location of the line info?  not sure


void setup() {
  Serial.begin(115200); //start serial coms at the speed the port is set on program
  Serial.flush(); //empty the arduino serial memory?
  inputString.reserve(200);  //reserve 200 bytes for data in string

  lcd.begin(40, 2); //sets up for lcd size
  pinMode(10, OUTPUT);
  digitalWrite(10, LOW); // turns on lcd backlight

  lcd.setCursor(24, 0); //sets the right part of display for temp and time
  lcd.print("|");
  lcd.setCursor(24, 1);
  lcd.print("|");
  lcd.setCursor(25, 0);
  lcd.print("Temperatur"); //for cabin temp
  lcd.setCursor(39, 0);
  lcd.print((char)223);
  lcd.setCursor(25, 1);
  lcd.print("Uhrzeit"); //for time

}

void loop() {

  if (stringComplete) {  //do something only when a complete string recieved?

    String split = inputString; //splts up the line of text from serial
    text1 = getValue(split, ',', 0); // delay yes / no
    text2 = getValue(split, ',', 1); // Line, short number
    text3 = getValue(split, ',', 2); // Route
    text4 = getValue(split, ',', 3); // Bus stop index
    text5 = getValue(split, ',', 4); // Time
    text6 = getValue(split, ',', 5); // Delay time
    text7 = getValue(split, ',', 6); // Bus sstop name
    text8 = getValue(split, ',', 7); // Zone
    text9 = getValue(split, ',', 8); // Destination
    text10 = getValue(split, ',', 9); // Direction, usually A or B
    text11 = getValue(split, ',', 10); // Line long number
    text12 = getValue(split, ',', 11); // Temp
    inputString = ""; //stored string data? whats the semicolon doing?
    // stringComplete = false; // is string complete now.... if i comment this out, it sort of works



    {
      if (linie_alt == text7) { // if bus stop name longer than so many characters, replace with shorter version
        lcd.setCursor(0, 0);
        lcd.print(linie_alt); //print the bus stop name from text file
      }
      if (linie_alt != text7) { //if bus stop name same as or shorter than so many characters
        lcd.setCursor(0, 0);
        lcd.print("                        "); //print spaces to clear that part of lcd
        lcd.setCursor(0, 0);
        lcd.print(text7);      //print the bus stop name
      }


      lcd.setCursor(35, 0);
      lcd.print(text12); //temp printed to right side of lcd

      lcd.setCursor(0, 1);
      lcd.print(text11); //print long line number

      char rou_num[6];
      text3.toCharArray(rou_num, sizeof(rou_num)); //check if route number is single or double digit
      int routennummer = atoi(rou_num);
      lcd.setCursor(6, 1);
      if (routennummer < 10) {
        String routennummer_ausgabe = "0" + text3;
        lcd.print(routennummer_ausgabe) + " ";  //if single digit, add a zero then print the number
      }
      if (routennummer > 9) {
        String routennummer_ausgabe = text3;
        lcd.print(routennummer_ausgabe) + " ";  //if double digit route number, don't add a zero, just print it as is
      }

      lcd.setCursor(9, 1);
      lcd.print(text9); //print the destination bus stop number
      lcd.setCursor(13, 1);
      lcd.print(text8); //print the zone number
      lcd.setCursor(17, 1);
      lcd.print(text10);  //print the direction (need to change this to A or B later)
      lcd.setCursor(19, 1);
      lcd.print(text6); //print the delay time
      lcd.setCursor(35, 1);
      lcd.print(text5); //print the time
      delay(100);
    }
  }
}


void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read(); //read the serial on charecter at a time?  not sure
    inputString += inChar;
    if (inChar == '\n') { //new ling charecter, if seen means string is complete... this was set to ; originaly
      stringComplete = true;
    }
  }
}

String getValue(String data, char separator, int index) //get the bits that make up the string
{
  int found = 0;
  int strIndex[] = {0, -1};
  int maxIndex = data.length() - 1; //Not sure what all this does

  for (int i = 0; i <= maxIndex && found <= index; i++) {
    if (data.charAt(i) == separator || i == maxIndex) {
      found++;
      strIndex[0] = strIndex[1] + 1;
      strIndex[1] = (i == maxIndex) ? i + 1 : i;
    }
  }

  return found > index ? data.substring(strIndex[0], strIndex[1]) : ""; //not sure
}

Blackfin:
I don't know if this follows all of your rules nor if the LCD interface will work but you can try this:

I am trying to figure out what is happening in the sketch you wrote for me,
i dont have and i2c lcd yet, so i just changed those bits to the normal lcd functions

when i upload the sketch i get an error :
warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] char *pszString = "1,76,2,0,19:31,- 6.0,E.-dorf Krkhaus,24,107,1,07601,";

Nothing seems to change when i send a string via the serial monitor, do i need to change the text in the 'pszString' bit?

The strings that come over serial from the bus sim change all the time,
so one minute it could be
0,92,2,0,21:49,0.0,Spandau Ü bahn,12,122,1,09202,
And a couple of stops later it'd be
1,92,2,0,21:54,+1.3,Rathaus,15,122,1,09202,
and so on.

That was a warning, not an error, FWIW. That sketch was just intended to show a single pass with a fixed string.

You can try this; set your serial monitor to 115200 and set the terminating char to '\n'. (Compiles, not tested...)

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 24, 2);

#define RX_BUFF_SIZE    60

uint8_t
    rxIdx;
char
    szStr[RX_BUFF_SIZE];   

HardwareSerial *serConsole = (HardwareSerial *)&Serial;

void setup()
{   
    serConsole->begin( 115200 );
    lcd.init();
    lcd.backlight();

    rxIdx = 0;

}//setup

void loop()
{
    char ch;
        
    if( serConsole->available() )
    {
        while( serConsole->available() > 0 )
        {
            ch = serConsole->read();
            
            if( ch == '\n' )
            {
                szStr[rxIdx] = '\0';
                rxIdx = 0;
                
                ParseString( szStr );
                
            }//if
            else
            {
                szStr[rxIdx] = ch;
                if( rxIdx < (RX_BUFF_SIZE - 1) )
                    rxIdx++;
            }//else
            
        }//while
        
    }//if

}//loop

void ParseString( char *pszString )
{
    char *tok;    
    float fVal;
    int val;
    uint8_t idx;
        
    idx = 0;
    tok = strtok( pszString, "," );
    
    while( tok != NULL )
    {
        switch( idx )
        {
            case    0:
                //1
                serConsole->println( tok );
            break;

            case    1:
                //76
                serConsole->println( tok );
            break;

            case    2:
                //2
                if( strlen( tok ) == 1 )
                    sprintf( szStr, "0%s ", tok );
                else
                    sprintf( szStr, "%s ", tok );
                lcd.setCursor( 6, 1 );
                lcd.print( szStr );
                serConsole->print( "Item 2: " ); serConsole->println( szStr );
            break;

            case    3:
                //0
                serConsole->println( tok );
            break;

            case    4:
                //19:31
                serConsole->println( tok );
            break;

            case    5:               
                //- 6.0
                //need to fix space in value between '-' and first digit if it exists               
                //because atof will stop at first non-# char (' ')
                if( tok[0] == '-' && tok[1] == ' ' )
                {
                    tok[0] = ' ';
                    tok[1] = '-';
                }                               

                //limit display values to +/-99.0
                fVal = atof( tok );                               

                if( fVal >= 99.0 )
                    fVal = 99.0;
                if( fVal <= -99.0 )
                    fVal = -99.0;
                dtostrf( fVal, 5, 1, szStr );

                //restore original form if necessary (e.g. give "- 6.0")
                if( szStr[0] == ' ' && szStr[1] == '-' )
                {
                    szStr[0] = '-';
                    szStr[1] = ' ';
                }                               
               
                lcd.setCursor( 19, 1 );
                lcd.print( szStr );
                serConsole->println( szStr );
            break;

            case    6:
                //E.-dorf Krkhaus
                lcd.setCursor( 0, 0 );               
                if( strcmp( tok, "0.0" ) == 0 )               
                    sprintf( szStr, "                        " );                   
                else
                    sprintf( szStr, "%s", tok );
                lcd.print( szStr );
                serConsole->print( "Item 6: " ); serConsole->println( szStr );
            break;

            case    7:
                //24
                val = atoi( tok );
                sprintf( szStr, "%4d", val );   //give 4 chars width to ensure leading spaces
                lcd.setCursor( 13, 1 );
                lcd.print( szStr );
                lcd.setCursor( 17, 1 );
                lcd.write( ' ' );
                serConsole->print( "Item 7: " ); serConsole->println( szStr );
            break;

            case    8:
                //107
                lcd.setCursor( 9, 1 );
                lcd.print( tok );
                lcd.setCursor( 12, 1 );
                lcd.write( ' ' );
                serConsole->print( "Item 8: " ); serConsole->println( tok );
            break;

            case    9:
                //1
                lcd.setCursor( 18, 1 );
                serConsole->print( "Item 9: " );
                val = atoi( tok );
                switch( val )
                {
                    case    0:
                        lcd.write( 'A' );
                        serConsole->write( 'A' ); serConsole->write( '\n' );
                    break;
                    case    1:
                        lcd.write( 'B' );
                        serConsole->write( 'B' ); serConsole->write( '\n' );
                    break;
                    case    -1:
                        lcd.write( ' ' );
                        serConsole->write( ' ' ); serConsole->write( '\n' );
                    break;
                }
            break;

            case    10:
                //07601
                sprintf( szStr, "%s ", tok );
                lcd.setCursor( 0, 1 );
                lcd.print( szStr );                 
                serConsole->print( "Item 10: " ); serConsole->println( szStr );
   
            break;                                   
           
        }//switch
       
        idx++;       
        tok = strtok( NULL, "," );
       
    }//while
    
}//ParseString

Ahh, sorry about that, yeah it's just a warning,

That sketch works with the serial monitor :slight_smile:

but not with the simulator :frowning: i have a feeling the simulator output may not be sending the new line character, is that possible?

Or could the signal that a string is complete be ' ; ' ? as when i the lcd serial sketch example to display whatever is received over the serial monitor from the simulator,
if i set it to display the ticket printer's output, it shows something like
"22:32 E.DORF KRK,HAUS ;" on the lcd.

i remember on the original sketch Lars supplied with komsi, he had
" if (inChar == ';') {
stringComplete = true; "
which gave the error that it's an unknown escape sequence. but could komsi be sending a ; as the terminating character

I think i'm getting somewhere.

I changed
"if( ch == '\n' )" to
"if( ch == ';' )

And it's working with the printer output (which can also display the ibis text on it if selected)... as that definitely sends the ' ; ' as the newline character,
with the ibis output it dosen't, bbut i think i just need to figure out what the newline character for the ibis string is to crack this.

One can use any character as a message terminating char if one is sure that the chosen character is not one that will show up in the meat of the message itself.

If you suspect that ';' marks the end of a "packet", then try just using:

if( ch == ';' )

(no slash) and see if that works.

I might have an issue that may be unrelated.. but also might be stopping me seeing the newline character when using the 'SerialDisplay' sketch from examples in the IDE, to put whatever is sent over the serial onto the lcd.

i'm using a 40 x 2 character LCD, and no matter what i send it using the SerialDisplay sketch, it wont display the last 17 characters on the 2nd line.

i've got 2 of the 40x2 displays, and both lcd's do the exact same thing.

i'm using an arduino uno, i have 2 of these, and tried them both, exactly the same issue, same if i use a leonardo.

I thought it could be the 'delay(100);' bit in the SerialDisplay sketch, thinking 100 milliseconds isn't long enough for an 80 character message to come through, but changing that value right upto 1000, makes no difference, last 17 characters are always missing.

The LCD's can display all 80 characters, as the komsi lcd sketch will use all the display, putting the time and temperature on the right hand 1/4 of the display,

Turns out the LCD not showing all characters issue is a serial buffer overrun, and it'll be fixed with the next update of the hd44780 library.

I'm having an issue with the sketch tho, it locks the arduino up after about 10 minutes of use,
i think it may be the arduino's memory getting full?

i do change the sketch to use the paralel lcd connection method rathe than I2C, as i've only just got hold of an I2C lcd backpack (and trying that with the sketch as is, i get an error saying the serial port is already in use)

I have discovered something about the bus simulator tho, there is a strainvarlist simply called 'IBIS' and when that's called it sends out the contents of the ibis screen in the virtual bus, 2 lines separated by the @ charecter, with all spaces and A or B stuff intact,

Unfortunately to use that much simpler method of getting the ibis data out would need the komsi program modifying, and the bloke who wrote it has moved onto other things and is very busy.

I might have to learn how to write a windows program that calls for the data from the bus sim, and simple passes on the IBIS screen data down the serial port to the lcd on the arduino,

gazz292:
Turns out the LCD not showing all characters issue is a serial buffer overrun, and it'll be fixed with the next update of the hd44780 library.

I'm having an issue with the sketch tho, it locks the arduino up after about 10 minutes of use,
i think it may be the arduino's memory getting full?

Are you running the sketch I provided in post #13? If not that exact one, can you post the current sketch in code tags?