Go Down

Topic: Problems with Serial Bus (Read 962 times) previous topic - next topic

wildbill

You're going to need to service serial quite frequently to avoid buffer overflow. Every 200ms is not going to cut it - theoretically, you could get ~190 characters delivered in that time. Post (attach) your code if you need assistance in refactoring it to achieve this.

zoomkat

I put a , on the end of your string and the below code returned the entire string to the serial monitor.

Code: [Select]

//zoomkat 3-5-12 simple delimited ',' string parce
//from serial port input (via serial monitor)
//and print result out serial port
// CR/LF could also be a delimiter

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}

void loop() {

  //expect a string like wer,qwe rty,123 456,hyre kjhg,
  //or like hello world,who are you?,bye!,
 
  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      //do stuff
      Serial.println(readString); //prints string to serial port out
      readString=""; //clears variable for new input     
     } 
    else {     
      readString += c; //makes the string readString
    }
  }
}

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

Go Up