integration complete

This commit is contained in:
2020-09-30 22:00:37 +02:00
parent 84aefca20e
commit e64ed203e9
4 changed files with 81 additions and 99 deletions

View File

@ -44,15 +44,14 @@ ReturnValue_t MGMHandlerLIS3MDL::setupMGM() {
}
ReturnValue_t MGMHandlerLIS3MDL::buildNormalDeviceCommand(
DeviceCommandId_t *id) { //defines CommandID of MGM in normal operation and build command from command
DeviceCommandId_t *id) {
//defines CommandID of MGM in normal operation and build command from command
*id = READALL_MGM;
return buildCommandFromCommand(*id, NULL, 0);
}
ReturnValue_t MGMHandlerLIS3MDL::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) {
lastSentCommand = deviceCommand;
switch(deviceCommand) {
@ -80,7 +79,7 @@ ReturnValue_t MGMHandlerLIS3MDL::buildCommandFromCommand(
return setOperatingMode(commandData, commandDataLen);
}
default:
lastSentCommand = NO_COMMAND;
lastSentCommand = DeviceHandlerIF::NO_COMMAND;
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
}
@ -110,7 +109,7 @@ ReturnValue_t MGMHandlerLIS3MDL::buildTransitionDeviceCommand(
}
ReturnValue_t MGMHandlerLIS3MDL::scanForReply(const uint8_t *start,
uint32_t len, DeviceCommandId_t *foundId, uint32_t *foundLen) {
size_t len, DeviceCommandId_t *foundId, size_t *foundLen) {
*foundLen = len;
if (len == TOTAL_NR_OF_ADRESSES + 1) {
*foundLen = len;
@ -149,7 +148,6 @@ ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id,
break;
}
case READALL_MGM: {
//DataSet mySet;
registers[0] = *(packet + 33);
registers[1] = *(packet + 34);
@ -183,18 +181,6 @@ ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id,
float z_value = (float) z_value_raw * sensitivity;
float temp_value = 25.0 + (((float) temp_value_raw) / 8.0);
// PoolVector<float, 3> mgm_measurement(mgmMagneticPoolId, &mySet,
// PoolVariableIF::VAR_WRITE);
// PoolVariable<float> mgm_temperature(mgmTempPoolId, &mySet,
// PoolVariableIF::VAR_WRITE);
// mgm_measurement[0] = x_value;
// mgm_measurement[1] = y_value;
// mgm_measurement[2] = z_value;
//
// mgm_temperature = temp_value;
// handleDeviceTM(&mySet, id);
break;
}
@ -339,19 +325,21 @@ ReturnValue_t MGMHandlerLIS3MDL::setOperatingMode(const uint8_t *commandData,
}
void MGMHandlerLIS3MDL::fillCommandAndReplyMap() {
/*Actually SPI answers directly, but as commanding ArduinoBoard the communication could be delayed
* SPI always has to be triggered, so there could be no periodic answer of the device, the device has
* to asked with a command, so periodic is zero.
/*
* Regarding ArduinoBoard:
* Actually SPI answers directly, but as commanding ArduinoBoard the
* communication could be delayed
* SPI always has to be triggered, so there could be no periodic answer of
* the device, the device has to asked with a command, so periodic is zero.
*
* We dont read single registers, we just expect special
* reply from he Readall_MGM
*/
insertInCommandAndReplyMap(READALL_MGM, 1, 0);
insertInCommandAndReplyMap(SETUP_MGM, 1, 0);
insertInCommandAndReplyMap(IDENTIFY_DEVICE, 1, 0);
insertInCommandAndReplyMap(TEMP_SENSOR_ENABLE, 1, 0);
insertInCommandAndReplyMap(ACCURACY_OP_MODE_SET, 1, 0);
insertInCommandAndReplyMap(READALL_MGM, 1);
insertInCommandAndReplyMap(SETUP_MGM, 1);
insertInCommandAndReplyMap(IDENTIFY_DEVICE, 1);
insertInCommandAndReplyMap(TEMP_SENSOR_ENABLE, 1);
insertInCommandAndReplyMap(ACCURACY_OP_MODE_SET, 1);
}
ReturnValue_t MGMHandlerLIS3MDL::prepareRegisterWrite() {
@ -369,20 +357,7 @@ ReturnValue_t MGMHandlerLIS3MDL::prepareRegisterWrite() {
}
void MGMHandlerLIS3MDL::setNormalDatapoolEntriesInvalid() {
// DataSet mySet;
// PoolVector<float, 3> mgmMeasurements(mgmMagneticPoolId, &mySet,
// PoolVariableIF::VAR_WRITE);
// PoolVariable<float> mgmTemperature(mgmTempPoolId, &mySet,
// PoolVariableIF::VAR_WRITE);
//
// mgmMeasurements[0] = 0;
// mgmMeasurements[1] = 0;
// mgmMeasurements[2] = 0;
//
// mgmTemperature = 999;
// mySet.commit(PoolVariableIF::INVALID);
// TODO: use new distributed datapools here.
}
void MGMHandlerLIS3MDL::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {