Beckhoff / ADS

Beckhoff protocol to communicate with TwinCAT devices.
MIT License
502 stars 194 forks source link

Need help with AdsVariable #124

Closed ideasoft-bz closed 3 years ago

ideasoft-bz commented 3 years ago

Hello,

My C++ knowledge is not good enough to decode AdsVariable. In the example

static void readByNameExample(std::ostream& out, const AdsDevice& route) { AdsVariable readVar {route, ".StevPalet"};

out << __FUNCTION__ << "():\n";
for (size_t i = 0; i < 8; ++i) {
    out << "ADS read " << std::hex << (uint32_t)readVar << '\n';
}

}

This example works, but how do I decode return data if my request is for variable type of bool, int, real?

Thank you very much for help

Regards Bojan

Frants1987 commented 3 years ago

Hello Bojan, it should look something like this:

Just make sure the size of the variables is the same in TwinCAT and on your platform. You can find more information on type sizes here. You can assign the value of the variable using the assignement operator: bool value = readVarBool; Hope I could help you.

ideasoft-bz commented 3 years ago

Super, thank you very much.

Regards Boajn