-
-
Notifications
You must be signed in to change notification settings - Fork 7k
SoftwareSerial returns impossible values #2858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What board are you using? Could you see if you could reproduce this problem using a minimal sketch, preferably without any external hardware attached? Are you sure you're using the official SoftwareSerial library, and not some other library inside your sketchbook? Perhaps you should post the full verbose compilation output, which should show this. |
These are school supplied Arduino Uno's and HC05 Bluetooth modules, I'm not sure if they're genuine Arduinos but I have managed to reproduce it with multiple Arduinos and HC05's and a minimal sketch, I haven't been able to recreate it without external hardware because it doesn't seem to happen while no data is being sent, however it does seem to happen more often when messages are sent more often, baud rate is 9600 so that shouldn't be too high. I'm currently on a bus but I'll post compilation output in a moment. |
Cool, thanks! If you can reproduce it by using output from another Arduino (connect its TX pin to the softwareserial RX pin), that would also help a lot. I don't think genuine or clone Arduino would make much of a difference here, btw. |
So far I haven't been able to reproduce this between two Arduinos, it only seems to happen with this specific bluetooth module |
You're looking at the same thing; just the difference between signed and unsigned numbers. If you look carefully at all the numbers you supplied, you'll notice that the difference between the two numbers is always 256. |
There is a subtle difference between I'll prepare a pull request to correct this. |
Cool to see someone bothered to look at old issues, and in retrospect that makes a lot of sense |
I've submitted #4669 to resolve this. |
I have the following code (Arduino 1.6.1):
(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.
The text was updated successfully, but these errors were encountered: