Mateusz Lubecki 2023-07-14 22:37:25 +02:00
rodzic 56d0f440b8
commit 50187cdf20
4 zmienionych plików z 71 dodań i 32 usunięć

Wyświetl plik

@ -38,26 +38,26 @@ extern char did_dummy_data;
ENTRY(0x1503U, gsm_sim800_lac) \
#define DIDS_FLOAT(ENTRY) \
ENTRY(0x2000U, &rte_wx_temperature_average_external_valid, 0x0, 0x0) \
ENTRY(0x2001U, &rte_wx_temperature_internal_valid, 0x0, 0x0) \
ENTRY(0x2002U, &rte_wx_pressure_history[0], &rte_wx_pressure_history[1], &rte_wx_pressure_history[2]) \
ENTRY(0x1505U, &gsm_sim800_signal_level_dbm, 0x0, 0x0) \
ENTRY(0x2000U, rte_wx_temperature_average_external_valid, DID_EMPTY, DID_EMPTY) \
ENTRY(0x2001U, rte_wx_temperature_internal_valid, DID_EMPTY, DID_EMPTY) \
ENTRY(0x2002U, rte_wx_pressure_history[0], rte_wx_pressure_history[1], rte_wx_pressure_history[2]) \
ENTRY(0x1505U, gsm_sim800_signal_level_dbm, DID_EMPTY, DID_EMPTY) \
#define DIDS_NUMERIC(ENTRY) \
ENTRY(0x1000U, &master_time, 0x0, 0x0) \
ENTRY(0x1001U, &rx10m, 0x0, 0x0) \
ENTRY(0x1002U, &tx10m, 0x0, 0x0) \
ENTRY(0x1003U, &digi10m, 0x0, 0x0) \
ENTRY(0x1004U, &digidrop10m, 0x0, 0x0) \
ENTRY(0x1100U, &rte_main_battery_voltage, &rte_main_average_battery_voltage, 0x0) \
ENTRY(0x2003U, &rte_wx_temperature_average_dallas, &rte_wx_temperature_average_pt, &rte_wx_temperature_average_internal) \
ENTRY(0x2004U, &rte_wx_average_winddirection, &rte_wx_average_windspeed, &rte_wx_max_windspeed) \
ENTRY(0x2005U, &rte_wx_windspeed[0], &rte_wx_windspeed[1], &rte_wx_windspeed[2]) \
ENTRY(0x2006U, &rte_wx_winddirection[0], &rte_wx_winddirection[1], &rte_wx_winddirection[2]) \
ENTRY(0x2007U, &rte_wx_humidity, 0x0, 0x0) \
ENTRY(0x2008U, &rte_wx_humidity, 0x0, 0x0) \
ENTRY(0x1504U, &gsm_sim800_signal_level_dbm, 0x0, 0x0) \
ENTRY(0xFFFFU, &did_dummy_data, &did_dummy_data, &did_dummy_data)
ENTRY(0x1000U, master_time, DID_EMPTY, DID_EMPTY) \
ENTRY(0x1001U, rx10m, DID_EMPTY, DID_EMPTY) \
ENTRY(0x1002U, tx10m, DID_EMPTY, DID_EMPTY) \
ENTRY(0x1003U, digi10m, DID_EMPTY, DID_EMPTY) \
ENTRY(0x1004U, digidrop10m, DID_EMPTY, DID_EMPTY) \
ENTRY(0x1100U, rte_main_battery_voltage, rte_main_average_battery_voltage, DID_EMPTY) \
ENTRY(0x2003U, rte_wx_temperature_average_dallas, rte_wx_temperature_average_pt, rte_wx_temperature_average_internal) \
ENTRY(0x2004U, rte_wx_average_winddirection, rte_wx_average_windspeed, rte_wx_max_windspeed) \
ENTRY(0x2005U, rte_wx_windspeed[0], rte_wx_windspeed[1], rte_wx_windspeed[2]) \
ENTRY(0x2006U, rte_wx_winddirection[0], rte_wx_winddirection[1], rte_wx_winddirection[2]) \
ENTRY(0x2007U, rte_wx_humidity, DID_EMPTY, DID_EMPTY) \
ENTRY(0x2008U, rte_wx_humidity, DID_EMPTY, DID_EMPTY) \
ENTRY(0x1504U, gsm_sim800_signal_level_dbm, DID_EMPTY, DID_EMPTY) \
ENTRY(0xFFFFU, did_dummy_data, did_dummy_data, did_dummy_data)
#endif
//!< Definition of all DIDs with theirs source data for PARATNC platform

Wyświetl plik

