Added device identification register
This commit is contained in:
parent
2a31f51494
commit
990e1ae908
@ -92,8 +92,8 @@ enum
|
|||||||
REGISTER_NUM_TYPICAL_PARTICLE_SIZE = 30027, /* nm */
|
REGISTER_NUM_TYPICAL_PARTICLE_SIZE = 30027, /* nm */
|
||||||
REGISTER_NUM_T_SCD4x = 30028, /* deg C */
|
REGISTER_NUM_T_SCD4x = 30028, /* deg C */
|
||||||
REGISTER_NUM_T_SCD4x_F = 30029, /* deg F */
|
REGISTER_NUM_T_SCD4x_F = 30029, /* deg F */
|
||||||
REGISTER_NUM_RH_SCD4x = 30030 /* % */
|
REGISTER_NUM_RH_SCD4x = 30030, /* % */
|
||||||
|
REGISTER_NUM_DEVICE_IDENTIFIER = 30100
|
||||||
/* VOC Index has initial blackout beriod, when the data is not ready. VOC index is 0 during this period */
|
/* VOC Index has initial blackout beriod, when the data is not ready. VOC index is 0 during this period */
|
||||||
} data_registers_numbers;
|
} data_registers_numbers;
|
||||||
|
|
||||||
@ -112,13 +112,20 @@ enum
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
REGISTER_NUM_VENDOR_NAME = 30010,
|
REGISTER_NUM_VENDOR_NAME = 30050,
|
||||||
REGISTER_NUM_PRODUCT_CODE = 30011,
|
REGISTER_NUM_PRODUCT_CODE = 30051,
|
||||||
REGISTER_NUM_REVISION = 30012,
|
REGISTER_NUM_REVISION = 30052,
|
||||||
REGISTER_NUM_PRODUCT_NAME = 30013,
|
REGISTER_NUM_PRODUCT_NAME = 30033,
|
||||||
REGISTER_NUM_SERIAL_NUMBER = 30014
|
REGISTER_NUM_SERIAL_NUMBER = 30054,
|
||||||
} identification_registers_numbers;
|
} identification_registers_numbers;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Device type specification: TODO improve and move to external library
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEVICE_IDENTIFIER 0xbeef
|
||||||
|
const uint16_t device_identifier = DEVICE_IDENTIFIER;
|
||||||
|
|
||||||
/* Variables to store the measured data */
|
/* Variables to store the measured data */
|
||||||
int16_t T_SCD4x, T_SHT4x, TF_SCD4x, TF_SHT4x;
|
int16_t T_SCD4x, T_SHT4x, TF_SCD4x, TF_SHT4x;
|
||||||
uint16_t CO2, RH_SCD4x, RH_SHT4x;
|
uint16_t CO2, RH_SCD4x, RH_SHT4x;
|
||||||
@ -944,6 +951,8 @@ int8_t modbus_slave_callback(modbus_transaction_t *transaction)
|
|||||||
case REGISTER_NUM_RH_SCD4x:
|
case REGISTER_NUM_RH_SCD4x:
|
||||||
transaction->input_registers[i] = (uint16_t)RH_SCD4x;
|
transaction->input_registers[i] = (uint16_t)RH_SCD4x;
|
||||||
break;
|
break;
|
||||||
|
case REGISTER_NUM_DEVICE_IDENTIFIER:
|
||||||
|
transaction->input_registers[i] = (uint16_t)device_identifier;
|
||||||
default:
|
default:
|
||||||
return MODBUS_ERROR_FUNCTION_NOT_IMPLEMENTED;
|
return MODBUS_ERROR_FUNCTION_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user