Check for 3 bytes somewhere in a 3-12 byte array


hi!

i messages via midi sysex, *sometimes* 3 bytes, , 12 bytes, , inbetween.


i need check 3 bytes, inside byte array nomatter length. 3 bytes check has in order, not matter if bytes 1-3 or 6-9 etc.


my current code is:
code: [select]

if (p[1] == 0xb0 && p[2] == 0x0c && p[3] == 0x0e )

{
}


does know how achieve this?

best regards
soren

like this:
code: (snippet) [select]
int inarray(int *p, int len)
{
  (int = 0; < len-3; i++)
  {
    if (p[i] == 0xb0 && p[i+1] == 0x0c && p[i+2] == 0x0e) return i;
  }
  return -1;
}


Arduino Forum > Using Arduino > Programming Questions > Check for 3 bytes somewhere in a 3-12 byte array


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code