|
|
@@ -154,6 +154,11 @@ void nbus_slave_unicastToModuleGet(nBus_TypeDef *nbus)
|
|
|
// module memory
|
|
|
nbus->memoryInterface->getId(&nbus->tx_buffer[25]);
|
|
|
nbus->tx_length += 8;
|
|
|
+ // sensor count
|
|
|
+ nBus_sensorCount_t sensor_count = nbus->interface->getSensorCount();
|
|
|
+ nbus->tx_buffer[33] = sensor_count.read_only_count;
|
|
|
+ nbus->tx_buffer[34] = sensor_count.read_write_count;
|
|
|
+ nbus->tx_length += 2;
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
@@ -201,28 +206,18 @@ void nbus_slave_unicastToModuleSet(nBus_TypeDef *nbus)
|
|
|
{
|
|
|
switch (nbus->function_code.function)
|
|
|
{
|
|
|
- case CMD_FIND: {
|
|
|
- if (nbus->rx_buffer[RX_DT] > 1) // if wrong parameter {0, 1}
|
|
|
- {
|
|
|
- setErrorResponse(nbus, ILLEGAL_FUNCTION_PARAM);
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- nbus->tx_buffer[TX_DT] = nbus->interface->find(nbus->rx_buffer[RX_DT]);
|
|
|
- nbus->tx_length += 1;
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
case CMD_STOP: {
|
|
|
nbus->measure_active = MEASURE_STOPPED;
|
|
|
- nbus->interface->stop();
|
|
|
+ nbus->tx_buffer[TX_DT] = nbus->interface->stop();
|
|
|
+ nbus->tx_length++;
|
|
|
nbus->hw_platform->led_off();
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case CMD_START: {
|
|
|
nbus->measure_active = MEASURE_RUNNING;
|
|
|
- nbus->interface->start();
|
|
|
+ nbus->tx_buffer[TX_DT] = nbus->interface->start();
|
|
|
+ nbus->tx_length++;
|
|
|
nbus->hw_platform->led_on();
|
|
|
}
|
|
|
break;
|
|
|
@@ -242,7 +237,9 @@ void nbus_slave_unicastToModuleSet(nBus_TypeDef *nbus)
|
|
|
uint8_t param_id;
|
|
|
uint32_t param_value;
|
|
|
|
|
|
- for (uint8_t i = 0; i < rx_payload; i++)
|
|
|
+ uint8_t i = 0;
|
|
|
+
|
|
|
+ for (; rx_payload > 0; rx_payload -= 5)
|
|
|
{
|
|
|
param_id = nbus->rx_buffer[3 + 5 * i];
|
|
|
param_value = *(int32_t *)&nbus->rx_buffer[4 + 5 * i];
|
|
|
@@ -250,6 +247,7 @@ void nbus_slave_unicastToModuleSet(nBus_TypeDef *nbus)
|
|
|
nbus->tx_buffer[4 + 2 * i] = param_id;
|
|
|
nbus->tx_buffer[5 + 2 * i] = nbus->interface->setParam(0, param_id, param_value);
|
|
|
nbus->tx_length += 2;
|
|
|
+ i++;
|
|
|
}
|
|
|
}
|
|
|
}
|