Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SoftwareSerial returns impossible values #2858

Closed
Assignees
@Goz3rr

Description

I have the following code (Arduino 1.6.1):

if(_bt.available() > 0) {
 int data = _bt.peek();
 bool found = true;
 if(data == 'a') {
 // do something
 } else if(data == 'b') {
 // do something else
 } else {
 found = false;
 }
 if(found) _bt.read();
}

(It's set up like this because it's a library, and if unknown messages are found they should be passed to the code handling other commands, if that makes sense)

At random points the Arduino would stop reacting to any received messages, and after adding some debug code I found out that while _bt.available() would keep incrementing with each message received, _bt.peek() returns some a nonsense negative value but _bt.read() will return something completely different, these are some i've encountered so far:

-1 == 255
-76 == 180
-1 == 255
-36 == 220
-1 == 255
-5 == 251
-72 == 184
-36 == 220
-18 == 238

I'm not sure where these values originate from because I'm never sending them to the HC-05 attached to this SerialPort. Worth noting is that once this happens even if i disconnect the HC-05 the SoftwareSerial will keep returning the last values, so I assume some buffering is done internally.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /