B4J Question SOLVED - A little help adding c function (sendPronto)

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I am trying to add the sendPronto routine to the IRremoteESP8266 library.

I've gotten everything to compile properly but am always getting back a -2 (changed the sendPronto routine to return int's for return codes)

NOTE: the return 99 at the end will be changed to 0 once everything is working fine. Just wanted to make sure I was hitting that code.

Here is what I am sending from my B4R program

B4X:
Dim x() As UInt = Array As UInt(0x0000, 0x007e, 0x0022, 0x0000, 0x000a, 0x0046, 0x000a, 0x0046, 0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e,  _
                                0x000a, 0x001e, 0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e,  _
                                0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x036a, 0x000a, 0x0046, 0x000a, 0x0046,  _
                                0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e,  _
                                0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e,  _
                                0x0009, 0x0000)
                             
            Log("SendPronto:", mIRSend.SendPronto(x, x.Length, False))

NOW I am sure this is properly formatted Pronto Code.

The line in the library that is sending me back the -2 is in IRremoteESP8266.cpp
B4X:
  // We only know how to deal with 'raw' pronto codes types. Reject all others.
  if (data[kProntoTypeOffset] != 0) return -2;                   <----------- this is the bad boy.  Value is Zero and it doesn't like it

The first value (kProntoTypeOffset = 0) is Zero. So I was confused to what was going on so I changed the line in the program to return what it was seeing

B4X:
  // We only know how to deal with 'raw' pronto codes types. Reject all others.
  if (data[kProntoTypeOffset] != 0) return data[kProntoTypeOffset];  //-2;

And it returned Zero. Which really confused me (and that is not hard to do lately) so I thought that maybe I was pointing to the wrong place so I
I change my Pronto String about to get rid of the first 0x0000 and have the 0x007e as the first entry

B4X:
Dim x() As UInt = Array As UInt(0x007e, 0x0022, 0x0000, 0x000a, 0x0046, 0x000a, 0x0046, 0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e,  _
                                0x000a, 0x001e, 0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e,  _
                                0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x036a, 0x000a, 0x0046, 0x000a, 0x0046,  _
                                0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e,  _
                                0x000a, 0x0046, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e, 0x000a, 0x001e,  _
                                0x0009, 0x0000)
                             
            Log("SendPronto:", mIRSend.SendPronto(x, x.Length, False))

After changing the first grouping to 0x007e or 126 and the routine then returned to me a 126 (0x7e). (Which it should the value as not zero - just what I figured should happen)


But when the first entry was zero it still returned -2 (or now the value)

I AM SURE I just need another pair of eyes here. Something I am missing

BobVal

PS: Happy Easter everyone
 

Attachments

  • IRControl.zip
    49.5 KB · Views: 169
Last edited:

OliverA

Expert
Licensed User
Longtime User
Could you post the modified code?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
I AM SURE I just need another pair of eyes here. Something I am missing
Sorry, but my eyes seem to be not enough. No clue what you (nor I) are missing...
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Johan: Thanks for the direction pointing. After getting the DSTV code to work in my code it lead me to understand what was wrong.

I was passing a Array of UInt to the C code which was looking for an Array of Unsigned Int.
Turns out our UInt is smaller (short) then an unsigned int (same as B4R ULong). Changing my array from UInt to ULong and everything seems to work fine.

Not sure if I should change the C code to look for an Array of Unsigned Short Int's (which would be the same as B4R UInt).
Pronto code values never need more then a short.

I do get the right return code 99 but unable to verify the codes are working because I have a bunch of old IR Leds and of course NO Docs for them and am not sure if I am hooking them up properly. Order some others. But shipping being what it is maybe a week or so.

Thanks for all the help
 
Upvote 0
Top