0

I have this method prototype

bool setMacParam(const char* paramName, const uint8_t* paramValue, uint16_t size)
{
    debugPrint("[setMacParam] "); debugPrint(paramName); debugPrint("= [array]");
this->loraStream->print(STR_CMD_SET);
this->loraStream->print(paramName);

for (uint16_t i = 0; i < size; ++i) {
    this->loraStream->print(static_cast<char>(NIBBLE_TO_HEX_CHAR(HIGH_NIBBLE(paramValue[i]))));
    this->loraStream->print(static_cast<char>(NIBBLE_TO_HEX_CHAR(LOW_NIBBLE(paramValue[i]))));
}

this->loraStream->print(CRLF);

return expectOK();}

I would like to assign my variable devEUI to paramValue, I am doing this call

uint8_t DevEUI2[8] = {  0x00, 0x00, 0x00, 0x00, 0x41, 0x47, 0x30, 0x39 };
setMacParam(STR_DEV_EUI,DevEUI2,8);

However my terminal shows that paramValue is empty

[setMacParam] deveui = [array]

What do I do wrong?

4
  • what is debugPrint ? Commented Apr 6, 2017 at 15:09
  • uint8_t* is often interpreted by the compiler the same as char*, and any attempt to debug it will stop at the first null byte. You need to inspect each element of the array to know what's really in it. Commented Apr 6, 2017 at 15:11
  • 2
    In the above code, there's no debugPrint for the paramValue-array at all.. Commented Apr 6, 2017 at 15:14
  • @Mat that code is this #define debugPrint(...) SerialUSB.print(__VA_ARGS__); Commented Apr 6, 2017 at 15:15

1 Answer 1

1

debugPrint is interpretating your array as a byte array in which each byte is a char; because the first value is 0x00, incidentally is the same value for the '\0' character, that represent the "end of string".

Also the other value will be represented by their ascii representation, which is never the same as the byte value.

The print() of Serial accept some parameter that tell the function to print the ascii representation of the hex, decimal, octal or binary; maybe your SerialUSB support them too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.