|
|
@@ -44,17 +44,13 @@ inline static void send_response()
|
|
|
{
|
|
|
if (nBus.send_response == SEND_RESPONSE)
|
|
|
{
|
|
|
+ nBus.hw_platform->led_on();
|
|
|
nBus.tx_buffer[0] -= 1; // prvý bajt sa nepočíta
|
|
|
nBus.hw_platform->uart_transmit(nBus.tx_buffer, nBus.tx_length);
|
|
|
+ nBus.hw_platform->led_off();
|
|
|
}
|
|
|
- nBus.hw_platform->led_off();
|
|
|
-}
|
|
|
|
|
|
-#if MODULE_MASTER == 1
|
|
|
-inline static void receive_slave_response()
|
|
|
-{
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
static nBusCommandType_t get_request_type()
|
|
|
{
|
|
|
@@ -93,34 +89,34 @@ static void process_request()
|
|
|
nBus.tx_buffer[1] = nBus.rx_buffer[0]; // Module address
|
|
|
nBus.tx_buffer[2] = nBus.rx_buffer[1]; // Sensor address
|
|
|
|
|
|
+ // paket nie je adresovany tomuto modulu
|
|
|
+ if (nBus.addressModule != MODULE_ADDRESS)
|
|
|
+ {
|
|
|
+ nBus.send_response = NO_RESPONSE;
|
|
|
+ receivePacket();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
uint8_t crcC = crc8x_fast(nBus.rx_buffer, nBus.rx_length - 1);
|
|
|
if (crcC != nBus.rx_buffer[nBus.rx_length - 1])
|
|
|
{
|
|
|
nBus.send_response = NO_RESPONSE;
|
|
|
+ receivePacket();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-#if MODULE_SLAVE == 1
|
|
|
// spracovanie broadcast komunikacie
|
|
|
if ((request_type == BROADCAST_SPECIFIC_SENSORS || request_type == BROADCAST_GLOBAL))
|
|
|
{
|
|
|
nbus_slave_broadcast(&nBus, request_type);
|
|
|
return;
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
- // paket nie je adresovany tomuto modulu
|
|
|
- if (nBus.addressModule != MODULE_ADDRESS)
|
|
|
- {
|
|
|
- nBus.send_response = NO_RESPONSE;
|
|
|
- receivePacket();
|
|
|
- return;
|
|
|
- }
|
|
|
+ nBus.hw_platform->led_on();
|
|
|
|
|
|
nBus.function_code.error = 0;
|
|
|
nBus.tx_length = META_SIZE;
|
|
|
|
|
|
-#if MODULE_SLAVE == 1
|
|
|
if (nBus.function_code.notReadWrite == REQUEST_GET)
|
|
|
{
|
|
|
if (request_type == UNICAST_TO_SENSOR)
|
|
|
@@ -146,18 +142,7 @@ static void process_request()
|
|
|
nbus_slave_unicastToModuleSet(&nBus);
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
-#if MODULE_MASTER == 1
|
|
|
- if (nBus.function_code.notReadWrite == REQUEST_GET)
|
|
|
- {
|
|
|
- nbus_master_unicastToModuleGet(&nBus);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- nbus_master_unicastToModuleSet(&nBus);
|
|
|
- }
|
|
|
-#endif
|
|
|
nBus.tx_buffer[3] = *(uint8_t *)&nBus.function_code;
|
|
|
nBus.tx_buffer[nBus.tx_length - 1] = crc8x_fast(&nBus.tx_buffer[1], nBus.tx_length - 2);
|
|
|
nBus.tx_buffer[0] = nBus.tx_length;
|
|
|
@@ -298,15 +283,9 @@ void nbus_stack(void)
|
|
|
{
|
|
|
|
|
|
process_request();
|
|
|
+ nBus.hw_platform->led_off();
|
|
|
nBus.uart_state = UART_RX_WAIT;
|
|
|
-#if MODULE_SLAVE == 1
|
|
|
- send_response();
|
|
|
-#endif
|
|
|
-#if MODULE_MASTER == 1
|
|
|
- // test
|
|
|
send_response();
|
|
|
- // receive_slave_response();
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
if (nBus.hw_platform->loop_callback != NULL)
|