diff --git a/coincellhell.c b/coincellhell.c index c59eb0b70eba137005b1c92eefd9ab2e42e6b7c8..ab45f64cc3b3a2baaecf880381d7c872873184c5 100644 --- a/coincellhell.c +++ b/coincellhell.c @@ -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; } diff --git a/coincellhell.h b/coincellhell.h index b0a490ac1a2003beda121b6f5daffb7a017d9868..061ab157ed4fb01d295abfad80c5b308ac6791f2 100644 --- a/coincellhell.h +++ b/coincellhell.h @@ -54,6 +54,7 @@ struct heater_state bool enabled; bool ready; bool ramp; + bool fault; uint8_t dacCommand; float setpoint; diff --git a/main.c b/main.c index 09c865026ee54998afc959de53a68e7c638de93a..a5d41f2b42bb03378accb078da95a84fc11631eb 100644 --- a/main.c +++ b/main.c @@ -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);