Loading...
Pages: 1 [2]   Go Down
Author Topic: Problems with Serial Bus  (Read 418 times)
0 Members and 1 Guest are viewing this topic.
New Jersey
Offline Offline
Edison Member
*
Karma: 24
Posts: 2351
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Tesla Member
***
Karma: 50
Posts: 6546
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
//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
    }
  }
}

Logged

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

Pages: 1 [2]   Go Up
Print
 
Jump to: