9 static int find_mode_index(
const char *buffer,
const int buffer_size,
int value_index);
13 return c !=
' ' && c !=
'\r' && c !=
'\n';
19 bool space_found =
false;
20 bool found_important_symbol =
false;
21 for (
int i = 0; i < buffer_size && !found_important_symbol; ++i)
27 else if (buffer[i] !=
'\r' && buffer[i] !=
'\n')
29 found_important_symbol =
true;
42 for (
int i = starting_index; i < buffer_size && -1 == rn_index; ++i)
44 if (
'\r' == buffer[i] && i + 1 < buffer_size &&
'\n' == buffer[i + 1])
53 new_buffer_size = buffer_size - rn_index - 1;
54 for (
int i = 0; i < new_buffer_size; ++i)
56 buffer[i] = buffer[i + rn_index + 1];
61 new_buffer_size = buffer_size;
64 return new_buffer_size;
67 int find_mode_index(
char const *
const buffer,
int const buffer_size,
int const value_index)
69 int mode_index = value_index;
74 while (mode_index < buffer_size && buffer[mode_index] ==
' ')
83 bool parser_success =
false;
85 bool is_data_valid =
false;
89 if (-1 != value_index)
91 value =
static_cast<float>(atof(&buffer[value_index]));
95 if (mode_index < buffer_size)
97 is_data_valid =
'1' == buffer[mode_index];
98 parser_success =
'1' == buffer[mode_index] ||
'0' == buffer[mode_index];
103 return ParseDsp3000Data(parser_success, new_buffer_size, value, is_data_valid);
static bool is_important_symbol(char const c)
static int find_value_index(const char *buffer, const int buffer_size)
static int find_mode_index(const char *buffer, const int buffer_size, int value_index)
Copyright Autonomous Solutions Inc. 2016.
ParseDsp3000Data parse_dsp3000(char *const buffer, int const buffer_size)
static int trim_buffer_up_to_rn(char *buffer, int buffer_size, int starting_index=0)