Pages: [1]   Go Down
Author Topic: SoftwareSerial Signal FIFO  (Read 867 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am reading information from an Maxbotix LV-WR1 through a SoftwareSerial connection.

Unfortunately, the result is delayed. I guess that I only read the next Data transmitted but not the last.

Here is the part of my software where I am reading the Data.
Code:
// UltrasonicSerial
float readUltraSerial() {
  char new;
  int inchInt = 0, counter=0;
  char * inch;
 
  if (UltraSerial.available()) {
    for(;;) {

      neu = UltraSerial.read();
     
      if (neu == 'R' || isNumber(neu)) {
        if (neu == 'R') {
        //  Serial.println();
          inch = "";
          counter = 0;
        } else {
          inch[counter] = new;
          counter++;
        }
        Serial.print(counter);
        Serial.print(" - ");
        Serial.println(new);
       
       
        if (counter == 3) {
          inchInt = atoi(inch);
          Serial.print(inchInt);
          Serial.print(" - ");
          Serial.println(inchInt*2.54);
          return (inchInt*2.54);
        }
      }
    }
  } else {
    return 0;
  }
}

I am using an Arduino Mega 2560 and I have free HardwareSerial ports but I can't read the RS232 Data from the Sensor. If you could help me with that, it would be even better.


Thank you
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


the problem is in these two lines

Code:
if (UltraSerial.available()) {
    for(;;) {

suppose you have one byte available in UltraSerial, it enters an endless loop that (tries to) read a char per iteration (assuming neu and new are the same;)

add a few lines to check it.
Code:
  if (UltraSerial.available()) {
    for(;;) {

      neu = UltraSerial.read();
      Serial.print("<");
      Serial.print(neu, DEC);
      Serial.println(">");
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you that helped me :-)
Logged

Pages: [1]   Go Up
Jump to: