xnecas hace 1 día
padre
commit
ee5587f47d
Se han modificado 4 ficheros con 22 adiciones y 10 borrados
  1. 4 0
      include/app_bridge.h
  2. 8 8
      src/nbus_app.c
  3. 5 1
      src/nbus_slave_module_unicast.c
  4. 5 1
      src/nbus_slave_sensor_unicast.c

+ 4 - 0
include/app_bridge.h

@@ -17,7 +17,11 @@ typedef enum
 {
     // read-only sensors
     TYPE_UNKNOWN = 0xFF,
+<<<<<<< Updated upstream
 	TYPE_ACCELEROMETER = 0,
+=======
+    TYPE_ACCELEROMETER = 0,
+>>>>>>> Stashed changes
 	TYPE_GYROSCOPE,
 	TYPE_MAGNETOMETER,
 	TYPE_EULER_ANGLES_GAUGE,

+ 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);