Skip to content
Snippets Groups Projects
Commit 43171396 authored by uvos's avatar uvos
Browse files

fix some minor issues, expose fault flag

parent b0b2c423
No related branches found
No related tags found
No related merge requests found
......@@ -115,8 +115,9 @@ int coincellhell_get_state(struct coincellhell* hell, uint8_t heater, struct hea
int16_t* rampTarget = (int16_t*)(buf+3);
state->enabled = buf[0] & (1 << 0);
state->ready = buf[0] & (1 << 2);
state->ramp = buf[0] & (1 << 3);
state->ready = buf[0] & (1 << 1);
state->ramp = buf[0] & (1 << 2);
state->fault = buf[0] & (1 << 3);
state->setpoint = *setpoint/10.0f;
state->rampTarget = *rampTarget/10.0f;
......@@ -151,8 +152,10 @@ int coincellhell_check_ready(struct coincellhell* hell, bool* ready)
{
*ready = false;
int ret;
while((ret = usbshm_readControlTransferSync(hell->priv, COMMAND_READY, 0, 0, (uint8_t*)ready, 1)) == USBSHM_ERROR_AGAIN)
uint8_t readybits;
while((ret = usbshm_readControlTransferSync(hell->priv, COMMAND_READY, 0, 0, &readybits, 1)) == USBSHM_ERROR_AGAIN)
usleep(100000);
*ready = !(~readybits & 0x0F);
return ret == 1 ? 0 : -1;
}
......
......@@ -54,6 +54,7 @@ struct heater_state
bool enabled;
bool ready;
bool ramp;
bool fault;
uint8_t dacCommand;
float setpoint;
......
......@@ -186,8 +186,9 @@ static int process_commands(char** commands, size_t command_count, struct coince
break;
}
printf("Heater %d:\n\tEnabled: %s\n\tReady: %s\n\tRamp: %s\n\tSet point: %f\n\tDAC command: %d\n",
i, state.enabled ? "True" : "False", state.ready ? "True" : "False", state.ramp ? "True" : "False", state.setpoint, state.dacCommand);
printf("Heater %d:\n\tEnabled: %s\n\tReady: %s\n\tRamp: %s\n\tFault: %s\n\tSet point: %f\n\tDAC command: %d\n",
i, state.enabled ? "True" : "False", state.ready ? "True" : "False", state.ramp ? "True" : "False", state.fault ? "True" : "False",
state.setpoint, state.dacCommand);
float temperature;
ret = coincellhell_get_temperature(hell, i, TEMP_LOCATION_BOTH, &temperature);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment