Rev 2237 | Rev 2241 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2237 | Rev 2239 | ||
|---|---|---|---|
| Line 60... | Line 60... | ||
| 60 | #endif |
60 | #endif |
| 61 | #if (IR_PROTOCOLS_USE_VIKING_STEAK) |
61 | #if (IR_PROTOCOLS_USE_VIKING_STEAK) |
| 62 | res = parseVikingSteak(buf, len, index, proto); |
62 | res = parseVikingSteak(buf, len, index, proto); |
| 63 | if (res!=IR_NOT_CORRECT_DATA) return res; |
63 | if (res!=IR_NOT_CORRECT_DATA) return res; |
| 64 | #endif |
64 | #endif |
| - | 65 | #if (IR_PROTOCOLS_USE_RUBICSON) |
|
| - | 66 | res = parseRubicson(buf, len, index, proto); |
|
| - | 67 | if (res!=IR_NOT_CORRECT_DATA) return res; |
|
| - | 68 | #endif |
|
| - | 69 | ||
| - | 70 | ||
| 65 | /* No protocol matched. */ |
71 | /* No protocol matched. */ |
| 66 | proto->protocol = IR_PROTO_UNKNOWN; |
72 | proto->protocol = IR_PROTO_UNKNOWN; |
| 67 | return IR_NOT_CORRECT_DATA; |
73 | return IR_NOT_CORRECT_DATA; |
| 68 | } |
74 | } |
| 69 | 75 | ||
| Line 123... | Line 129... | ||
| 123 | /* parse buf[], max is len */ |
129 | /* parse buf[], max is len */ |
| 124 | 130 | ||
| 125 | /* check if we have correct amount of data. |
131 | /* check if we have correct amount of data. |
| 126 | supporting two versions of SIRC: |
132 | supporting two versions of SIRC: |
| 127 | 12 bit = 25, 15 bit = 31 |
133 | 12 bit = 25, 15 bit = 31 |
| 128 | there is also a 20 bit protocol, but we don't support it |
134 | there is also a 20 bit protocol, but we don't support it |
| 129 | */ |
135 | */ |
| 130 | if (len != 25 && len != 31) { |
136 | if (len != 25 && len != 31) { |
| 131 | return IR_NOT_CORRECT_DATA; |
137 | return IR_NOT_CORRECT_DATA; |
| 132 | } |
138 | } |
| 133 | 139 | ||
| Line 165... | Line 171... | ||
| 165 | #endif |
171 | #endif |
| 166 | 172 | ||
| 167 | /** |
173 | /** |
| 168 | * Expand data from SIRC protocol |
174 | * Expand data from SIRC protocol |
| 169 | * http://www.sbprojects.com/knowledge/ir/sirc.htm |
175 | * http://www.sbprojects.com/knowledge/ir/sirc.htm |
| 170 | * |
176 | * |
| 171 | * @param buf |
177 | * @param buf |
| 172 | * Pointer to buffer to store the expanded data |
178 | * Pointer to buffer to store the expanded data |
| 173 | * @param len |
179 | * @param len |
| 174 | * Pointer to length of the data |
180 | * Pointer to length of the data |
| 175 | * @param proto |
181 | * @param proto |
| 176 | * Pointer to protocol information |
182 | * Pointer to protocol information |
| Line 229... | Line 235... | ||
| 229 | //halfbitscnt&1==1 in the middle of bits |
235 | //halfbitscnt&1==1 in the middle of bits |
| 230 | //i&1==0 positive flank |
236 | //i&1==0 positive flank |
| 231 | 237 | ||
| 232 | if ((halfbitscnt&1)==1 && (i&1)==0) { /* in the middle of bit AND a positve flank */ |
238 | if ((halfbitscnt&1)==1 && (i&1)==0) { /* in the middle of bit AND a positve flank */ |
| 233 | rawbits |= (1<<(13-(halfbitscnt>>1))); |
239 | rawbits |= (1<<(13-(halfbitscnt>>1))); |
| 234 | } |
240 | } |
| 235 | 241 | ||
| 236 | if (buf[i] > IR_RC5_HALF_BIT - IR_RC5_HALF_BIT/IR_RC5_TOL_DIV && buf[i] < IR_RC5_HALF_BIT + IR_RC5_HALF_BIT/IR_RC5_TOL_DIV) { |
242 | if (buf[i] > IR_RC5_HALF_BIT - IR_RC5_HALF_BIT/IR_RC5_TOL_DIV && buf[i] < IR_RC5_HALF_BIT + IR_RC5_HALF_BIT/IR_RC5_TOL_DIV) { |
| 237 | halfbitscnt += 1; |
243 | halfbitscnt += 1; |
| 238 | } else if (buf[i] > IR_RC5_BIT - IR_RC5_BIT/IR_RC5_TOL_DIV && buf[i] < IR_RC5_BIT + IR_RC5_BIT/IR_RC5_TOL_DIV) { |
244 | } else if (buf[i] > IR_RC5_BIT - IR_RC5_BIT/IR_RC5_TOL_DIV && buf[i] < IR_RC5_BIT + IR_RC5_BIT/IR_RC5_TOL_DIV) { |
| 239 | halfbitscnt += 2; |
245 | halfbitscnt += 2; |
| 240 | } else { |
246 | } else { |
| 241 | return IR_NOT_CORRECT_DATA; |
247 | return IR_NOT_CORRECT_DATA; |
| 242 | } |
248 | } |
| 243 | 249 | ||
| 244 | } |
250 | } |
| 245 | 251 | ||
| 246 | proto->protocol=IR_PROTO_RC5; |
252 | proto->protocol=IR_PROTO_RC5; |
| 247 | proto->timeout=IR_RC5_TIMEOUT; |
253 | proto->timeout=IR_RC5_TIMEOUT; |
| 248 | //support RC5-extended keeping second startbit |
254 | //support RC5-extended keeping second startbit |
| 249 | //remove togglebit |
255 | //remove togglebit |
| 250 | proto->data = rawbits&0x37ff; //This seems to be wrong? Does not invert second start bit and keeps first start bit |
256 | proto->data = rawbits&0x37ff; //This seems to be wrong? Does not invert second start bit and keeps first start bit |
| 251 | //proto->data = (rawbits&0x07ff) | ((~rawbits)&0x0100); |
257 | //proto->data = (rawbits&0x07ff) | ((~rawbits)&0x0100); |
| 252 | 258 | ||
| 253 | 259 | ||
| 254 | return IR_OK; |
260 | return IR_OK; |
| 255 | } |
261 | } |
| 256 | #endif |
262 | #endif |
| 257 | 263 | ||
| 258 | /** |
264 | /** |
| 259 | * Used by the expandRC5 to ensure that we toggle the signal with each button press. |
265 | * Used by the expandRC5 to ensure that we toggle the signal with each button press. |
| 260 | */ |
266 | */ |
| 261 | int8_t rc5_toggle=0; |
267 | int8_t rc5_toggle=0; |
| 262 | 268 | ||
| Line 313... | Line 319... | ||
| 313 | //We know that RC5 messages are 14 bits long |
319 | //We know that RC5 messages are 14 bits long |
| 314 | for(uint8_t pos=11;pos>0;pos--) |
320 | for(uint8_t pos=11;pos>0;pos--) |
| 315 | { |
321 | { |
| 316 | // Check the current bit |
322 | // Check the current bit |
| 317 | if(previousBit == ((rawMessage>>(pos-1)) & 1)) |
323 | if(previousBit == ((rawMessage>>(pos-1)) & 1)) |
| 318 | { |
324 | { |
| 319 | buf[*len]=IR_RC5_HALF_BIT; |
325 | buf[*len]=IR_RC5_HALF_BIT; |
| 320 | buf[*len+1]=IR_RC5_HALF_BIT; |
326 | buf[*len+1]=IR_RC5_HALF_BIT; |
| 321 | *len=*len+2; |
327 | *len=*len+2; |
| 322 | } |
328 | } |
| 323 | else |
329 | else |
| 324 | { |
330 | { |
| Line 399... | Line 405... | ||
| 399 | #endif |
405 | #endif |
| 400 | 406 | ||
| 401 | /** |
407 | /** |
| 402 | * Expand data from Sharp protocol |
408 | * Expand data from Sharp protocol |
| 403 | * http://www.sbprojects.com/knowledge/ir/sharp.htm |
409 | * http://www.sbprojects.com/knowledge/ir/sharp.htm |
| 404 | * |
410 | * |
| 405 | * @param buf |
411 | * @param buf |
| 406 | * Pointer to buffer to store the expanded data |
412 | * Pointer to buffer to store the expanded data |
| 407 | * @param len |
413 | * @param len |
| 408 | * Pointer to length of the data |
414 | * Pointer to length of the data |
| 409 | * @param proto |
415 | * @param proto |
| Line 414... | Line 420... | ||
| 414 | int8_t expandSharp(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
420 | int8_t expandSharp(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
| 415 | //TODO: Implement this function. |
421 | //TODO: Implement this function. |
| 416 | return IR_NOT_CORRECT_DATA; |
422 | return IR_NOT_CORRECT_DATA; |
| 417 | } |
423 | } |
| 418 | 424 | ||
| 419 | 425 | ||
| 420 | #if (IR_PROTOCOLS_USE_NEC) |
426 | #if (IR_PROTOCOLS_USE_NEC) |
| 421 | /** |
427 | /** |
| 422 | * Test data on NEC protocol |
428 | * Test data on NEC protocol |
| 423 | * http://www.sbprojects.com/knowledge/ir/nec.htm |
429 | * http://www.sbprojects.com/knowledge/ir/nec.htm |
| 424 | * |
430 | * |
| 425 | * @param buf |
431 | * @param buf |
| 426 | * Pointer to buffer to where to data to parse is stored |
432 | * Pointer to buffer to where to data to parse is stored |
| 427 | * @param len |
433 | * @param len |
| 428 | * Length of the data |
434 | * Length of the data |
| 429 | * @param proto |
435 | * @param proto |
| Line 439... | Line 445... | ||
| 439 | return IR_NOT_CORRECT_DATA; |
445 | return IR_NOT_CORRECT_DATA; |
| 440 | } |
446 | } |
| 441 | 447 | ||
| 442 | /* check startbit */ |
448 | /* check startbit */ |
| 443 | if (buf[0] > IR_NEC_ST_BIT + IR_NEC_ST_BIT/IR_NEC_TOL_DIV || buf[0] < IR_NEC_ST_BIT - IR_NEC_ST_BIT/IR_NEC_TOL_DIV) { |
449 | if (buf[0] > IR_NEC_ST_BIT + IR_NEC_ST_BIT/IR_NEC_TOL_DIV || buf[0] < IR_NEC_ST_BIT - IR_NEC_ST_BIT/IR_NEC_TOL_DIV) { |
| 444 | return IR_NOT_CORRECT_DATA; |
450 | return IR_NOT_CORRECT_DATA; |
| 445 | } |
451 | } |
| 446 | 452 | ||
| 447 | /* check pause after startbit */ |
453 | /* check pause after startbit */ |
| 448 | if (buf[1] > IR_NEC_ST_PAUSE + IR_NEC_ST_PAUSE/IR_NEC_TOL_DIV || buf[1] < IR_NEC_ST_PAUSE - IR_NEC_ST_PAUSE/IR_NEC_TOL_DIV) { |
454 | if (buf[1] > IR_NEC_ST_PAUSE + IR_NEC_ST_PAUSE/IR_NEC_TOL_DIV || buf[1] < IR_NEC_ST_PAUSE - IR_NEC_ST_PAUSE/IR_NEC_TOL_DIV) { |
| 449 | return IR_NOT_CORRECT_DATA; |
455 | return IR_NOT_CORRECT_DATA; |
| 450 | } |
456 | } |
| 451 | 457 | ||
| 452 | uint32_t rawbits = 0; |
458 | uint32_t rawbits = 0; |
| 453 | 459 | ||
| 454 | for (uint8_t i = 3; i < len; i++) { |
460 | for (uint8_t i = 3; i < len; i++) { |
| 455 | if ((i&1) == 1) { /* if odd, ir-pause */ |
461 | if ((i&1) == 1) { /* if odd, ir-pause */ |
| Line 457... | Line 463... | ||
| 457 | if (buf[i] > IR_NEC_LOW_ONE - IR_NEC_LOW_ONE/IR_NEC_TOL_DIV && buf[i] < IR_NEC_LOW_ONE + IR_NEC_LOW_ONE/IR_NEC_TOL_DIV) { |
463 | if (buf[i] > IR_NEC_LOW_ONE - IR_NEC_LOW_ONE/IR_NEC_TOL_DIV && buf[i] < IR_NEC_LOW_ONE + IR_NEC_LOW_ONE/IR_NEC_TOL_DIV) { |
| 458 | /* write a one */ |
464 | /* write a one */ |
| 459 | rawbits |= 1UL<<((i-3)>>1); |
465 | rawbits |= 1UL<<((i-3)>>1); |
| 460 | } else if (buf[i] > IR_NEC_LOW_ZERO - IR_NEC_LOW_ZERO/IR_NEC_TOL_DIV && buf[i] < IR_NEC_LOW_ZERO + IR_NEC_LOW_ZERO/IR_NEC_TOL_DIV) { |
466 | } else if (buf[i] > IR_NEC_LOW_ZERO - IR_NEC_LOW_ZERO/IR_NEC_TOL_DIV && buf[i] < IR_NEC_LOW_ZERO + IR_NEC_LOW_ZERO/IR_NEC_TOL_DIV) { |
| 461 | /* do nothing, a zero is already in place */ |
467 | /* do nothing, a zero is already in place */ |
| 462 | } else { |
468 | } else { |
| 463 | return IR_NOT_CORRECT_DATA; |
469 | return IR_NOT_CORRECT_DATA; |
| 464 | } |
470 | } |
| 465 | } else { /* if even, ir-bit */ |
471 | } else { /* if even, ir-bit */ |
| 466 | if (buf[i] > IR_NEC_HIGH + IR_NEC_HIGH/IR_NEC_TOL_DIV || buf[i] < IR_NEC_HIGH - IR_NEC_HIGH/IR_NEC_TOL_DIV) { |
472 | if (buf[i] > IR_NEC_HIGH + IR_NEC_HIGH/IR_NEC_TOL_DIV || buf[i] < IR_NEC_HIGH - IR_NEC_HIGH/IR_NEC_TOL_DIV) { |
| 467 | return IR_NOT_CORRECT_DATA; |
473 | return IR_NOT_CORRECT_DATA; |
| 468 | } |
474 | } |
| 469 | } |
475 | } |
| Line 539... | Line 545... | ||
| 539 | int8_t parseSamsung(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) { |
545 | int8_t parseSamsung(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) { |
| 540 | /* parse buf[], max is len */ |
546 | /* parse buf[], max is len */ |
| 541 | 547 | ||
| 542 | /* check if we have correct amount of data */ |
548 | /* check if we have correct amount of data */ |
| 543 | if (len != 67) { |
549 | if (len != 67) { |
| 544 | return IR_NOT_CORRECT_DATA; |
550 | return IR_NOT_CORRECT_DATA; |
| 545 | } |
551 | } |
| 546 | 552 | ||
| 547 | /* check startbit */ |
553 | /* check startbit */ |
| 548 | if (buf[0] > IR_SAMS_ST_BIT + IR_SAMS_ST_BIT/IR_SAMS_TOL_DIV || buf[0] < IR_SAMS_ST_BIT - IR_SAMS_ST_BIT/IR_SAMS_TOL_DIV) { |
554 | if (buf[0] > IR_SAMS_ST_BIT + IR_SAMS_ST_BIT/IR_SAMS_TOL_DIV || buf[0] < IR_SAMS_ST_BIT - IR_SAMS_ST_BIT/IR_SAMS_TOL_DIV) { |
| 549 | return IR_NOT_CORRECT_DATA; |
555 | return IR_NOT_CORRECT_DATA; |
| 550 | } |
556 | } |
| 551 | 557 | ||
| 552 | /* check pause after startbit */ |
558 | /* check pause after startbit */ |
| 553 | if (buf[1] > IR_SAMS_ST_PAUSE + IR_SAMS_ST_PAUSE/IR_SAMS_TOL_DIV || buf[1] < IR_SAMS_ST_PAUSE - IR_SAMS_ST_PAUSE/IR_SAMS_TOL_DIV) { |
559 | if (buf[1] > IR_SAMS_ST_PAUSE + IR_SAMS_ST_PAUSE/IR_SAMS_TOL_DIV || buf[1] < IR_SAMS_ST_PAUSE - IR_SAMS_ST_PAUSE/IR_SAMS_TOL_DIV) { |
| 554 | return IR_NOT_CORRECT_DATA; |
560 | return IR_NOT_CORRECT_DATA; |
| 555 | } |
561 | } |
| 556 | 562 | ||
| 557 | uint32_t rawbits = 0; |
563 | uint32_t rawbits = 0; |
| 558 | 564 | ||
| 559 | for (uint8_t i = 3; i < len; i++) { |
565 | for (uint8_t i = 3; i < len; i++) { |
| 560 | if ((i&1) == 1) { /* if odd, ir-pause */ |
566 | if ((i&1) == 1) { /* if odd, ir-pause */ |
| 561 | /* check length of pause between bits */ |
567 | /* check length of pause between bits */ |
| 562 | if (buf[i] > IR_SAMS_LOW_ONE - IR_SAMS_LOW_ONE/IR_SAMS_TOL_DIV && buf[i] < IR_SAMS_LOW_ONE + IR_SAMS_LOW_ONE/IR_SAMS_TOL_DIV) { |
568 | if (buf[i] > IR_SAMS_LOW_ONE - IR_SAMS_LOW_ONE/IR_SAMS_TOL_DIV && buf[i] < IR_SAMS_LOW_ONE + IR_SAMS_LOW_ONE/IR_SAMS_TOL_DIV) { |
| 563 | /* write a one */ |
569 | /* write a one */ |
| 564 | rawbits |= 1UL<<((i-3)>>1); |
570 | rawbits |= 1UL<<((i-3)>>1); |
| 565 | } else if (buf[i] > IR_SAMS_LOW_ZERO - IR_SAMS_LOW_ZERO/IR_SAMS_TOL_DIV && buf[i] < IR_SAMS_LOW_ZERO + IR_SAMS_LOW_ZERO/IR_SAMS_TOL_DIV) { |
571 | } else if (buf[i] > IR_SAMS_LOW_ZERO - IR_SAMS_LOW_ZERO/IR_SAMS_TOL_DIV && buf[i] < IR_SAMS_LOW_ZERO + IR_SAMS_LOW_ZERO/IR_SAMS_TOL_DIV) { |
| 566 | /* do nothing, a zero is already in rawbits */ |
572 | /* do nothing, a zero is already in rawbits */ |
| 567 | } else { |
573 | } else { |
| 568 | return IR_NOT_CORRECT_DATA; |
574 | return IR_NOT_CORRECT_DATA; |
| 569 | } |
575 | } |
| 570 | } else { /* if even, ir-bit */ |
576 | } else { /* if even, ir-bit */ |
| 571 | if (buf[i] > IR_SAMS_HIGH + IR_SAMS_HIGH/IR_SAMS_TOL_DIV || buf[i] < IR_SAMS_HIGH - IR_SAMS_HIGH/IR_SAMS_TOL_DIV) { |
577 | if (buf[i] > IR_SAMS_HIGH + IR_SAMS_HIGH/IR_SAMS_TOL_DIV || buf[i] < IR_SAMS_HIGH - IR_SAMS_HIGH/IR_SAMS_TOL_DIV) { |
| 572 | return IR_NOT_CORRECT_DATA; |
578 | return IR_NOT_CORRECT_DATA; |
| 573 | } |
579 | } |
| 574 | } |
580 | } |
| 575 | } |
581 | } |
| 576 | 582 | ||
| 577 | proto->protocol=IR_PROTO_SAMS; |
583 | proto->protocol=IR_PROTO_SAMS; |
| 578 | proto->timeout=IR_SAMS_TIMEOUT; |
584 | proto->timeout=IR_SAMS_TIMEOUT; |
| 579 | proto->data=rawbits; |
585 | proto->data=rawbits; |
| Line 583... | Line 589... | ||
| 583 | 589 | ||
| 584 | /** |
590 | /** |
| 585 | * Expand data from Samsung protocol |
591 | * Expand data from Samsung protocol |
| 586 | * Very much like NEC, different start bit/pause lengths etc. |
592 | * Very much like NEC, different start bit/pause lengths etc. |
| 587 | * http://www.sbprojects.com/knowledge/ir/nec.htm |
593 | * http://www.sbprojects.com/knowledge/ir/nec.htm |
| 588 | * |
594 | * |
| 589 | * @param buf |
595 | * @param buf |
| 590 | * Pointer to buffer to store the expanded data |
596 | * Pointer to buffer to store the expanded data |
| 591 | * @param len |
597 | * @param len |
| 592 | * Pointer to length of the data |
598 | * Pointer to length of the data |
| 593 | * @param proto |
599 | * @param proto |
| 594 | * Pointer to protocol information |
600 | * Pointer to protocol information |
| 595 | * @return |
601 | * @return |
| 596 | * IR_OK if data expanded successfully, one of several errormessages if not |
602 | * IR_OK if data expanded successfully, one of several errormessages if not |
| 597 | */ |
603 | */ |
| 598 | int8_t expandSamsung(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
604 | int8_t expandSamsung(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
| 599 | /* Set up startbit */ |
605 | /* Set up startbit */ |
| 600 | buf[0] = IR_SAMS_ST_BIT; |
606 | buf[0] = IR_SAMS_ST_BIT; |
| 601 | buf[1] = IR_SAMS_ST_PAUSE; |
607 | buf[1] = IR_SAMS_ST_PAUSE; |
| Line 633... | Line 639... | ||
| 633 | * Length of the data |
639 | * Length of the data |
| 634 | * @param proto |
640 | * @param proto |
| 635 | * Pointer to protocol information |
641 | * Pointer to protocol information |
| 636 | * @return |
642 | * @return |
| 637 | * IR_OK if data parsed successfully, one of several errormessages if not |
643 | * IR_OK if data parsed successfully, one of several errormessages if not |
| 638 | */ |
644 | */ |
| 639 | int8_t parseMarantz(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) { |
645 | int8_t parseMarantz(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) { |
| 640 | uint8_t halfbitscnt = 1; |
646 | uint8_t halfbitscnt = 1; |
| 641 | uint32_t rawbits = 0; |
647 | uint32_t rawbits = 0; |
| 642 | 648 | ||
| 643 | for (uint8_t i = 0; i<len; i++) { |
649 | for (uint8_t i = 0; i<len; i++) { |
| 644 | //halfbitscnt&1==1 in the middle of bits |
650 | //halfbitscnt&1==1 in the middle of bits |
| 645 | //i&1==0 positive flank |
651 | //i&1==0 positive flank |
| 646 | 652 | ||
| 647 | if ((halfbitscnt&1)==1 && (i&1)==0) { /* in the middle of bit AND a positve flank */ |
653 | if ((halfbitscnt&1)==1 && (i&1)==0) { /* in the middle of bit AND a positve flank */ |
| 648 | rawbits |= (uint32_t)1<<(19-(halfbitscnt>>1)); |
654 | rawbits |= (uint32_t)1<<(19-(halfbitscnt>>1)); |
| 649 | } |
655 | } |
| 650 | 656 | ||
| 651 | if (buf[i] > IR_MARANTZ_HALF_BIT - IR_MARANTZ_HALF_BIT/IR_MARANTZ_TOL_DIV && buf[i] < IR_MARANTZ_HALF_BIT + IR_MARANTZ_HALF_BIT/IR_MARANTZ_TOL_DIV) { |
657 | if (buf[i] > IR_MARANTZ_HALF_BIT - IR_MARANTZ_HALF_BIT/IR_MARANTZ_TOL_DIV && buf[i] < IR_MARANTZ_HALF_BIT + IR_MARANTZ_HALF_BIT/IR_MARANTZ_TOL_DIV) { |
| Line 654... | Line 660... | ||
| 654 | halfbitscnt += 2; |
660 | halfbitscnt += 2; |
| 655 | } else if (buf[i] > IR_MARANTZ_BIT - IR_MARANTZ_BIT/IR_MARANTZ_TOL_DIV && buf[i] < 5*IR_MARANTZ_HALF_BIT + IR_MARANTZ_BIT/IR_MARANTZ_TOL_DIV) { |
661 | } else if (buf[i] > IR_MARANTZ_BIT - IR_MARANTZ_BIT/IR_MARANTZ_TOL_DIV && buf[i] < 5*IR_MARANTZ_HALF_BIT + IR_MARANTZ_BIT/IR_MARANTZ_TOL_DIV) { |
| 656 | halfbitscnt += 1; //It seems to work, not entirely sure of the purpose of this long zero though. |
662 | halfbitscnt += 1; //It seems to work, not entirely sure of the purpose of this long zero though. |
| 657 | } else { |
663 | } else { |
| 658 | return IR_NOT_CORRECT_DATA; |
664 | return IR_NOT_CORRECT_DATA; |
| 659 | } |
665 | } |
| 660 | 666 | ||
| 661 | } |
667 | } |
| 662 | 668 | ||
| 663 | proto->protocol=IR_PROTO_MARANTZ; |
669 | proto->protocol=IR_PROTO_MARANTZ; |
| 664 | proto->timeout=IR_MARANTZ_TIMEOUT; |
670 | proto->timeout=IR_MARANTZ_TIMEOUT; |
| Line 696... | Line 702... | ||
| 696 | 702 | ||
| 697 | tempdata = (uint32_t)(proto->data)<<14; |
703 | tempdata = (uint32_t)(proto->data)<<14; |
| 698 | 704 | ||
| 699 | for(uint8_t i = 0; i < 17; i++) { |
705 | for(uint8_t i = 0; i < 17; i++) { |
| 700 | tempdata = (uint32_t)tempdata<<1; |
706 | tempdata = (uint32_t)tempdata<<1; |
| 701 | 707 | ||
| 702 | if (((uint32_t)tempdata>>31)==1){ |
708 | if (((uint32_t)tempdata>>31)==1){ |
| 703 | if (previousBit == 1){//11 |
709 | if (previousBit == 1){//11 |
| 704 | buf[*len] = IR_MARANTZ_HALF_BIT; |
710 | buf[*len] = IR_MARANTZ_HALF_BIT; |
| 705 | buf[*len+1] = IR_MARANTZ_HALF_BIT; |
711 | buf[*len+1] = IR_MARANTZ_HALF_BIT; |
| 706 | *len = *len + 2; |
712 | *len = *len + 2; |
| Line 738... | Line 744... | ||
| 738 | proto->repeats=IR_MARANTZ_REPS; |
744 | proto->repeats=IR_MARANTZ_REPS; |
| 739 | return IR_OK; |
745 | return IR_OK; |
| 740 | } |
746 | } |
| 741 | 747 | ||
| 742 | #if (IR_PROTOCOLS_USE_PANASONIC) |
748 | #if (IR_PROTOCOLS_USE_PANASONIC) |
| 743 | /** |
749 | /** |
| 744 | * Test data on Panasonic protocol |
750 | * Test data on Panasonic protocol |
| 745 | * |
751 | * |
| 746 | * @param buf |
752 | * @param buf |
| 747 | * Pointer to buffer to where to data to parse is stored |
753 | * Pointer to buffer to where to data to parse is stored |
| 748 | * @param len |
754 | * @param len |
| Line 1076... | Line 1082... | ||
| 1076 | * IR_OK if data expanded successfully, one of several errormessages if not |
1082 | * IR_OK if data expanded successfully, one of several errormessages if not |
| 1077 | */ |
1083 | */ |
| 1078 | int8_t expandNexa2(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
1084 | int8_t expandNexa2(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
| 1079 | buf[0] = IR_NEXA2_HIGH; |
1085 | buf[0] = IR_NEXA2_HIGH; |
| 1080 | buf[1] = IR_NEXA2_START2; |
1086 | buf[1] = IR_NEXA2_START2; |
| 1081 | 1087 | ||
| 1082 | uint64_t tempshift = proto->data; |
1088 | uint64_t tempshift = proto->data; |
| 1083 | 1089 | ||
| 1084 | /* No dimming */ |
1090 | /* No dimming */ |
| 1085 | *len = 131; |
1091 | *len = 131; |
| 1086 | uint8_t dimming = 0; |
1092 | uint8_t dimming = 0; |
| 1087 | /* If most significant bit is set, then dimming should be sent */ |
1093 | /* If most significant bit is set, then dimming should be sent */ |
| 1088 | if ((uint32_t)(tempshift>> 32)&0x80) |
1094 | if ((uint32_t)(tempshift>> 32)&0x80) |
| 1089 | { |
1095 | { |
| 1090 | /* Dimming */ |
1096 | /* Dimming */ |
| 1091 | *len = 147; |
1097 | *len = 147; |
| 1092 | dimming=1; |
1098 | dimming=1; |
| 1093 | } |
1099 | } |
| 1094 | 1100 | ||
| Line 1100... | Line 1106... | ||
| 1100 | buf[i+1] = IR_NEXA2_LOW_ONE; |
1106 | buf[i+1] = IR_NEXA2_LOW_ONE; |
| 1101 | buf[i+3] = IR_NEXA2_LOW_ZERO; |
1107 | buf[i+3] = IR_NEXA2_LOW_ZERO; |
| 1102 | } else { |
1108 | } else { |
| 1103 | buf[i+1] = IR_NEXA2_LOW_ZERO; |
1109 | buf[i+1] = IR_NEXA2_LOW_ZERO; |
| 1104 | buf[i+3] = IR_NEXA2_LOW_ONE; |
1110 | buf[i+3] = IR_NEXA2_LOW_ONE; |
| 1105 | } |
1111 | } |
| 1106 | tempshift = tempshift>>1; |
1112 | tempshift = tempshift>>1; |
| 1107 | } |
1113 | } |
| 1108 | 1114 | ||
| 1109 | if (dimming) |
1115 | if (dimming) |
| 1110 | { |
1116 | { |
| 1111 | buf[111] = IR_NEXA2_LOW_ONE; |
1117 | buf[111] = IR_NEXA2_LOW_ONE; |
| 1112 | buf[113] = IR_NEXA2_LOW_ONE; |
1118 | buf[113] = IR_NEXA2_LOW_ONE; |
| Line 1114... | Line 1120... | ||
| 1114 | proto->modfreq=IR_NEXA2_F_MOD; |
1120 | proto->modfreq=IR_NEXA2_F_MOD; |
| 1115 | proto->timeout=IR_NEXA2_START1/1000; |
1121 | proto->timeout=IR_NEXA2_START1/1000; |
| 1116 | proto->repeats=IR_NEXA2_REPS; |
1122 | proto->repeats=IR_NEXA2_REPS; |
| 1117 | return IR_OK; |
1123 | return IR_OK; |
| 1118 | } |
1124 | } |
| 1119 | 1125 | ||
| 1120 | 1126 | ||
| 1121 | #if (IR_PROTOCOLS_USE_NEXA1) |
1127 | #if (IR_PROTOCOLS_USE_NEXA1) |
| 1122 | /** |
1128 | /** |
| 1123 | * Test data on NEXA protocol |
1129 | * Test data on NEXA protocol |
| 1124 | * http://www.elektronikforumet.com/wiki/index.php/RF_Protokoll_-_Nexa/Proove_(%C3%A4ldre,_ej_sj%C3%A4lvl%C3%A4rande) |
1130 | * http://www.elektronikforumet.com/wiki/index.php/RF_Protokoll_-_Nexa/Proove_(%C3%A4ldre,_ej_sj%C3%A4lvl%C3%A4rande) |
| 1125 | * |
1131 | * |
| 1126 | * @param buf |
1132 | * @param buf |
| 1127 | * Pointer to buffer to where to data to parse is stored |
1133 | * Pointer to buffer to where to data to parse is stored |
| 1128 | * @param len |
1134 | * @param len |
| 1129 | * Length of the data |
1135 | * Length of the data |
| 1130 | * @param proto |
1136 | * @param proto |
| 1131 | * Pointer to protocol information |
1137 | * Pointer to protocol information |
| Line 1183... | Line 1189... | ||
| 1183 | { |
1189 | { |
| 1184 | /* do nothing, a zero is already in rawbits */ |
1190 | /* do nothing, a zero is already in rawbits */ |
| 1185 | bitCounter++; |
1191 | bitCounter++; |
| 1186 | } |
1192 | } |
| 1187 | else |
1193 | else |
| 1188 | { |
1194 | { |
| 1189 | return IR_NOT_CORRECT_DATA; |
1195 | return IR_NOT_CORRECT_DATA; |
| 1190 | } |
1196 | } |
| 1191 | } |
1197 | } |
| 1192 | 1198 | ||
| 1193 | if (rawbitsTemp==0) |
1199 | if (rawbitsTemp==0) |
| 1194 | { |
1200 | { |
| 1195 | /* Bogus RF data */ |
1201 | /* Bogus RF data */ |
| Line 1226... | Line 1232... | ||
| 1226 | /* encode data bits */ |
1232 | /* encode data bits */ |
| 1227 | for (uint8_t i = 0; i < 45; i += 4) |
1233 | for (uint8_t i = 0; i < 45; i += 4) |
| 1228 | { |
1234 | { |
| 1229 | if (tempshift & 1) { |
1235 | if (tempshift & 1) { |
| 1230 | /* encode 0 bit */ |
1236 | /* encode 0 bit */ |
| 1231 | buf[i+0] = IR_NEXA1_SHORT; |
1237 | buf[i+0] = IR_NEXA1_SHORT; |
| 1232 | buf[i+1] = IR_NEXA1_LONG; |
1238 | buf[i+1] = IR_NEXA1_LONG; |
| 1233 | buf[i+2] = IR_NEXA1_SHORT; |
1239 | buf[i+2] = IR_NEXA1_SHORT; |
| 1234 | buf[i+3] = IR_NEXA1_LONG; |
1240 | buf[i+3] = IR_NEXA1_LONG; |
| 1235 | } else { |
1241 | } else { |
| 1236 | /* encode X bit */ |
1242 | /* encode X bit */ |
| 1237 | buf[i+0] = IR_NEXA1_SHORT; |
1243 | buf[i+0] = IR_NEXA1_SHORT; |
| 1238 | buf[i+1] = IR_NEXA1_LONG; |
1244 | buf[i+1] = IR_NEXA1_LONG; |
| 1239 | buf[i+2] = IR_NEXA1_LONG; |
1245 | buf[i+2] = IR_NEXA1_LONG; |
| 1240 | buf[i+3] = IR_NEXA1_SHORT; |
1246 | buf[i+3] = IR_NEXA1_SHORT; |
| 1241 | } |
1247 | } |
| 1242 | tempshift = tempshift>>1; |
1248 | tempshift = tempshift>>1; |
| 1243 | } |
1249 | } |
| 1244 | 1250 | ||
| 1245 | /* encode stop/sync bit */ |
1251 | /* encode stop/sync bit */ |
| 1246 | buf[48] = IR_NEXA1_SHORT; |
1252 | buf[48] = IR_NEXA1_SHORT; |
| 1247 | 1253 | ||
| 1248 | proto->modfreq = IR_NEXA1_F_MOD; |
1254 | proto->modfreq = IR_NEXA1_F_MOD; |
| 1249 | proto->timeout = IR_NEXA1_START/1000; |
1255 | proto->timeout = IR_NEXA1_START/1000; |
| 1250 | proto->repeats = IR_NEXA1_REPS; |
1256 | proto->repeats = IR_NEXA1_REPS; |
| 1251 | return IR_OK; |
1257 | return IR_OK; |
| 1252 | } |
1258 | } |
| 1253 | 1259 | ||
| 1254 | 1260 | ||
| 1255 | #if (IR_PROTOCOLS_USE_VIKING) |
1261 | #if (IR_PROTOCOLS_USE_VIKING) |
| 1256 | /** |
1262 | /** |
| 1257 | * Test data on Viking temperature sensor protocol |
1263 | * Test data on Viking temperature sensor protocol |
| 1258 | * |
1264 | * |
| Line 1289... | Line 1295... | ||
| 1289 | return IR_NOT_CORRECT_DATA; |
1295 | return IR_NOT_CORRECT_DATA; |
| 1290 | 1296 | ||
| 1291 | if ((i&1) == 0) |
1297 | if ((i&1) == 0) |
| 1292 | { /* if even, no data */ |
1298 | { /* if even, no data */ |
| 1293 | if ((buf[i2] < IR_VIKING_LOW - IR_VIKING_LOW/IR_VIKING_TOL_DIV) || (buf[i2] > IR_VIKING_LOW + IR_VIKING_LOW/IR_VIKING_TOL_DIV)) |
1299 | if ((buf[i2] < IR_VIKING_LOW - IR_VIKING_LOW/IR_VIKING_TOL_DIV) || (buf[i2] > IR_VIKING_LOW + IR_VIKING_LOW/IR_VIKING_TOL_DIV)) |
| 1294 | { |
1300 | { |
| 1295 | return IR_NOT_CORRECT_DATA; |
1301 | return IR_NOT_CORRECT_DATA; |
| 1296 | } |
1302 | } |
| 1297 | } |
1303 | } |
| 1298 | else |
1304 | else |
| 1299 | { /* if odd, data */ |
1305 | { /* if odd, data */ |
| 1300 | /* check length of transmit pulse */ |
1306 | /* check length of transmit pulse */ |
| 1301 | if ((buf[i2] > IR_VIKING_HIGH_ONE - IR_VIKING_HIGH_ONE/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_HIGH_ONE + IR_VIKING_HIGH_ONE/IR_VIKING_TOL_DIV)) |
1307 | if ((buf[i2] > IR_VIKING_HIGH_ONE - IR_VIKING_HIGH_ONE/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_HIGH_ONE + IR_VIKING_HIGH_ONE/IR_VIKING_TOL_DIV)) |
| 1302 | { |
1308 | { |
| 1303 | /* write a one */ |
1309 | /* write a one */ |
| 1304 | rawbitsTemp = rawbitsTemp<<1; |
1310 | rawbitsTemp = rawbitsTemp<<1; |
| 1305 | rawbitsTemp |= 1; |
1311 | rawbitsTemp |= 1; |
| 1306 | } |
1312 | } |
| 1307 | else if ((buf[i2] > IR_VIKING_HIGH_ZERO - IR_VIKING_HIGH_ZERO/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_HIGH_ZERO + IR_VIKING_HIGH_ZERO/IR_VIKING_TOL_DIV)) |
1313 | else if ((buf[i2] > IR_VIKING_HIGH_ZERO - IR_VIKING_HIGH_ZERO/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_HIGH_ZERO + IR_VIKING_HIGH_ZERO/IR_VIKING_TOL_DIV)) |
| 1308 | { |
1314 | { |
| 1309 | /* do nothing, a zero is already in rawbits */ |
1315 | /* do nothing, a zero is already in rawbits */ |
| 1310 | rawbitsTemp = rawbitsTemp<<1; |
1316 | rawbitsTemp = rawbitsTemp<<1; |
| 1311 | } |
1317 | } |
| 1312 | else |
1318 | else |
| 1313 | { |
1319 | { |
| 1314 | return IR_NOT_CORRECT_DATA; |
1320 | return IR_NOT_CORRECT_DATA; |
| 1315 | } |
1321 | } |
| 1316 | } |
1322 | } |
| 1317 | } |
1323 | } |
| 1318 | 1324 | ||
| 1319 | rawbitsTemp = ~rawbitsTemp; |
1325 | rawbitsTemp = ~rawbitsTemp; |
| 1320 | rawbitsTemp = rawbitsTemp&0xFFFFFFFFFF; |
1326 | rawbitsTemp = rawbitsTemp&0xFFFFFFFFFF; |
| 1321 | 1327 | ||
| 1322 | proto->protocol=IR_PROTO_VIKING; |
1328 | proto->protocol=IR_PROTO_VIKING; |
| Line 1324... | Line 1330... | ||
| 1324 | proto->data=rawbitsTemp; |
1330 | proto->data=rawbitsTemp; |
| 1325 | 1331 | ||
| 1326 | return IR_OK; |
1332 | return IR_OK; |
| 1327 | #else |
1333 | #else |
| 1328 | return IR_NOT_CORRECT_DATA; |
1334 | return IR_NOT_CORRECT_DATA; |
| - | 1335 | #endif |
|
| - | 1336 | } |
|
| - | 1337 | #endif |
|
| - | 1338 | ||
| - | 1339 | ||
| - | 1340 | #if (IR_PROTOCOLS_USE_VIKING_STEAK) |
|
| - | 1341 | /** |
|
| - | 1342 | * Test data on Viking steak temperature sensor protocol |
|
| - | 1343 | * |
|
| - | 1344 | * |
|
| - | 1345 | * |
|
| - | 1346 | * @param buf |
|
| - | 1347 | * Pointer to buffer to where to data to parse is stored |
|
| - | 1348 | * @param len |
|
| - | 1349 | * Length of the data |
|
| - | 1350 | * @param proto |
|
| - | 1351 | * Pointer to protocol information |
|
| - | 1352 | * @return |
|
| - | 1353 | * IR_OK if data parsed successfully, one of several errormessages if not |
|
| - | 1354 | */ |
|
| - | 1355 | ||
| - | 1356 | int8_t parseVikingSteak(const uint16_t *buf, uint8_t len, uint8_t index, Ir_Protocol_Data_t *proto) |
|
| - | 1357 | { |
|
| - | 1358 | #if IR_RX_CONTINUOUS_MODE==1 |
|
| - | 1359 | /* check if we have correct amount of data */ |
|
| - | 1360 | if (len < 74) { |
|
| - | 1361 | return IR_NOT_CORRECT_DATA; |
|
| - | 1362 | } |
|
| - | 1363 | uint8_t i, i2; |
|
| - | 1364 | uint64_t rawbitsTemp = 0;//0xffffffffffffffff; |
|
| - | 1365 | ||
| - | 1366 | /* Check start bit condition */ |
|
| - | 1367 | i2=index-74; |
|
| - | 1368 | if (i2>index) |
|
| - | 1369 | i2+=MAX_NR_TIMES; |
|
| - | 1370 | ||
| - | 1371 | proto->data=i2; /*Store startindex for debug output */ |
|
| - | 1372 | ||
| - | 1373 | if ((buf[i2] < IR_VIKING_STEAK_LOW_START - IR_VIKING_STEAK_LOW_START/IR_VIKING_STEAK_TOL_DIV) || (buf[i2] > IR_VIKING_STEAK_LOW_START + IR_VIKING_STEAK_LOW_START/IR_VIKING_STEAK_TOL_DIV)) |
|
| - | 1374 | { |
|
| - | 1375 | return IR_NOT_CORRECT_DATA; |
|
| - | 1376 | } |
|
| - | 1377 | ||
| - | 1378 | for (i = 73; i > 0; i--) |
|
| - | 1379 | { |
|
| - | 1380 | i2=index-i; |
|
| - | 1381 | if (i2>index) |
|
| - | 1382 | i2+=MAX_NR_TIMES; |
|
| - | 1383 | ||
| - | 1384 | /* Check if correct amount of data have been received */ |
|
| - | 1385 | //if ((i == 78) && (rawbitsTemp != 0b00001)) |
|
| - | 1386 | // return IR_NOT_CORRECT_DATA; |
|
| - | 1387 | ||
| - | 1388 | if ((i&1) != 0) |
|
| - | 1389 | { /* if odd, no data */ |
|
| - | 1390 | if ((buf[i2] < IR_VIKING_STEAK_HIGH - IR_VIKING_STEAK_HIGH/IR_VIKING_STEAK_TOL_DIV) || (buf[i2] > IR_VIKING_STEAK_HIGH + IR_VIKING_STEAK_HIGH/IR_VIKING_STEAK_TOL_DIV)) |
|
| - | 1391 | { |
|
| - | 1392 | return IR_NOT_CORRECT_DATA; |
|
| - | 1393 | } |
|
| - | 1394 | } |
|
| - | 1395 | else |
|
| - | 1396 | { /* if even, data */ |
|
| - | 1397 | /* check length of transmit pulse */ |
|
| - | 1398 | if ((buf[i2] > IR_VIKING_STEAK_LOW_ONE - IR_VIKING_STEAK_LOW_ONE/IR_VIKING_STEAK_TOL_DIV) && (buf[i2] < IR_VIKING_STEAK_LOW_ONE + IR_VIKING_STEAK_LOW_ONE/IR_VIKING_STEAK_TOL_DIV)) |
|
| - | 1399 | { |
|
| - | 1400 | /* write a one */ |
|
| - | 1401 | rawbitsTemp = rawbitsTemp<<1; |
|
| - | 1402 | rawbitsTemp |= 1; |
|
| - | 1403 | } |
|
| - | 1404 | else if ((buf[i2] > IR_VIKING_STEAK_LOW_ZERO - IR_VIKING_STEAK_LOW_ZERO/IR_VIKING_STEAK_TOL_DIV) && (buf[i2] < IR_VIKING_STEAK_LOW_ZERO + IR_VIKING_STEAK_LOW_ZERO/IR_VIKING_STEAK_TOL_DIV)) |
|
| - | 1405 | { |
|
| - | 1406 | /* do nothing, a zero is already in rawbits */ |
|
| - | 1407 | rawbitsTemp = rawbitsTemp<<1; |
|
| - | 1408 | } |
|
| - | 1409 | else |
|
| - | 1410 | { |
|
| - | 1411 | return IR_NOT_CORRECT_DATA; |
|
| - | 1412 | } |
|
| - | 1413 | } |
|
| - | 1414 | } |
|
| - | 1415 | ||
| - | 1416 | //rawbitsTemp = ~rawbitsTemp; |
|
| - | 1417 | //rawbitsTemp = rawbitsTemp&0xFFFFFFFFFF; |
|
| - | 1418 | ||
| - | 1419 | proto->protocol=IR_PROTO_VIKING_STEAK; |
|
| - | 1420 | proto->timeout=IR_VIKING_STEAK_TIMEOUT; |
|
| - | 1421 | proto->data=rawbitsTemp; |
|
| - | 1422 | ||
| - | 1423 | return IR_OK; |
|
| - | 1424 | #else |
|
| - | 1425 | return IR_NOT_CORRECT_DATA; |
|
| 1329 | #endif |
1426 | #endif |
| 1330 | } |
1427 | } |
| 1331 | #endif |
1428 | #endif |
| 1332 | 1429 | ||
| 1333 | - | ||
| 1334 | #if ( |
1430 | #if (IR_PROTOCOLS_USE_RUBICSON) |
| 1335 | /** |
1431 | /** |
| 1336 | * Test data on |
1432 | * Test data on Rubicson temperature sensor protocol |
| 1337 | * |
1433 | * |
| 1338 | * |
1434 | * |
| 1339 | * |
1435 | * |
| 1340 | * @param buf |
1436 | * @param buf |
| 1341 | * Pointer to buffer to where to data to parse is stored |
1437 | * Pointer to buffer to where to data to parse is stored |
| Line 1345... | Line 1441... | ||
| 1345 | * Pointer to protocol information |
1441 | * Pointer to protocol information |
| 1346 | * @return |
1442 | * @return |
| 1347 | * IR_OK if data parsed successfully, one of several errormessages if not |
1443 | * IR_OK if data parsed successfully, one of several errormessages if not |
| 1348 | */ |
1444 | */ |
| 1349 | 1445 | ||
| 1350 | int8_t |
1446 | int8_t parseRubicson(const uint16_t *buf, uint8_t len, uint8_t index, Ir_Protocol_Data_t *proto) |
| 1351 | { |
1447 | { |
| 1352 | #if IR_RX_CONTINUOUS_MODE==1 |
1448 | #if IR_RX_CONTINUOUS_MODE==1 |
| 1353 | /* check if we have correct amount of data */ |
1449 | /* check if we have correct amount of data */ |
| 1354 | if (len < 74) { |
1450 | if (len < 74) { |
| 1355 | return IR_NOT_CORRECT_DATA; |
1451 | return IR_NOT_CORRECT_DATA; |
| 1356 | } |
1452 | } |
| 1357 | uint8_t i, i2; |
1453 | uint8_t i, i2; |
| 1358 | uint64_t rawbitsTemp = 0;//0xffffffffffffffff; |
1454 | uint64_t rawbitsTemp = 0;//0xffffffffffffffff; |
| 1359 | 1455 | ||
| 1360 | /* Check start bit condition */ |
1456 | /* Check start bit condition */ |
| 1361 | i2=index-74; |
1457 | i2=index-74; |
| 1362 | if (i2>index) |
1458 | if (i2>index) |
| 1363 | i2+=MAX_NR_TIMES; |
1459 | i2+=MAX_NR_TIMES; |
| 1364 | 1460 | ||
| 1365 | proto->data=i2; /*Store startindex for debug output */ |
1461 | proto->data=i2; /*Store startindex for debug output */ |
| 1366 | 1462 | ||
| 1367 | if ((buf[i2] < |
1463 | if ((buf[i2] < IR_RUBICSON_LOW_START - IR_RUBICSON_LOW_START/IR_RUBICSON_TOL_DIV) || (buf[i2] > IR_RUBICSON_LOW_START + IR_RUBICSON_LOW_START/IR_RUBICSON_TOL_DIV)) |
| 1368 | { |
1464 | { |
| 1369 | return IR_NOT_CORRECT_DATA; |
1465 | return IR_NOT_CORRECT_DATA; |
| 1370 | } |
1466 | } |
| 1371 | 1467 | ||
| 1372 | for (i = 73; i > 0; i--) |
1468 | for (i = 73; i > 0; i--) |
| Line 1379... | Line 1475... | ||
| 1379 | //if ((i == 78) && (rawbitsTemp != 0b00001)) |
1475 | //if ((i == 78) && (rawbitsTemp != 0b00001)) |
| 1380 | // return IR_NOT_CORRECT_DATA; |
1476 | // return IR_NOT_CORRECT_DATA; |
| 1381 | 1477 | ||
| 1382 | if ((i&1) != 0) |
1478 | if ((i&1) != 0) |
| 1383 | { /* if odd, no data */ |
1479 | { /* if odd, no data */ |
| 1384 | if ((buf[i2] < |
1480 | if ((buf[i2] < IR_RUBICSON_HIGH - IR_RUBICSON_HIGH/IR_VIKING_STEAK_TOL_DIV) || (buf[i2] > IR_RUBICSON_HIGH + IR_RUBICSON_HIGH/IR_RUBICSON_TOL_DIV)) |
| 1385 | { |
1481 | { |
| 1386 | return IR_NOT_CORRECT_DATA; |
1482 | return IR_NOT_CORRECT_DATA; |
| 1387 | } |
1483 | } |
| 1388 | } |
1484 | } |
| 1389 | else |
1485 | else |
| 1390 | { /* if even, data */ |
1486 | { /* if even, data */ |
| 1391 | /* check length of transmit pulse */ |
1487 | /* check length of transmit pulse */ |
| 1392 | if ((buf[i2] > |
1488 | if ((buf[i2] > IR_RUBICSON_LOW_ONE - IR_RUBICSON_LOW_ONE/IR_RUBICSON_TOL_DIV) && (buf[i2] < IR_RUBICSON_LOW_ONE + IR_RUBICSON_LOW_ONE/IR_RUBICSON_TOL_DIV)) |
| 1393 | { |
1489 | { |
| 1394 | /* write a one */ |
1490 | /* write a one */ |
| 1395 | rawbitsTemp = rawbitsTemp<<1; |
1491 | rawbitsTemp = rawbitsTemp<<1; |
| 1396 | rawbitsTemp |= 1; |
1492 | rawbitsTemp |= 1; |
| 1397 | } |
1493 | } |
| 1398 | else if ((buf[i2] > |
1494 | else if ((buf[i2] > IR_RUBICSON_LOW_ZERO - IR_RUBICSON_LOW_ZERO/IR_RUBICSON_TOL_DIV) && (buf[i2] < IR_RUBICSON_LOW_ZERO + IR_RUBICSON_LOW_ZERO/IR_RUBICSON_TOL_DIV)) |
| 1399 | { |
1495 | { |
| 1400 | /* do nothing, a zero is already in rawbits */ |
1496 | /* do nothing, a zero is already in rawbits */ |
| 1401 | rawbitsTemp = rawbitsTemp<<1; |
1497 | rawbitsTemp = rawbitsTemp<<1; |
| 1402 | } |
1498 | } |
| 1403 | else |
1499 | else |
| Line 1408... | Line 1504... | ||
| 1408 | } |
1504 | } |
| 1409 | 1505 | ||
| 1410 | //rawbitsTemp = ~rawbitsTemp; |
1506 | //rawbitsTemp = ~rawbitsTemp; |
| 1411 | //rawbitsTemp = rawbitsTemp&0xFFFFFFFFFF; |
1507 | //rawbitsTemp = rawbitsTemp&0xFFFFFFFFFF; |
| 1412 | 1508 | ||
| 1413 | proto->protocol= |
1509 | proto->protocol=IR_PROTO_RUBICSON; |
| 1414 | proto->timeout= |
1510 | proto->timeout=IR_RUBICSON_TIMEOUT; |
| 1415 | proto->data=rawbitsTemp; |
1511 | proto->data=rawbitsTemp; |
| 1416 | 1512 | ||
| 1417 | return IR_OK; |
1513 | return IR_OK; |
| 1418 | #else |
1514 | #else |
| 1419 | return IR_NOT_CORRECT_DATA; |
1515 | return IR_NOT_CORRECT_DATA; |
| 1420 | #endif |
1516 | #endif |
| 1421 | } |
1517 | } |
| 1422 | #endif |
1518 | #endif |
| - | 1519 | ||