Closed mafflerbach closed 7 years ago
Having a look at your code, a few things stand out as potential issues:
unsigned long code = server.arg(i).toInt();
int foo = server.arg(i).toInt();
// testing for the roundtrip
for(int i = 0; i < 10; i++) {
irsend.sendRC6(foo, 21);
delay(10);
Serial.println(foo);
FYI, int on the ESP8266 & arduino's is only 16 bits. long is 32 bit. This is unlike linux which typically has a 32 bit int. So change all instances of 'foo' to 'code' is a good first start. The codes you are trying to send are all bigger than a uint16_t (0xFFFF). Next, I'm not 100% sure .toInt() handles longs. It probably does, but worth checking/confirming.
You are printing 'foo' (code) to serial. What is the value it is displaying. i.e. Does it match what you're sending as the '&int=' html argument?
So, on this point totally clueless how to debug this shi*** .
Lots of Serial.println()s. ;-) You'll need to connect a serial monitor/terminal/etc to the ESP8266 and set it to 115200 baud. We also typically use our own library (or similar) on another ESP8266 or arduino device and capture the raw timing values, so we know exactly what we are looking at. See examples directory.
Now, my confessions. I'm not familiar with LIRC that much, so you may need to explain what you are seeing a bit more to me. Next, I haven't really worked with or have any RC6 devices, so I can't easily test with 100% assurance.
A thing I find unsettling is, if I am understanding the LIRC stuff correctly, is that the ESP is transmitting 22 bits, when you've told it 21. Btw, where are you getting the '21' value from in your irsend.sendRC6(foo, 21);
call? 21 seems to be an odd (pun intended) value for the number of bits. The RC6 protocol calls for a Stop Bit after the initial header. This isn't counted in the IRremote library in the nr. of bits. Maybe LIRC is seeing that and counting it in its count of bits. So something to try is use '20' instead of '21'. e.g. irsend.sendRC6(code, 20);
Let us know what debug values you're getting and what of the above you've tried.
Most of the code (okay eeeevrything ;) ) comes from examples/IRServer.
in case of 21 to 22 bit: I thought the bits param from the lirc.conf is the right bit counting. But maybe i missunderstood the meaning of "bits" in the conf and "bits" as param in the methode.
//extending only the handleIr methode
void handleIr(){
for (uint8_t i=0; i<server.args(); i++){
//Serial.println("arg: " + server.argName(i));
if(server.argName(i) == "int")
{
Serial.println("val: " + server.arg(i));
unsigned long code = server.arg(i).toInt();
int code2 = server.arg(i).toInt();
//Serial.print("Send: " + code);
// don't print to SM - but why ?
Serial.printf("code: %u\n", code);
// print the expected value
for(int i = 0; i < 7; i++) {
irsend.sendRC6(code, 20);
delay(10);
Serial.printf("code: %u\n", code);
}
/**
Complete Output in SM:
Connected to "Networkname"
IP address: "IP Address"
MDNS responder started
HTTP server started
// after click on the link:
val: 1048562
code: 1048562
*/
}
}
handleRoot();
}
So at this point maybe i have 2 problems... The wrong bit (i have teste with 20 and 22 bit, but both of them could not fix the problem), and the second is, that the codes from irrecord from linux is not compatible with the lib from IRremoteESP8266.
My next step is, to record the codes with the esp, and testing with this side.
My next step is, to record the codes with the esp, and testing with this side.
Taking a step back. What is it you are trying to achieve? I'm assuming you have a device which receives an RC6 code, and a remote that produces an RC6 code and you want to replicate the latter on the ESP. You should then look at dumping what the actual remote sends, on the ESP using https://github.com/markszabo/IRremoteESP8266/blob/master/examples/IRrecvDumpV2/IRrecvDumpV2.ino or similar. Numeric 'codes' can often differ from one library implementation to another for the same physical button press on an actual remote. e.g. Some store the incoming transmitted bit pattern starting at the LSB and some in the MSB.
Also, the raw dump will include the timing values of each mark(led on) and each space(led off) period, and will be useful to debug if we are producing an incorrect pattern with sendRC6().
Thanks for the extra debugging info so far. I'm glad to know .toInt() handles longs also on the platform.
BTW, what device & remote are you trying to emulate? e.g. XBox 360 and some MCE stuff uses 36 bit codes which we are trying to work out support for, as they are larger than the 32bit longs currently used.
Oh, reading up a bit on LIRC, I found this: http://www.righto.com/2010/12/64-bit-rc6-codes-arduino-and-xbox.html
To use these RC6 code with the Arduino takes a bit of work. First, the codes have been split into 21 bits of pre-data, followed by 16 bits of data. So if you want the OnOff code, you need to concatenate the bits together, to get 37 bits: 0x37ff08bf3. The second factor is the Arduino library provides the first start bit automatically, so you only need to use 36 bits. The third issue is the LIRC files inconveniently have 0 and 1 bits swapped, so you'll need to invert the code. The result is the 36-bit code 0xc800f740c that can be used with the IRremote library. The rc6_mask specifies which bit is the double-wide "trailer" bit, which is the fourth bit sent (both in 20 and 36 bit RC6 codes). The library handles this bit automatically, so you can ignore it.
The toggle_bit_mask is important, as it indicates which position needs to be toggled every other transmission. For example, to transmit OnOff you will send 0xc800f740c the first time, but the next time you will need to transmit 0xc800ff40c.
So, you can't just take the code from LIRC and use it unmodified in an IRremote-esque based library. Using a 20 bit length in our library is the equiv of 21 bit in LIRC for this protocol (see quote).
That also reminds me, you need to handle the toggle bit when sending multiple codes with RC6. This library leaves it up to the caller to handle that aspect.
For 36bit codes, there is an experimental RC6 branch of the library, where I've been working on supporting that bit code length. It might be worth a shot, but you'll need to convert your IR code args to unsigned long long's to use it.
BTW, what device & remote are you trying to emulate? e.g. XBox 360 and some MCE stuff uses 36 bit codes which we are trying to work out support for, as they are larger than the 32bit longs currently used.
It's a orginal philips RC 4492 01b.
Ohh well, really interesting. I thougt i have a rc6 remote controll. But the dumping says other things (see below).
So, i understand it right, that my only option by these incomming data is, sending raw data ?
Here is the output if someone needs it in the future:
on/off
Encoding : UNKNOWN
Code : B4CB49F4 (32 bits)
Timing[40]:
+ 950, - 500 + 850, - 500 + 400, - 500 + 400, - 500
+ 850, - 950 + 450, - 500 + 400, - 500 + 400, - 500
+ 400, - 500 + 400, - 500 + 400, - 500 + 400, - 500
+ 400, - 500 + 400, - 500 + 400, - 500 + 400, - 500
+ 400, - 950 + 450, - 500 + 850, - 500 + 400, - 500
unsigned int rawData[40] = {950,500, 850,500, 400,500, 400,500, 850,950, 450,500, 400,500, 400,500, 400,5
00, 400,500, 400,500, 400,500, 400,500, 400,500, 400,500, 400,500, 400,950, 450,500, 850,500, 400,500 };
// UNKNOWN B4CB49F4
mute
Encoding : UNKNOWN
Code : 11C1CC36 (32 bits)
Timing[42]:
+ 950, - 500 + 900, - 500 + 450, - 500 + 450, - 500
+ 900, - 900 + 500, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500
unsigned int rawData[42] = {950,500, 900,500, 450,500, 450,500, 900,900, 500,500, 450,500, 450,500, 450,5
00, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500 };
// UNKNOWN 11C1CC36
1
Encoding : UNKNOWN
Code : 8075A6C5 (32 bits)
Timing[38]:
+ 950, - 500 + 900, - 500 + 450, - 500 + 450, -1300
+1400, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 950
unsigned int rawData[38] = {950,500, 900,500, 450,500, 450,1300, 1400,500, 450,500, 450,500, 450,500, 450
,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,950 };
// UNKNOWN 8075A6C5
2
Encoding : UNKNOWN
Code : 36F039E3 (32 bits)
Timing[40]:
+ 950, - 500 + 850, - 500 + 400, - 500 + 400, - 500
+ 850, - 950 + 450, - 500 + 400, - 500 + 450, - 500
+ 400, - 500 + 450, - 500 + 400, - 500 + 450, - 500
+ 450, - 500 + 400, - 500 + 450, - 500 + 450, - 500
+ 400, - 500 + 450, - 500 + 450, - 950 + 900, - 500
unsigned int rawData[40] = {950,500, 850,500, 400,500, 400,500, 850,950, 450,500, 400,500, 450,500, 400,5
00, 450,500, 400,500, 450,500, 450,500, 400,500, 450,500, 450,500, 400,500, 450,500, 450,950, 900,500 };
// UNKNOWN 36F039E3
3
Encoding : UNKNOWN
Code : F07D12DC (32 bits)
Timing[38]:
+ 950, - 500 + 900, - 500 + 450, - 500 + 450, -1400
+1350, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 950 + 450, - 500
unsigned int rawData[38] = {950,500, 900,500, 450,500, 450,1400, 1350,500, 450,500, 450,500, 450,500, 450
,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,950, 450,500 };
// UNKNOWN F07D12DC
4
Encoding : UNKNOWN
Code : 9897C6AA (32 bits)
Timing[38]:
+ 900, - 400 +1000, - 400 + 550, - 400 + 550, -1350
+1350, - 400 + 550, - 400 + 550, - 400 + 550, - 400
+ 550, - 400 + 550, - 400 + 550, - 400 + 550, - 400
+ 550, - 400 + 550, - 400 + 550, - 400 + 550, - 400
+ 550, - 900 + 950, - 400 + 550, - 400
unsigned int rawData[38] = {900,400, 1000,400, 550,400, 550,1350, 1350,400, 550,400, 550,400, 550,400, 55
0,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,900, 950,400, 550,400 };
// UNKNOWN 9897C6AA
5
Encoding : UNKNOWN
Code : FB6C8A70 (32 bits)
Timing[38]:
+ 900, - 400 +1000, - 400 + 550, - 400 + 550, - 400
+1000, - 900 + 500, - 400 + 550, - 400 + 550, - 400
+ 550, - 400 + 550, - 400 + 550, - 400 + 550, - 400
+ 550, - 400 + 550, - 400 + 550, - 400 + 550, - 400
+ 550, - 400 + 550, - 900 + 950, - 900
unsigned int rawData[38] = {900,400, 1000,400, 550,400, 550,400, 1000,900, 500,400, 550,400, 550,400, 550
,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,900, 950,900 };
// UNKNOWN FB6C8A70
6
Encoding : UNKNOWN
Code : D57E76D1 (32 bits)
Timing[38]:
+ 900, - 400 +1000, - 400 + 550, - 400 + 550, -1350
+1350, - 400 + 550, - 400 + 550, - 400 + 550, - 400
+ 550, - 400 + 550, - 400 + 550, - 400 + 550, - 400
+ 550, - 400 + 550, - 400 + 550, - 400 + 550, - 400
+ 550, - 900 + 500, - 400 +1000, - 400
unsigned int rawData[38] = {900,400, 1000,400, 550,400, 550,1350, 1350,400, 550,400, 550,400, 550,400, 55
0,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,400, 550,900, 500,400, 1000,400 };
// UNKNOWN D57E76D1
7
Encoding : UNKNOWN
Code : D87E7B88 (32 bits)
Timing[38]:
+1000, - 500 + 900, - 500 + 450, - 500 + 450, -1300
+1400, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 850 + 550, - 500 + 450, - 500
unsigned int rawData[38] = {1000,500, 900,500, 450,500, 450,1300, 1400,500, 450,500, 450,500, 450,500, 45
0,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,850, 550,500, 450,500 };
// UNKNOWN D87E7B88
8
Encoding : UNKNOWN
Code : A0EC7588 (32 bits)
Timing[40]:
+1000, - 500 + 900, - 500 + 450, - 500 + 450, - 500
+ 900, - 850 + 500, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 850 +1000, - 500 + 450, - 500 + 450, - 500
unsigned int rawData[40] = {1000,500, 900,500, 450,500, 450,500, 900,850, 500,500, 450,500, 450,500, 450,
500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,850, 1000,500, 450,500, 450,500 };
// UNKNOWN A0EC7588
9
Encoding : UNKNOWN
Code : A0873985 (32 bits)
Timing[38]:
+ 950, - 500 + 900, - 500 + 450, - 500 + 450, - 500
+ 900, - 900 + 500, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 900 + 950, - 500 + 450, - 900
unsigned int rawData[38] = {950,500, 900,500, 450,500, 450,500, 900,900, 500,500, 450,500, 450,500, 450,5
00, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,900, 950,500, 450,900 };
// UNKNOWN A0873985
0
Encoding : UNKNOWN
Code : 11C1CC36 (32 bits)
Timing[42]:
+ 950, - 500 + 900, - 500 + 450, - 500 + 450, - 500
+ 900, - 900 + 500, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500 + 450, - 500 + 450, - 500 + 450, - 500
+ 450, - 500
unsigned int rawData[42] = {950,500, 900,500, 450,500, 450,500, 900,900, 500,500, 450,500, 450,500, 450,5
00, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450,500, 450
,500 }; // UNKNOWN 11C1CC36
Thanks for that. In the short term, yes, raw format is what you'll need to use to (re)send those codes.
The codes you have provided are a little odd. The don't seem to have a clear header mark & space like most protocols. Next, they seem to be of different lengths which is even more odd. I don't recognise the protocol off the top of my head, but I'll have a look around later.
You might want to try globalcache's IRDB to see if you can find the codes for what ever the recipient device is.
After hours to reproduce send and resend codes in raw format, i can't get running a simple functioning call.... ohh what frustrating. hmph. Could i have damaged my receiver so it get oddish results?
Unlikely. I'd suggest trying getting a single code correct first. As I said earlier, the received results above don't have the right feel to them. They are odd. I'd expect long(er) pulses/timings for the first pair in the rawData, and a constant length to the rawData array for typical remote codes.
Still need any help?
sorry in the last days i had not time to check the codes. Today i recorded my remote control and in this time i get totally other results. here in example the mute button:
Encoding : RC6 Code : 1000D (20 bits) Timing[37]: +2650, - 950 + 500, - 900 + 500, - 450 + 500, - 450 +1300, -1400 + 500, - 450 + 500, - 450 + 500, - 450
oh, and watch its RC6 remote control -_- really annoying. But this result came after holding the button for a second or two.
So maybe this is the point, to get valid codes
My guess is the IR receiver you've got connected is a typical 38kHz variety, and there might be some issues with the 36kHz signal from the remote. If you want to receive the IR signal to do actions on, then that's probably an issue. However, sending really doesn't require anything special other than a typical 940nm IR LED. If that's all you need to do, then you're probably fine.
Something to note, the example dumping code doesn't play well with repeated signals. The time it takes to print out the decoded info etc, it's already missed/mangled the next incoming code. Often you only get a good clean sample on the very first code.
It's good that its a standard RC6 protocol remote. Now all we need to work out is why the sendRC6() code isn't giving you a good enough signal for your device.
We seem to be using timing values of the following for RC6:
That pretty much is what we are seeing (+/- 50) in the raw dump and in the RC6 spec, except the 4th bit which is double length, seems to be greater than expected in your dump. Interesting.
Have you tried sending with sendRC6(0x1000D, 20);
yet to see if it controls the device or if your LIRC device decodes it correctly as an RC6 signal?
Oh, and remember, you have to manage the toggle bit yourself between transmissions for RC6.
FYI, something to try is the reporter's suggestion in #62
What the heck.... Okay Today i have a litlebit time to testing the "new" recorded codes, Drum whirl aaaaannnnndd it's work... I don't know what, i don't know how, and why, but I must have done something else. I wish I could better describe what was different, or why it did not work at the first time.
Nevertheless many thank you for the great support!
Good to hear. If you do isolate what the cause of your issue was, I'd love to know so we can add it to the Troubleshooting Guide.
Otherwise we can chalk it up to "Unvalidated, synchronous memory variance".
Marking this resolved now. If you think it isn't, please feel free to re-open it.
from the level It's not a newbie question. But I'm a newbie in embedded programming (i'm coming from the web development side).
I have an ai Thinker NodeMCU dev board connected with an Ir diode.
i collected with my raspberry and irrecord the specific key codes. My tests to controll my tv with these code over irsend is functioning (e.g. irsend SEND_ONCE philips KEY_MUTE)
*KEY_MUTE stands for the signal 0x0FFFF2 btw for signal 1048562
But i have problem to send the signal over the dev board. A roundtrip test (rerecording the data from esp to raspi) have a complete other hex lis. i.g.
KEY_MUTE 0x0FFFF2 => 1048562
KEY_MUTE 0x10000D => 1048589
here is my code *striped some lines:
the base bit was switch from 21 to 22
So, on this point totally clueless how to debug this shi*** . so maybe the folk from here have some ideas.
esptest lirc.conf
functioning lirc.conf