- Posts: 14
strcmp not working?
- theseankelly
- Topic Author
- Offline
Less
More
07 Aug 2016 04:58 - 07 Aug 2016 04:59 #52524
by theseankelly
strcmp not working? was created by theseankelly
Hey forum -- I'm trying to implement telemetry for the Crazyflie2.0 protocol (cflie). The crazyflie has a notion of a logging table-of-contents which clients are supposed to scan and search for telemetry variable IDs, instead of hard coding an ID.
For each variable, there are two null terminated strings starting with the fifth byte of the packet: A group name, and a variable name. The group name I want is "pm" and the variable is "vbatMV". strcmp isn't working for me here. Here's a few versions of my string checking code:
When I comment out the third if block with the strcmp calls, both the first if and the second if successfully find the variable I'm interested in. However, when I uncomment the third if block, none of the code seems to hit.
Does anyone have experience with strcmp on the f1 processor? I'm testing on a devo7e.
For each variable, there are two null terminated strings starting with the fifth byte of the packet: A group name, and a variable name. The group name I want is "pm" and the variable is "vbatMV". strcmp isn't working for me here. Here's a few versions of my string checking code:
char pm_group_name[] = "pm";
char vbat_var_name[] = "vbatMV";
if (rx_packet[4] == pm_group_name[0] && rx_packet[5] == pm_group_name[1]
&& rx_packet[6] == pm_group_name[2] && rx_packet[7] == vbat_var_name[0]
&& rx_packet[8] == vbat_var_name[1] && rx_packet[9] == vbat_var_name[2]
&& rx_packet[10] == vbat_var_name[3] && rx_packet[11] == vbat_var_name[4]
&& rx_packet[12] == vbat_var_name[5] && rx_packet[13] == vbat_var_name[6]) {
// Found the vbat element - save it for later
vbat_var_id = next_toc_variable;
Telemetry.value[TELEM_DSM_FLOG_FADESB] = 1;
TELEMETRY_SetUpdated(TELEM_DSM_FLOG_FADESB);
}
if (rx_packet[4] == 'p' && rx_packet[5] == 'm'
&& rx_packet[6] == '\0' && rx_packet[7] == 'v'
&& rx_packet[8] == 'b' && rx_packet[9] == 'a'
&& rx_packet[10] == 't' && rx_packet[11] == 'M'
&& rx_packet[12] == 'V' && rx_packet[13] == '\0') {
// Found the vbat element - save it for later
vbat_var_id = next_toc_variable;
Telemetry.value[TELEM_DSM_FLOG_FADESR] = 1;
TELEMETRY_SetUpdated(TELEM_DSM_FLOG_FADESR);
}
if (0 == strcmp((char*) &rx_packet[4], pm_group_name)
&& 0 == strcmp((char*) &rx_packet[4 + strlen(pm_group_name) + 1], vbat_var_name)) {
// Found the vbat element - save it for later
vbat_var_id = next_toc_variable;
Telemetry.value[TELEM_DSM_FLOG_FADESA] = 1;
TELEMETRY_SetUpdated(TELEM_DSM_FLOG_FADESA);
}
When I comment out the third if block with the strcmp calls, both the first if and the second if successfully find the variable I'm interested in. However, when I uncomment the third if block, none of the code seems to hit.
Does anyone have experience with strcmp on the f1 processor? I'm testing on a devo7e.
Last edit: 07 Aug 2016 04:59 by theseankelly.
Please Log in or Create an account to join the conversation.
Time to create page: 0.032 seconds
- Home
- Forum
- Development
- Protocol Development
- strcmp not working?