|
|
@@ -32,7 +32,7 @@ void test_Controller_SetCurrent()
|
|
|
|
|
|
controller_SetCurrent(0x48, 0, current);
|
|
|
//Debug
|
|
|
- printf("Mock command: 0x%02X\n", tx_packet.txBuffer[0]);
|
|
|
+ printf("Mock command SET: 0x%02X\n", tx_packet.txBuffer[0]);
|
|
|
printf("Mock slot_id: 0x%02X\n", tx_packet.txBuffer[1]);
|
|
|
printf("Mock current: 0x%02X\n", tx_packet.txBuffer[2]);
|
|
|
printf("Mock current: 0x%02X\n", tx_packet.txBuffer[3]);
|
|
|
@@ -40,8 +40,9 @@ void test_Controller_SetCurrent()
|
|
|
//assert() checks if the variable is true or false, if False the program gets aborted and a diagnostic message is printed
|
|
|
assert(tx_packet.txBuffer[0] == CMD_SET_CURRENT);
|
|
|
assert(tx_packet.txBuffer[1] == 0);
|
|
|
- assert(tx_packet.txBuffer[2] == 0x18);
|
|
|
- assert(tx_packet.txBuffer[3] == 0xFC);
|
|
|
+ //Current is sent in two bytes, as Little Endian format
|
|
|
+ assert(tx_packet.txBuffer[2] == (current & 0xFF)); // LSB
|
|
|
+ assert(tx_packet.txBuffer[3] == ((current >> 8) & 0xFF)); // MSB
|
|
|
assert(tx_packet.txLen == 4); // 1 byte for command + 1 byte for slot_id + 1 byte for current
|
|
|
printf("[TEST] Set Current: Passed\n");
|
|
|
}
|
|
|
@@ -53,7 +54,6 @@ void test_Controller_GetBatteryMeasurement()
|
|
|
measurement.voltage = 350; // Example voltage
|
|
|
measurement.current = 10; // Example current
|
|
|
measurement.temperature = 25; // Example temperature
|
|
|
-
|
|
|
// Check if the function returns success
|
|
|
rx_packet.rxBuffer[0] = measurement.voltage & 0xFF; // Voltage LSB
|
|
|
rx_packet.rxBuffer[1] = (measurement.voltage >> 8) & 0xFF; // Voltage MSB
|
|
|
@@ -66,7 +66,8 @@ void test_Controller_GetBatteryMeasurement()
|
|
|
// Call the function to get battery measurement
|
|
|
bool result= controller_GetBatteryMeasurement(0x48, 0, &measurement);
|
|
|
|
|
|
-
|
|
|
+ printf("Mock command GET: 0x%02X\n", tx_packet.txBuffer[0]);
|
|
|
+
|
|
|
assert(result == true);
|
|
|
assert(measurement.voltage == 350);
|
|
|
assert(measurement.current == 10);
|