Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ mkdir build
cd build
cmake ..
make

./pstop/pstop_test
```
2 changes: 1 addition & 1 deletion pstop_c/pstop/include/pstop/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ typedef struct pstop_machine_t {

void machine_init(pstop_machine_t *machine, pstop_application_t *app, pstop_client_data_t *clients, uint16_t max_clients);

void machine_stop_robot(pstop_machine_t *machine, pstop_client_data_t *client);
void machine_stop_robot(pstop_machine_t *machine);

#endif /* PSTOP_MACHINE_H */
16 changes: 4 additions & 12 deletions pstop_c/pstop/src/pstop/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ handle_unbond_msg(pstop_machine_t *machine, pstop_client_data_t *client, const p

// if this is the last client then stop the robot
if((pstop_client_num_active(&(machine->pstops)) == 0U) || (machine->robot_state.robot_state == ROBOT_STATE_STOPPED)) {
machine_stop_robot(machine, NULL);
machine_stop_robot(machine);
}

return PSTOP_OK;
Expand Down Expand Up @@ -270,8 +270,6 @@ machine_check_heartbeats(pstop_machine_t *machine)
continue;
}

//client->missed_heartbeats_counter++;

// problem! this client hasn't talked to us in a while
// if we're still within the window of missed heartbeats then we're OK

Expand All @@ -284,7 +282,7 @@ machine_check_heartbeats(pstop_machine_t *machine)
}

if(needsStop != 0) {
machine_stop_robot(machine, NULL);
machine_stop_robot(machine);
return PSTOP_MISSED_HEARTBEATS;
}

Expand All @@ -310,17 +308,11 @@ machine_init(pstop_machine_t *machine, pstop_application_t *app, pstop_client_da
}

void
machine_stop_robot(pstop_machine_t *machine, pstop_client_data_t *client)
machine_stop_robot(pstop_machine_t *machine)
{
machine->robot_state.robot_state = ROBOT_STATE_STOPPED;
machine->robot_state.restart_state = ROBOT_RESTART_STATE_NEED_STOP;

if(client != NULL) {
machine->robot_state.client_stop_id = client->local_client_id;
}
else {
machine->robot_state.client_stop_id = 0U;
}
machine->robot_state.client_stop_id = 0U;

machine->application->status_cb(PSTOP_STATUS_STOP);
}
2 changes: 1 addition & 1 deletion pstop_c/pstop/src/pstop/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ validate_message(pstop_machine_t *machine, pstop_client_data_t *client, const ps
// too many lost messages
// clean up this client
*resp = NULL;
machine_stop_robot(machine, NULL);
machine_stop_robot(machine);
return PSTOP_MSG_LOST;
}
}
Expand Down
7 changes: 0 additions & 7 deletions pstop_c/pstop/src/pstop/pstop_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ pstop_client_init(pstop_client_data_t *client)
client->local_client_id = next_client_id++;
}

static
void
pstop_client_copy(pstop_client_data_t *dest, pstop_client_data_t *src)
{
memcpy(dest, src, sizeof(pstop_client_data_t));
}

void
pstop_clients_init(pstop_clients_t *clients)
{
Expand Down
2 changes: 2 additions & 0 deletions pstop_c/pstop/test/src/pstop/machine_timeout_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ test_bond_stop_timeout_2_missed_timeouts(void)

current_time = 222U; // now two missed heartbeats
TEST_ASSERT_EQUAL(PSTOP_MISSED_HEARTBEATS, machine.check_heartbeats_cb(&machine));
TEST_ASSERT_EQUAL(ROBOT_STATE_STOPPED, machine.robot_state.robot_state);
TEST_ASSERT_EQUAL(ROBOT_RESTART_STATE_NEED_STOP, machine.robot_state.restart_state);
}

void
Expand Down
Loading