Skip to content

Commit cc193b2

Browse files
committed
LCM: Bound and clear payloads
1 parent ec37475 commit cc193b2

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

src/lcm.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,25 +194,17 @@ void lcm_light_ctrl_request(LcmData *lcm, unsigned char *cfg, int len) {
194194
return;
195195
}
196196

197+
lcm->payload_size = 0;
197198
int32_t idx = 0;
198199

199200
lcm->brightness = min(cfg[idx++], 100u);
200201
lcm->brightness_idle = min(cfg[idx++], 100u);
201202
lcm->status_brightness = min(cfg[idx++], 100u);
202203

203204
if (len > 3) {
204-
if (lcm->enabled) {
205-
// Copy rest of payload into data for LCM to pull
206-
lcm->payload_size = len - idx;
207-
for (int i = 0; i < lcm->payload_size; i++) {
208-
lcm->payload[i] = cfg[idx + i];
209-
}
210-
} else {
211-
if (len > 5) {
212-
// d->float_conf.led_mode = cfg[idx++];
213-
// d->float_conf.led_mode_idle = cfg[idx++];
214-
// d->float_conf.led_status_mode = cfg[idx++];
215-
}
205+
lcm->payload_size = min(len - idx, MAX_LCM_PAYLOAD_LENGTH);
206+
for (int i = 0; i < lcm->payload_size; i++) {
207+
lcm->payload[i] = cfg[idx + i];
216208
}
217209
}
218210
}

0 commit comments

Comments
 (0)