I have a uint8 array which contains the output from a serial port. I'd like to parse the array to look for particular messages - which I thought I'd do using a regex.
I've written a short example which appears to work when I define the array as a character array to begin with (note - I'm using google test to check the output).
This appears to pass or fail as I expect (either changing the 4 to a 5 in EXPECT_EQ or changing the rx regex to "Hello". However if I try doing a similar approach with a uint8 array I getting unusual results. The regex doesn't appear to work.
I was wondering if anyone can explain what I'm doing wrong? Also if there was a more efficient way of applying the regex to the raw data without having to cast or convert to a string?
I think you're getting confused with the use of *.
raw_ptr is a pointer to type uint8_t - hence reinterpret_cast is casting a type of pointer to uint8_t to type pointer to char. OK.
*data_uint8 doesn't do what you're thinking it does. I takes data_uint8 as a pointer and de-references this. This value is then cast to type pointer to char. Uh oh!!