|
@@ -20,26 +20,34 @@ void nbus_slave_unicastToSensorGet(nBus_TypeDef *nbus){
|
|
|
case CMD_PARAM:
|
|
case CMD_PARAM:
|
|
|
{
|
|
{
|
|
|
if (nbus->rx_length >= 5){
|
|
if (nbus->rx_length >= 5){
|
|
|
- if (nbus->interface->hasParam(nbus->sensorInfo.address, (nBus_param_t)nbus->tx_buffer[3]) == 0) {
|
|
|
|
|
|
|
+ if (nbus->interface->hasParam(nbus->sensorInfo.address, (nBus_param_t)nbus->rx_buffer[3]) == 0) {
|
|
|
setErrorResponse(nbus, PARAM_NOT_IMPLEMENTED);
|
|
setErrorResponse(nbus, PARAM_NOT_IMPLEMENTED);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- nbus->tx_buffer[4] = nbus->tx_buffer[3];
|
|
|
|
|
- nbus->tx_buffer[5] = nbus->interface->getParam(nbus->sensorInfo.address, (nBus_param_t)nbus->tx_buffer[3]);
|
|
|
|
|
- nbus->tx_length += 2;
|
|
|
|
|
|
|
+ nbus->tx_buffer[4] = nbus->rx_buffer[3];
|
|
|
|
|
+ int32_t param_value = nbus->interface->getParam(nbus->sensorInfo.address, (nBus_param_t)nbus->rx_buffer[3]);
|
|
|
|
|
+ nbus->tx_buffer[5] = (uint8_t)(param_value & 0xFF);
|
|
|
|
|
+ nbus->tx_buffer[6] = (uint8_t)((param_value>>8) & 0xFF);
|
|
|
|
|
+ nbus->tx_buffer[7] = (uint8_t)((param_value>>16) & 0xFF);
|
|
|
|
|
+ nbus->tx_buffer[8] = (uint8_t)((param_value>>24) & 0xFF);
|
|
|
|
|
+ nbus->tx_length += 5;
|
|
|
} else {
|
|
} else {
|
|
|
nBus_param_t* params = nbus_interface_allParams();
|
|
nBus_param_t* params = nbus_interface_allParams();
|
|
|
for(uint8_t i=0; i < nbus_interface_allParamsCount() ; i++){
|
|
for(uint8_t i=0; i < nbus_interface_allParamsCount() ; i++){
|
|
|
- if(nbus->interface->hasParam(i, params[i])){
|
|
|
|
|
- nbus->tx_buffer[4+2*i] = params[i];
|
|
|
|
|
- nbus->tx_buffer[5+2*i] = nbus->interface->getParam(i, params[i]);
|
|
|
|
|
- nbus->tx_length += 2;
|
|
|
|
|
|
|
+ if(nbus->interface->hasParam(nbus->sensorInfo.address, params[i])){
|
|
|
|
|
+ int32_t param_value = nbus->interface->getParam(nbus->sensorInfo.address, params[i]);
|
|
|
|
|
+ nbus->tx_buffer[4+5*i] = params[i];
|
|
|
|
|
+ //nbus->tx_buffer[5+2*i] = nbus->interface->getParam(nbus->sensorInfo.address, params[i]);
|
|
|
|
|
+ nbus->tx_buffer[5+5*i] = (uint8_t)(param_value & 0xFF);
|
|
|
|
|
+ nbus->tx_buffer[6+5*i] = (uint8_t)((param_value>>8) & 0xFF);
|
|
|
|
|
+ nbus->tx_buffer[7+5*i] = (uint8_t)((param_value>>16) & 0xFF);
|
|
|
|
|
+ nbus->tx_buffer[8+5*i] = (uint8_t)((param_value>>24) & 0xFF);
|
|
|
|
|
+
|
|
|
|
|
+ nbus->tx_length += 5;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- // alebo
|
|
|
|
|
- nbus->memoryInterface->getParam(nbus->sensorInfo.address, 0x05);
|
|
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
@@ -71,11 +79,17 @@ void nbus_slave_unicastToSensorSet(nBus_TypeDef *nbus){
|
|
|
switch(nbus->function_code.function){
|
|
switch(nbus->function_code.function){
|
|
|
case CMD_PARAM:
|
|
case CMD_PARAM:
|
|
|
{
|
|
{
|
|
|
- nBus_param_t p = nbus->interface->setParam(nbus->sensorInfo.address, (nBus_param_t)nbus->tx_buffer[3], nbus->tx_buffer[4]);
|
|
|
|
|
- if (p == PARAM_NONE) {
|
|
|
|
|
|
|
+ if (!nbus->interface->hasParam(nbus->sensorInfo.address, (nBus_param_t)nbus->rx_buffer[3])){
|
|
|
setErrorResponse(nbus, PARAM_NOT_IMPLEMENTED);
|
|
setErrorResponse(nbus, PARAM_NOT_IMPLEMENTED);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ int32_t param_value = nbus->rx_buffer[4] | nbus->rx_buffer[5]<<8 | nbus->rx_buffer[6]<<16 << nbus->rx_buffer[7]<<23;
|
|
|
|
|
+ nBus_param_t p = nbus->interface->setParam(nbus->sensorInfo.address, (nBus_param_t)nbus->rx_buffer[3], param_value);
|
|
|
|
|
+ if (p == PARAM_NONE) {
|
|
|
|
|
+ setErrorResponse(nbus, ILLEGAL_DATA_VALUE);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
nbus->tx_buffer[4] = OK_CODE;
|
|
nbus->tx_buffer[4] = OK_CODE;
|
|
|
nbus->tx_length += 1;
|
|
nbus->tx_length += 1;
|
|
|
}
|
|
}
|
|
@@ -83,8 +97,10 @@ void nbus_slave_unicastToSensorSet(nBus_TypeDef *nbus){
|
|
|
|
|
|
|
|
case CMD_DATA:
|
|
case CMD_DATA:
|
|
|
{
|
|
{
|
|
|
- nbus->interface->setData(&nbus->rx_buffer[3]);
|
|
|
|
|
- nbus->tx_buffer[4] = OK_CODE;
|
|
|
|
|
|
|
+ nbus->tx_buffer[4] = nbus->interface->setData(&nbus->rx_buffer[3]);
|
|
|
|
|
+ if (nbus->tx_buffer[4] != OK_CODE){
|
|
|
|
|
+ nbus->function_code.error = 1;
|
|
|
|
|
+ }
|
|
|
nbus->tx_length += 1;
|
|
nbus->tx_length += 1;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|