@ -8,6 +8,8 @@
#ifndef KISS_XMACRO_HELPERS_H_
#define KISS_XMACRO_HELPERS_H_
#define DID_EMPTY did_dummy_data
/**
* This macro is used to define DIDs which return integer values
@ -15,11 +17,11 @@
#define DID_NUMERIC_DEFINITION_EXPANDER(id, first_data_pointer, second_data_pointer, third_data_pointer) \
{ \
.identifier = id, \
.first_data = (void*)first_data_pointer, \
.first_data = (void*)&first_data_pointer, \
.first_data_size = sizeof(first_data_pointer), \
.second_data = (void*)second_data_pointer, \
.second_data = (void*)&second_data_pointer, \
.second_data_size = sizeof(second_data_pointer), \
.third_data = (void*)third_data_pointer, \
.third_data = (void*)&third_data_pointer, \
.third_data_size = sizeof(third_data_pointer) \
},
@ -30,11 +32,11 @@
#define DID_NUMERIC_FLOAT_DEFINITION_EXPANDER(id, first_data_pointer, second_data_pointer, third_data_pointer) \
{ \
.identifier = id, \
.first_data = (void*)first_data_pointer, \
.first_data = (void*)&first_data_pointer, \
.first_data_size = 0, \
.second_data = (void*)second_data_pointer, \
.second_data = (void*)&second_data_pointer, \
.second_data_size = 0, \
.third_data = (void*)third_data_pointer, \
.third_data = (void*)&third_data_pointer, \
.third_data_size = 0 \
},

Wyświetl plik

@ -230,7 +230,7 @@ int32_t kiss_callback_read_did(uint8_t* input_frame_from_host, uint16_t input_le
uint16_t did = *(input_frame_from_host + 2) | (*(input_frame_from_host + 3) << 8);
// construct DID response to an output buffer
const uint8_t response_size = kiss_did_response(did, response_buffer + 4, buffer_size - 4);
const uint8_t response_size = kiss_did_response(did, response_buffer + 4, buffer_size - 5);
// check if DID has been found and everyting is OK with it.
if (response_size > 0) {

Wyświetl plik

@ -62,13 +62,13 @@ static uint8_t kiss_did_how_much_data(kiss_did_numeric_definition_t * definition
int out = 0;
if (definition != 0) {
if (definition->first_data != 0x00) {
if (definition->first_data != &DID_EMPTY) {
out++;
if (definition->second_data != 0x00) {
if (definition->second_data != &DID_EMPTY) {
out++;
if (definition->third_data != 0x00) {
if (definition->third_data != &DID_EMPTY) {
out++;
}
}
@ -78,6 +78,21 @@ static uint8_t kiss_did_how_much_data(kiss_did_numeric_definition_t * definition
return out;
}
/**
* Checks if this DID
* @param definition
* @return
*/
static int kiss_did_validate_is_float(kiss_did_numeric_definition_t * definition) {
int out = 0;
if (definition != 0) {
}
return out;
}
/**
* Check if this DID return string data
* @param definition
@ -191,8 +206,10 @@ static int kiss_did_validate(kiss_did_numeric_definition_t * definition, uint8_t
/**
* Creates a response for DID request into specified buffer. Please take into account
* that this function cannot use full size of this buffer. The exact content of the
* response is: FEND, NONSTANDARD, KISS_READ_DID_RESP, DID LSB, DID MSB, data, FEND.
* So in practice payload data may use only buffer_ln - 6 bytes of data.
* response is: FEND, NONSTANDARD, RESPONSE_LN, KISS_READ_DID_RESP, DID LSB, DID MSB,
* data, FEND.
* So in practice payload data may use only buffer_ln - 7 bytes of data. By default
* an output buffer used to return a response has 20 bytes in size
*
* @param identifier
* @param output_buffer pointer to buffer where response will be generated into
@ -206,6 +223,26 @@ uint8_t kiss_did_response(uint16_t identifier, uint8_t * output_buffer, uint16_t
// iterator to go through DID definition
int i = 0;
/**
* Explanation how size_byte works. DID can return three kinds of data:
* a string, integer data (one, two or three) with different width,
* float (also one, two or three). size_byte is used to distinguish
* between these three formats. It works like that
*
* 0y - If most significant nibble is set to zero, size_byte will
* signalize string DID as ASCII characters from basic ASIC
* table are from range 0 to 127
* 10 - If most significant nibble is set to zero AND less significant
* nibble is set to zero this DID returns integer data. In such
* case three groups of two bits controls a size of data according
* to 'kiss_did_sizeof_to_sizebyte_mapping'. If a group of two bits
* is set to 0 it means that DID consist less than 3 variables
* 11 - This means that a DID return float data. One did cannot mix
* integer and floating point data and float has always 32 bit wide.
* The rest of size_bute doesn't specify any size. Less significant
* part consist number how many variables are returned.
*/
// first byte of a DID response which defines size of each field
uint8_t size_byte = 0u;
@ -247,10 +284,10 @@ uint8_t kiss_did_response(uint16_t identifier, uint8_t * output_buffer, uint16_t
size_byte |= kiss_did_sizeof_to_sizebyte_mapping[found.first_data_size];
// append a size of second data source
size_byte |= (kiss_did_sizeof_to_sizebyte_mapping[found.first_data_size] << 2);
size_byte |= (kiss_did_sizeof_to_sizebyte_mapping[found.second_data_size] << 2);
// append a size of third data source
size_byte |= (kiss_did_sizeof_to_sizebyte_mapping[found.first_data_size] << 4);
size_byte |= (kiss_did_sizeof_to_sizebyte_mapping[found.third_data_size] << 4);
output_buffer[0] = size_byte;