7 int main(int argc
, char *argv
[]) {
13 printf("Usage: %s <port>\n", argv
[0]);
18 p
= pm3_open(argv
[1]);
20 // Execute the command
21 pm3_console(p
, "hw status", true, true);
23 const char *buf
= pm3_grabbed_output_get(p
);
24 const char *line_start
= buf
;
25 const char *newline_pos
;
26 while ((newline_pos
= strchr(line_start
, '\n')) != NULL
) {
27 // Determine the length of the line
28 size_t line_length
= newline_pos
- line_start
;
30 // Create a temporary buffer to hold the line
31 char line
[line_length
+ 1];
32 strncpy(line
, line_start
, line_length
);
33 line
[line_length
] = '\0'; // Null-terminate the string
35 if (strstr(line
, "ERROR") != NULL
) {
38 if (strstr(line
, "Unique ID") != NULL
) {
42 // Move to the next line
43 line_start
= newline_pos
+ 1;