|
|
@@ -10,36 +10,32 @@
|
|
|
|
|
|
#if MODULE_MASTER == 1
|
|
|
|
|
|
+inline void setErrorResponse(nBus_TypeDef *nbus, uint8_t code)
|
|
|
+{
|
|
|
+ nbus->function_code.error = 1;
|
|
|
+ nbus->tx_buffer[4] = code;
|
|
|
+ nbus->tx_length += 1;
|
|
|
+}
|
|
|
+
|
|
|
void nbus_master_unicastToModuleSet(nBus_TypeDef *nbus)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void nbus_master_unicastToModuleGet(nBus_TypeDef *nbus)
|
|
|
{
|
|
|
- // case CMD_SYNC:
|
|
|
+ switch (nbus->function_code.function)
|
|
|
{
|
|
|
- if (nbus->rx_length < 11)
|
|
|
+ case CMD_ECHO: {
|
|
|
+ for (uint8_t i = 3; i < nbus->rx_length - 1; i++)
|
|
|
{
|
|
|
- return;
|
|
|
+ nbus->tx_buffer[i + 1] = nbus->rx_buffer[i]+1;
|
|
|
}
|
|
|
-
|
|
|
- // RTC_TimeTypeDef sTime = {0};
|
|
|
- // RTC_DateTypeDef sDate = {0};
|
|
|
-
|
|
|
- // sTime.Hours = nbus->rx_buffer[7];
|
|
|
- // sTime.Minutes = nbus->rx_buffer[8];
|
|
|
- // sTime.Seconds = nbus->rx_buffer[9];
|
|
|
- // sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
|
|
|
- // sTime.StoreOperation = RTC_STOREOPERATION_RESET;
|
|
|
- // HAL_RTC_SetTime(nbus->periph->rtc, &sTime, RTC_FORMAT_BCD);
|
|
|
-
|
|
|
- // sDate.WeekDay = nbus->rx_buffer[6];
|
|
|
- // sDate.Date = nbus->rx_buffer[5];
|
|
|
- // sDate.Month = nbus->rx_buffer[4];
|
|
|
- // sDate.Year = nbus->rx_buffer[3];
|
|
|
-
|
|
|
- // HAL_RTC_SetDate(nbus->periph->rtc, &sDate, RTC_FORMAT_BCD);
|
|
|
+ nbus->tx_length += (nbus->rx_length - 4);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default: {
|
|
|
+ setErrorResponse(nbus, ILLEGAL_FUNCTION);
|
|
|
+ }
|
|
|
}
|
|
|
- // break;
|
|
|
}
|
|
|
#endif
|