#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

bool get_vals(char* buf, uint8_t* vals, uint8_t count)
{
  buf = strchr(buf, '*');
  for (; count; count--)
  {
    if (buf == NULL)
      return false;             // no success
    *vals++ = atoi(++buf);      // read number after delimiter
    buf = strchr(buf, ',');     // point to next delimiter
  }
  return true;                  // wanted count of numbers read
}

#define COUNT 4

int main( void )
{
  char* input = "*127,255,001,111#";
  uint8_t colors[COUNT];
  while (true)
  {
    get_vals(input, colors, COUNT);
  }
}
