Hi, Mikko!
I try compare two buffers twice.
unsigned char vnd[] = "VND";
gxData vndr; // here byteArr "VND"
unsigned char c = bb_compare(vndr.value.byteArr, vnd, 3); //OK, c==1
c = bb_compare(vndr.value.byteArr, vnd, 3); //Fail, c == 0
This is because if the buffers are equal, position of vndr.byteArr changes to length of comparing.
How to compare buffers multiple times?
Thanks!
Hi, If compare succeeds, the…
Hi,
If compare succeeds, the bb_compare increases the byte array position with the length of compared str;
Try this:
unsigned char c = bb_compare(vndr.value.byteArr, vnd, 3); //OK, c==1
if (c)
{
vndr.value.byteArr-position -= 3;
}
c = bb_compare(vndr.value.byteArr, vnd, 3);
BR,
Mikko
Thanks for you reply. It's…
Thanks for you reply.
It's work.
But i think comparing should not change internal state of buffers.
Also i try this:
if(vndr.value.vt == DLMS_DATA_TYPE_OCTET_STRING)
{
bool res = (memcmp(vndr.value.byteArr->data, vnd, sizeof(vnd)-1) == 0);
}
Hi, It's designed this way…
Hi,
It's designed this way and used in many projects, so it can't be changed.
BR,
Mikko