Converting a Datastream into an Array

Hi guys, I´m new here and i might not do everything right so sorry for that in advance.
my Project right now is using a Levelshifter and Arduino to read a Consistent Datastream of my Cars ECU. it´s Serial with 187500 Baud and only in one direction. i configured a Softwareserial for the ECU side and used the Hardwareserial to see what is happening. right now i can read the Stream as intendet and can see it in the Serial Monitor of the Arduino IDE. my Problem is Arranging it in an Array so i can Order every Byte of data and convert it to readable Data to output it on a Display.
the Stream is built up like this:
its a continuous stream with a start and end byte and 31 Bytes inbetween so together 33 Bytes it starts with 0xBB/187 dec and ends with 0xAA/170 dec. my Problem is that Arranging it in an character Array does not work. i think its converting it to an obscure Ascii Code and Arduino outputs nothing a vertical mirrored Questioning Mark.
i hope someone might be able to help me.
thanks in advance.
I´ll include the code in a comment when i find out how.

Setup is pretty simple,
Arduino UNO, Automotive KKL Adapter for Levelshifting from 12V to 5V And Bosch ECU

const byte numChars = 35;
char  receivedChars[numChars];
int endMarker = 170;
int gelesen = 0;
static byte ndx = 0;
int rc; 
boolean newData = false;
byte startMarker = 187;

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3); // RX, TX

void setup() {
Serial.begin(230400);
while(!Serial) {;}

mySerial.begin(187500);


}

void loop() {
 recwithEndmarker();
 showNewData();
 
 

 

}
void recwithEndmarker(){
  
  
  
  while(mySerial.available() && newData == false){
    rc = mySerial.read();
    if (rc != endMarker){
      receivedChars[ndx] = rc;
      ndx++;
      if(ndx >= numChars){
        ndx = numChars - 1;
        
      }
    }
    else {
      ndx = 0;
      newData = true;
    }
  }
  
}

void showNewData() {
  if (newData == true) {
    Serial.print(receivedChars);
    newData = false;
  }
}

If change i change the code to output "rc" over the normal serial when softwareserial has a byte available it outputs it how it should but i would like to order it in an easy array

Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation of your ask).


are you receiving binary data? the cString won't be really nice to print when yo do
Serial.print(receivedChars);
--> print the chars 1 by 1 (but you should remember the length as 0 might be a valid input)

Hi J-M-L thanks for the Advice i hope it`s better now.
I think you just found my solution. i just converted the array to integers and now i can output all by one and organized. you just saved my day, thanks alot :smiley:

Thanks it’s good and tidy now :slight_smile:

Glad you solved it (an array of byte should be enough)

Software Serial is now capable of handling 187500 BAUD?