Skip to content

Commit 3085057

Browse files
committed
wj200: only complain once about "failed to get status"
This change is from Karl Schmidt.
1 parent f90de8e commit 3085057

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/hal/user_comps/wj200_vfd/wj200_vfd.comp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ void userinit(int argc, char **argv)
271271
void user_mainloop(void) {
272272
wj200_status status;
273273
uint16_t calculated_frequency;
274+
bool last_enable_state = FALSE;
274275

275276
while(1) {
276277
FOR_ALL_INSTS() {
@@ -297,10 +298,19 @@ void user_mainloop(void) {
297298
pin won't change until we make it all the way through
298299
the loop.
299300
*/
300-
if(!wj200_getStatus(ctx, &status)) {
301-
print_modbus_error(__comp_inst, "failed to get status");
302-
continue;
303-
}
301+
302+
if(!wj200_getStatus(ctx, &status)) {
303+
/*
304+
Only want to list 'failed to get status' once
305+
any time enable changes - don't spam the output.
306+
A wink is as good as a nod.
307+
*/
308+
if (last_enable_state != enable) {
309+
print_modbus_error(__comp_inst, "failed to get status");
310+
}
311+
last_enable_state = enable;
312+
continue;
313+
}
304314

305315
is_running = status.running;
306316
is_at_speed = status.at_speed;

0 commit comments

Comments
 (0)