From 20e24087f11c36a3776fd974954ea12c46083f0d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:09:22 -0400 Subject: [PATCH] Update main.c I2C 1 and 3 and Camera failures --- main.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 93a6e96c..b9af4197 100644 --- a/main.c +++ b/main.c @@ -1294,6 +1294,32 @@ void get_tlm_fox() { voltage[map[MINUS_Y]] = 0.0; printf("-Y Solar SC Simulated Failure!\n"); } + if (failureMode == FAIL_I2C1) { + voltage[map[PLUS_X]] = 0.0; + current[map[PLUS_X]] = 0.0; + voltage[map[PLUS_Y]] = 0.0; + current[map[PLUS_Y]] = 0.0; + voltage[map[BAT]] = 0.0; + current[map[BAT]] = 0.0; + voltage[map[BAT2]] = 0.0; + current[map[BAT2]] = 0.0; + printf("I2C Bus 1 Simulated Failure!\n"); + } + if (failureMode == FAIL_I2C3) { + voltage[map[MINUS_X]] = 0.0; + current[map[MINUS_X]] = 0.0; + voltage[map[MINUS_Y]] = 0.0; + current[map[MINUS_Y]] = 0.0; + voltage[map[MINUS_Z]] = 0.0; + current[map[MINUS_Z]] = 0.0; + voltage[map[PLUS_Z]] = 0.0; + current[map[PLUS_Z]] = 0.0; + printf("I2C Bus 3 Simulated Failure!\n"); + } + if (failureMode == FAIL_CAMERA) { + camera = OFF; + printf("Camera Simulated Failure!\n"); + } if (mode == FSK) id = 7; @@ -1631,9 +1657,18 @@ void get_tlm_fox() { simulated = TRUE; printf("Showing Simulted in FoxTelem\n"); } + int i2c_1, i2c_3; + i2c_1 = i2c_bus1; + i2c_2 = i2c_bus2; + if (failureMode == FAIL_I2C1) { + i2c_1 = FALSE; + } else if (failureMode == FAIL_I2C3) { + i2c_3 = FALSE; + } // int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + +// (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; int status = STEMBoardFailure + SafeMode * 2 + simulated * 4 + PayloadFailure1 * 8 + - (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; + (i2c_bus0 == OFF) * 16 + (i2c_1 == OFF) * 32 + (i2c_3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; encodeA(b, 51 + head_offset, status); encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4);