Skip to content

Commit b49d233

Browse files
committed
Closes #722
1 parent b6b979e commit b49d233

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.8.1 2020/10
2+
- Fixed bug in Sony decode introduced in 2.8.0.
3+
14
## 2.8.0 2020/10
25
- Changed License to MIT see https://github.com/z3t0/Arduino-IRremote/issues/397.
36
- Added ATtiny timer 1 support.

examples/IRtest/IRtest.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public:
9999

100100
IRsendDummy irsenddummy;
101101

102-
void verify(unsigned long val, int bits, int type) {
102+
void verify(unsigned long val, unsigned int bits, unsigned int type) {
103103
irsenddummy.useDummyBuf();
104104
IrReceiver.decode();
105105
Serial.print("Testing ");

examples/IRtest2/IRtest2.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void dump() {
118118
// The motivation behind this method is that the sender and the receiver
119119
// can do the same test calls, and the mode variable indicates whether
120120
// to send or receive.
121-
void test(const char *label, int type, uint32_t value, int bits) {
121+
void test(const char *label, int type, uint32_t value, unsigned int bits) {
122122
if (mode == SENDER) {
123123
Serial.println(label);
124124
if (type == NEC) {

src/IRremote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class IRsend {
535535
*/
536536
void sendPronto(const char* prontoHexString, unsigned int times = 1U);
537537

538-
void sendPronto(const uint16_t* data, unsigned int length, unsigned int times = 1U);
538+
void sendPronto(const uint16_t *data, unsigned int length, unsigned int times = 1U);
539539

540540
#if HAS_FLASH_READ || defined(DOXYGEN)
541541
void sendPronto_PF(uint_farptr_t str, unsigned int times = 1U);

src/ir_Sony.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void IRsend::sendSony(unsigned long data, int nbits) {
2727

2828
// Header
2929
mark(SONY_HEADER_MARK);
30-
space (SONY_SPACE);
30+
space(SONY_SPACE);
3131

3232
sendPulseDistanceWidthData(SONY_ONE_MARK, SONY_SPACE, SONY_ZERO_MARK, SONY_SPACE, data, nbits);
3333
/*
@@ -59,7 +59,7 @@ bool IRrecv::decodeSony() {
5959

6060
// Some Sony's deliver repeats fast after first
6161
// unfortunately can't spot difference from of repeat from two fast clicks
62-
if (results.rawbuf[offset] < (SONY_DOUBLE_SPACE_USECS / MICROS_PER_TICK)) {
62+
if (results.rawbuf[0] < (SONY_DOUBLE_SPACE_USECS / MICROS_PER_TICK)) {
6363
DBG_PRINTLN("IR Gap found");
6464
results.bits = 0;
6565
results.value = REPEAT;
@@ -75,14 +75,16 @@ bool IRrecv::decodeSony() {
7575
}
7676
offset++;
7777

78-
// Check header "space"
79-
if (!MATCH_SPACE(results.rawbuf[offset], SONY_SPACE)) {
80-
return false;
81-
}
82-
offset++;
83-
8478
// MSB first - Not compatible to standard, which says LSB first :-(
85-
while (offset < results.rawlen) {
79+
while (offset + 1 < results.rawlen) {
80+
81+
// First check for the constant space length, we do not have a space at the end of raw data
82+
// we are lucky, since the start space is equal the data space.
83+
if (!MATCH_SPACE(results.rawbuf[offset], SONY_SPACE)) {
84+
return false;
85+
}
86+
offset++;
87+
8688
// bit value is determined by length of the mark
8789
if (MATCH_MARK(results.rawbuf[offset], SONY_ONE_MARK)) {
8890
data = (data << 1) | 1;
@@ -93,11 +95,6 @@ bool IRrecv::decodeSony() {
9395
}
9496
offset++;
9597

96-
// check for the constant space length
97-
if (!MATCH_SPACE(results.rawbuf[offset], SONY_SPACE)) {
98-
return false;
99-
}
100-
offset++;
10198
}
10299

103100
results.bits = SONY_BITS;

src/private/IRremoteInt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ struct irparams_struct {
4949
uint8_t blinkpin;
5050
uint8_t blinkflag; ///< true -> enable blinking of pin on IR processing
5151
uint16_t rawlen; ///< counter of entries in rawbuf
52-
uint16_t timer; ///< State timer, counts 50uS ticks.
53-
uint16_t rawbuf[RAW_BUFFER_LENGTH]; ///< raw data, first entry is the length of the gap between previous and current command
52+
uint16_t timer; ///< State timer, counts 50uS ticks.
53+
uint16_t rawbuf[RAW_BUFFER_LENGTH]; ///< raw data / tick counts per mark/space, first entry is the length of the gap between previous and current command
5454
uint8_t overflow; ///< Raw buffer overflow occurred
5555
};
5656

0 commit comments

Comments
 (0)