#2 Revision

Otevřený
xnecas chce sloučit 5 revizí z větve irep/MN_REVISION do větve irep/main

+ 3 - 3
include/app_bridge.h

@@ -14,7 +14,7 @@ typedef enum
 {
     // read-only sensors
     TYPE_UNKNOWN = 0xFF,
-	TYPE_ACCELEROMETER = 0,
+    TYPE_ACCELEROMETER = 0,
 	TYPE_GYROSCOPE,
 	TYPE_MAGNETOMETER,
 	TYPE_EULER_ANGLES_GAUGE,
@@ -66,12 +66,12 @@ typedef struct __attribute__((packed, aligned(1)))
      * uložený v logaritmickom tvare (pr. 2 -> 10^2).
      * @note: povolený rozsah [-64 , +63]
      */
-    uint8_t unit_multiplier : 7;
+    int8_t unit_multiplier : 7;
 
     /** Násobok meranej hodnoty uložený v logaritmickom tvare (pr. 1 -> 10^1).
      * @note: povolený rozsah [-128 , +127]
      */
-    uint8_t value_multiplier : 8;
+    int8_t value_multiplier : 8;
 
     /** Počet bajtov meranej hodnoty.
      * @note: povolený rozsah [1 , 8]

+ 8 - 8
src/nbus_app.c

@@ -89,14 +89,6 @@ 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])
     {
@@ -112,6 +104,14 @@ static void process_request()
         return;
     }
 
+    // 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;

+ 5 - 1
src/nbus_slave_module_unicast.c

@@ -241,7 +241,11 @@ void nbus_slave_unicastToModuleSet(nBus_TypeDef *nbus)
             for (; rx_payload > 0; rx_payload -= 5)
             {
                 param_id = nbus->rx_buffer[3 + 5 * i];
-                param_value = *(int32_t *)&nbus->rx_buffer[4 + 5 * i];
+
+                param_value  = (int32_t)nbus->rx_buffer[3 + 5 * i + 1];
+                param_value |= (int32_t)nbus->rx_buffer[3 + 5 * i + 2] << 8;
+                param_value |= (int32_t)nbus->rx_buffer[3 + 5 * i + 3] << 16;
+                param_value |= (int32_t)nbus->rx_buffer[3 + 5 * i + 4] << 24;
 
                 nbus->tx_buffer[4 + 2 * i] = param_id;
                 nbus->tx_buffer[5 + 2 * i] = nbus->interface->setParam(0, param_id, param_value);

+ 5 - 1
src/nbus_slave_sensor_unicast.c

@@ -149,7 +149,11 @@ void nbus_slave_unicastToSensorSet(nBus_TypeDef *nbus)
             for (; rx_payload > 0; rx_payload -= 5)
             {
                 param_id = nbus->rx_buffer[3 + 5 * i];
-                param_value = *(int32_t *)&nbus->rx_buffer[4 + 5 * i];
+
+                param_value  = (int32_t)nbus->rx_buffer[3 + 5 * i + 1];
+				param_value |= (int32_t)nbus->rx_buffer[3 + 5 * i + 2] << 8;
+				param_value |= (int32_t)nbus->rx_buffer[3 + 5 * i + 3] << 16;
+				param_value |= (int32_t)nbus->rx_buffer[3 + 5 * i + 4] << 24;
 
                 nbus->tx_buffer[4 + 2 * i] = param_id;
                 nbus->tx_buffer[5 + 2 * i] = nbus->interface->setParam(nbus->rx_buffer[RX_SA], param_id, param_value);