C/C++ Question How to handle a pointer to a Byte

Discussion in 'Libraries developers questions' started by kolbe, May 5, 2019.

  1. kolbe

    kolbe Active Member Licensed User

    I'm trying to wrap a pn532 library and not sure how to handle a pointer to a byte. This method is suppose to provide the uid length when called so it needs to stay a pointer.

    The original library method is the following.

    Code:
    bool readPassiveTargetID(uint8_t cardbaudrate, uint8_t * uid, uint8_t * uidLength, uint16_t timeout);
    I call this from the wrapper.

    Code:
    bool B4RPN532::readPassiveTargetID(byte cardbaudrate, ArrayByte* uid, byte &uidLength, UInt timeout) {
            
    return pn->readPassiveTargetID(cardbaudrate,(byte*)uid->data,&uidLength,timeout);
        
    }
    The wrapper header declares this.

    Code:
    bool readPassiveTargetID(byte cardbaudrate, ArrayByte* uid, byte &uidLength, UInt timeout);
    This code actually works but B4Rh2xml.jar doesn't like the reference to uidLength and ignores the variable. If i remove the reference, run B4Rh2xml.jar and then put it back the code work like it is intended.

    What is the correct way of doing this?

    I guess I could just change it to an ArrayByte* but was hoping for something simpler.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    pointer to a byte is an array of bytes.

    There are many methods that work with arrays of bytes. See rWire.WriteTo header and implementation.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice