5 years, 4 months ago.

Error:Undefined symbol mbed::Reply::putData<unsigned short>(T1) (referred from main.cpp.LPC11U24.o).

trying to use AnalogIn over serial rpc. why am getting this error , how to solve it??? i am using LPC11U24

my code:

RPC::add_rpc_class<RpcAnalogIn>();
RpcAnalogIn rpc_ain(p19, "ain");

Question relating to:

Comment on this question

1 Answer

5 years, 4 months ago.

Because mbed::Reply::putData<unsigned short> has not been defined. Change to use an "int" and it should work.

Alternatively, you could define template specializations for the Reply::putData() and Arguments::getArg() methods.

I ran into the same problem with uint16_t (probably the same as your unsigned short), and fixed it this way:

namespace mbed {

template<> uint16_t Arguments::getArg<uint16_t>(void) {
    index++;
    char *pEnd;
    return (uint16_t)(strtol(argv[index], &pEnd, 10) & 0xffff);
}

template<> void Reply::putData<uint16_t>(uint16_t v) {
    separator();
    reply += sprintf(reply, "%u", (unsigned)v);
}

}

Hi ned, Thanks for the answer. I found the same solution few days back. After exploring the code i found the following problem. AnalogIn also returns unsigned integer. In arguments.cpp file there is a reply class which is responsible for returning outputs through the putData template which doesnt have a definition to handle unsigned integer data type. So i added the following same as you have said...

putData template for unsigned integer data type

// put by me to accomodate read_u16() of AnalogIn
template<> void Reply::putData<unsigned short>(unsigned short uint16) {
    separator();
    reply += sprintf(reply, "%u", uint16);
}

And it works... Thanks again...

posted by bhavik gala 09 Jul 2014

You need to log in to post a question