Example
The following is an example of how the communication should be executed.
The packets will be in JSON for readability, but should be in the common_com_lib packets in practice.
- Send an
ENTERcommand withC_EARTH_BOND_MEASUREMENT_RPEmeasurement.
STM -> nRF1
{
"items": [
{
"key": "C_G_EVENT_ENTER",
"value": "C_EARTH_BOND_MEASUREMENT_RPE"
}
]
}
- The
nRFshould start sending back currentMFT's settings, preferrably when their value has changed.
nRF -> STM2
{
"items": [
{
"key": "C_G_FUNC_SETTINGS_GLOBAL"
},
{
"key": "C_SETTINGS_GLOBAL_SETT_MFT_ROTARY",
"value": "C_SETTINGS_GLOBAL_SETT_VAL_MFT_ROTARY_CONTINUITY"
},
{
"key": "C_SETTINGS_GLOBAL_SETT_MFT_F1",
"value": "C_SETTINGS_GLOBAL_SETT_VAL_MFT_F1_LN"
},
{
"key": "C_SETTINGS_GLOBAL_SETT_MFT_F2",
"value": "C_SETTINGS_GLOBAL_SETT_VAL_MFT_F2_ZEROED"
},
{
"key": "C_SETTINGS_GLOBAL_SETT_MFT_F3",
"value": "C_SETTINGS_GLOBAL_SETT_VAL_MFT_F3_PRETEST_OHM_PLUS_MINUS"
},
{
"key": "C_SETTINGS_GLOBAL_SETT_MFT_F4",
"value": "C_SETTINGS_GLOBAL_SETT_VAL_MFT_F4_MA250"
}
]
}
- When the measurement on
STMis started, theC_G_EVENT_STARTwill be sent.
STM -> nRF3
{
"items": [
{
"key": "C_G_EVENT_START",
"value": "C_EARTH_BOND_MEASUREMENT_RPE"
}
]
}
- The
nRFshould start sending back results when they're available, possibly waiting for the user to start the measurement.
nRF -> STM4
{
"items": [
{
"key": "C_EARTH_BOND_MEASUREMENT_RPE"
},
{
"key": "C_EARTH_BOND_RES_RPE_EARTH_BOND",
"value": 0.25
}
]
}
- The
STMstops the measurement.
STM -> nRF5
{
"items": [
{
"key": "C_G_EVENT_STOP",
"value": null,
}
]
}
- The
STMexits the measurement.
STM -> nRF6
{
"items": [
{
"key": "C_G_EVENT_EXIT",
"value": null,
}
]
}
Packets templates in C/C++
To create the packet, the following boilerplate can be used:
Enter packet
MSG_CREATE(msg);
MSG_APPEND(msg, C_G_EVENT_ENTER, C_EARTH_BOND_MEASUREMENT_RPE);
MSG_SEND(&comm, msg);
Settings packet
MSG_CREATE(msg);
MSG_APPEND(msg, C_G_FUNC_SETTINGS_GLOBAL);
MSG_APPEND(msg, C_SETTINGS_GLOBAL_SETT_MFT_ROTARY, C_SETTINGS_GLOBAL_SETT_VAL_ROTARY_INSULATION);
MSG_APPEND(msg, C_SETTINGS_GLOBAL_SETT_MFT_F1, C_SETTINGS_GLOBAL_SETT_VAL_MFT_F1_LN);
MSG_APPEND(msg, C_SETTINGS_GLOBAL_SETT_MFT_F2, C_SETTINGS_GLOBAL_SETT_VAL_MFT_F2_ZEROED);
MSG_APPEND(msg, C_SETTINGS_GLOBAL_SETT_MFT_F3, C_SETTINGS_GLOBAL_SETT_VAL_MFT_F3_PRETEST_OHM_PLUS_MINUS);
MSG_APPEND(msg, C_SETTINGS_GLOBAL_SETT_MFT_F4, C_SETTINGS_GLOBAL_SETT_VAL_MFT_F4_MA250);
MSG_SEND(&comm, msg);
Start packet
MSG_CREATE(msg);
MSG_APPEND(msg, C_G_EVENT_START, C_EARTH_BOND_MEASUREMENT_RPE);
MSG_SEND(&comm, msg);
Result packet
MSG_CREATE(msg);
MSG_APPEND(msg, C_EARTH_BOND_MEASUREMENT_RPE);
MSG_APPEND(msg, C_EARTH_BOND_RES_RPE_EARTH_BOND, 0.25);
MSG_SEND(&comm, msg);
Stop packet
MSG_CREATE(msg);
MSG_APPEND(msg, C_G_EVENT_STOP);
MSG_SEND(&comm, msg);
Exit packet
MSG_CREATE(msg);
MSG_APPEND(msg, C_G_EVENT_EXIT);
MSG_SEND(&comm, msg);