Pigi_102
Member level 2
Hi all,
I have an arduino sketch code that works well and I'm convertin in c ansi but I'm having a (some) problem.
My input data is a char array like this:
in arduino c I have this code:
and the ret value, out of the loop is 160 ( which is correct ).
I have "translated" in:
but ret value is 255, which obviously is wrong.
What I'm doing wrong ?
Thanks in advance
Pierluigi
I have an arduino sketch code that works well and I'm convertin in c ansi but I'm having a (some) problem.
My input data is a char array like this:
Code:
pkt="10100000"
in arduino c I have this code:
Code:
int ret
for (i = 0; i < 8; i++) {
ret = (ret << 1) ^ ((pkt[i] & B00010000) ? 1 : 0);
}
I have "translated" in:
Code:
for (i = 0; i < 8; i++) {
ret = (ret << 1) ^ ((pkt[i] & 0b00010000) ? 1 : 0);
}
but ret value is 255, which obviously is wrong.
What I'm doing wrong ?
Thanks in advance
Pierluigi
Last edited by a moderator: