Browse Source

dlt645 success

haitao 1 year ago
parent
commit
f5b9dce4c3

+ 2 - 0
app/MDKProject/.vscode/keil-assistant.log

@@ -121,3 +121,5 @@
 
 [info] Log at : 2023/8/22|14:42:02|GMT+0800
 
+[info] Log at : 2023/8/23|16:08:42|GMT+0800
+

File diff suppressed because it is too large
+ 410 - 8475
app/MDKProject/JLinkLog.txt


File diff suppressed because it is too large
+ 763 - 745
app/MDKProject/Listings/lora_gateway.map


File diff suppressed because it is too large
+ 123 - 132
app/MDKProject/lora_gateway.uvguix.16936


+ 5 - 22
app/MDKProject/lora_gateway.uvoptx

@@ -153,24 +153,7 @@
           <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F2xx_1024 -FS08000000 -FL0100000 -FP0($$Device:STM32F207ZGTx$CMSIS\Flash\STM32F2xx_1024.FLM))</Name>
         </SetRegEntry>
       </TargetDriverDllRegistry>
-      <Breakpoint>
-        <Bp>
-          <Number>0</Number>
-          <Type>0</Type>
-          <LineNumber>88</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134248924</Address>
-          <ByteObject>0</ByteObject>
-          <HtxType>0</HtxType>
-          <ManyObjects>0</ManyObjects>
-          <SizeOfObject>0</SizeOfObject>
-          <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\SYSTEM\source\task.c</Filename>
-          <ExecCommand></ExecCommand>
-          <Expression>\\lora_gateway\../SYSTEM/source/task.c\88</Expression>
-        </Bp>
-      </Breakpoint>
+      <Breakpoint/>
       <MemoryWindow1>
         <Mm>
           <WinNumber>1</WinNumber>
@@ -289,7 +272,7 @@
 
   <Group>
     <GroupName>SYSTEM</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -769,7 +752,7 @@
 
   <Group>
     <GroupName>HARDWARE</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -1225,7 +1208,7 @@
 
   <Group>
     <GroupName>DLT645</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -1293,7 +1276,7 @@
 
   <Group>
     <GroupName>MODBUS</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>

BIN
app/OBJ/dlt645_port.crf


BIN
app/OBJ/gateway_message.crf


BIN
app/OBJ/lora_gateway.axf


+ 60 - 1
app/OBJ/lora_gateway.build_log.htm

@@ -27,7 +27,66 @@ Project File Date:  08/21/2023
 <h2>Output:</h2>
 *** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\workSoftware\stm32Software\mdk\mdkcore\ARM\ARMCC\Bin'
 Build target 'Target 1'
-"..\OBJ\lora_gateway.axf" - 0 Error(s), 0 Warning(s).
+compiling gateway_message.c...
+..\SYSTEM\includes\gateway_message.h(108): warning:  #1295-D: Deprecated declaration get_gateway_config_params - give arg types
+  GATEWAY_PARAMS *get_gateway_config_params();
+..\SYSTEM\includes\protocol.h(12): warning:  #1-D: last line of file ends without a newline
+  #endif
+..\SYSTEM\source\gateway_message.c(42): warning:  #223-D: function "sprintf" declared implicitly
+          sprintf(nodeStart, "node_%d", nodeIndex);
+..\SYSTEM\source\gateway_message.c(76): warning:  #223-D: function "sscanf" declared implicitly
+        sscanf((const char *)&nodeIdString[j * 2], "%2hhx", &byte);
+..\SYSTEM\source\gateway_message.c(88): warning:  #223-D: function "sprintf" declared implicitly
+          sprintf(device, "\"device_%d\":", deviceIndex);
+..\SYSTEM\source\gateway_message.c(67): warning:  #177-D: variable "deviceString"  was declared but never referenced
+      char *deviceString = (char *)nodestring; // 用于移位解析device设备信息
+..\SYSTEM\source\gateway_message.c(189): warning:  #223-D: function "sscanf" declared implicitly
+            sscanf((const char *)&string[j * 2], "%2hhx", &byte);
+..\SYSTEM\source\gateway_message.c(260): warning:  #223-D: function "sscanf" declared implicitly
+      sscanf(ptr, "%[^\"],", value);
+..\SYSTEM\source\gateway_message.c(278): warning:  #223-D: function "sprintf" declared implicitly
+      sprintf(node_index, "node_%d", nodeNum);
+..\SYSTEM\source\gateway_message.c(279): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
+      strstr(ptr, node_index); // 将指针指向第一个节点
+..\SYSTEM\source\gateway_message.c: 10 warnings, 0 errors
+compiling node_data_acquisition.c...
+..\SYSTEM\includes\node_data_acquisition.h(8): warning:  #1-D: last line of file ends without a newline
+  #endif
+..\SYSTEM\includes\node_message.h(63): warning:  #1295-D: Deprecated declaration get_node_receive_params - give arg types
+  NODE_DEVICE_PARAMS *get_node_receive_params();
+..\SYSTEM\includes\node_message.h(68): warning:  #1-D: last line of file ends without a newline
+  #endif
+..\SYSTEM\source\node_data_acquisition.c(17): warning:  #188-D: enumerated type mixed with another type
+  			mmodbus_set16bitOrder(node->params[i].modbus_read->bigLittleFormat);
+..\SYSTEM\source\node_data_acquisition.c(99): warning:  #1-D: last line of file ends without a newline
+  }
+..\SYSTEM\source\node_data_acquisition.c: 5 warnings, 0 errors
+compiling main.c...
+..\HARDWARE\includes\usart.h(88): warning:  #1295-D: Deprecated declaration USART_232_config - give arg types
+  void USART_232_config();
+..\HARDWARE\includes\usart.h(90): warning:  #1295-D: Deprecated declaration USART_485_config - give arg types
+  void USART_485_config();
+..\HARDWARE\includes\led.h(49): warning:  #1-D: last line of file ends without a newline
+  					
+..\SYSTEM\includes\myfile.h(12): warning:  #1295-D: Deprecated declaration ViewRootDir - give arg types
+  void ViewRootDir();
+..\SYSTEM\includes\myfile.h(14): warning:  #1-D: last line of file ends without a newline
+  #endif
+..\USER\main.c(102): warning:  #177-D: variable "cpu_sr"  was declared but never referenced
+  	OS_CPU_SR cpu_sr;
+..\USER\main.c(114): warning:  #177-D: variable "cpu_sr"  was declared but never referenced
+  	OS_CPU_SR cpu_sr;
+..\USER\main.c(141): warning:  #177-D: variable "NVIC_InitStructure"  was declared but never referenced
+    NVIC_InitTypeDef NVIC_InitStructure;
+..\USER\main.c: 8 warnings, 0 errors
+compiling stm32f2xx_it.c...
+..\SYSTEM\includes\node_data_acquisition.h(8): warning:  #1-D: last line of file ends without a newline
+  #endif
+..\USER\stm32f2xx_it.c: 1 warning, 0 errors
+linking...
+Program Size: Code=46704 RO-data=177340 RW-data=452 ZI-data=667932  
+FromELF: creating hex file...
+"..\OBJ\lora_gateway.axf" - 0 Error(s), 24 Warning(s).
 
 <h2>Software Packages used:</h2>
 

+ 12 - 12
app/OBJ/lora_gateway.htm

@@ -3,7 +3,7 @@
 <title>Static Call Graph - [..\OBJ\lora_gateway.axf]</title></head>
 <body><HR>
 <H1>Static Call Graph for image ..\OBJ\lora_gateway.axf</H1><HR>
-<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Tue Aug 22 14:52:47 2023
+<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Sat Aug 26 13:40:26 2023
 <BR><P>
 <H3>Maximum Stack Usage =       2512 bytes + Unknown(Functions without stacksize, Cycles, Untraceable Function Pointers)</H3><H3>
 Call chain for Maximum Stack Depth:</H3>
@@ -673,8 +673,8 @@ Global Symbols
 <LI><a href="#[12b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;SX1276LoRaSetRFFrequency
 <LI><a href="#[119]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;SX1276FskReadRssi
 <LI><a href="#[111]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;SX1276FskProcess
-<LI><a href="#[1a2]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_data_parse_by_format_to_float
 <LI><a href="#[17e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;pow
+<LI><a href="#[1a2]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_data_parse_by_format_to_float
 <LI><a href="#[15c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__mathlib_dbl_invalid
 <LI><a href="#[15a]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__mathlib_dbl_divzero
 <LI><a href="#[160]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_fp_digits
@@ -695,9 +695,9 @@ Global Symbols
 </UL>
 <BR>[Called By]<UL><LI><a href="#[11a]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;SX1276FskReadAfc
 <LI><a href="#[138]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;SX1276LoRaProcess
-<LI><a href="#[1a2]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_data_parse_by_format_to_float
 <LI><a href="#[17e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;pow
 <LI><a href="#[183]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;data_package_translate_to_int
+<LI><a href="#[1a2]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_data_parse_by_format_to_float
 </UL>
 
 <P><STRONG><a name="[93]"></a>__aeabi_ui2d</STRONG> (Thumb, 26 bytes, Stack size 16 bytes, dfltui.o(.text))
@@ -2525,8 +2525,8 @@ Global Symbols
 <P><STRONG><a name="[1ac]"></a>_crc</STRONG> (Thumb, 26 bytes, Stack size 8 bytes, dlt645_data.o(i._crc))
 <BR><BR>[Stack]<UL><LI>Max Depth = 8<LI>Call Chain = _crc
 </UL>
-<BR>[Called By]<UL><LI><a href="#[1a8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_common_check
-<LI><a href="#[1a5]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_send_msg
+<BR>[Called By]<UL><LI><a href="#[1a5]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_send_msg
+<LI><a href="#[1a8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_common_check
 </UL>
 
 <P><STRONG><a name="[165]"></a>addDevice</STRONG> (Thumb, 124 bytes, Stack size 24 bytes, gateway_message.o(i.addDevice))
@@ -2590,7 +2590,7 @@ Global Symbols
 <LI><a href="#[192]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dir_next
 </UL>
 
-<P><STRONG><a name="[17b]"></a>data_acquisition</STRONG> (Thumb, 750 bytes, Stack size 64 bytes, node_data_acquisition.o(i.data_acquisition))
+<P><STRONG><a name="[17b]"></a>data_acquisition</STRONG> (Thumb, 774 bytes, Stack size 64 bytes, node_data_acquisition.o(i.data_acquisition))
 <BR><BR>[Stack]<UL><LI>Max Depth = 608 + Unknown Stack Size
 <LI>Call Chain = data_acquisition &rArr; dlt645_read_data &rArr; dlt645_2007_read_data &rArr; dlt645_2007_parsing_data &rArr; dlt645_data_parse_by_format_to_float &rArr; data_package_translate_to_int &rArr; pow &rArr; __kernel_poly &rArr; __aeabi_dadd &rArr; _double_epilogue &rArr; _double_round
 </UL>
@@ -2600,10 +2600,10 @@ Global Symbols
 <LI><a href="#[182]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_read_data
 <LI><a href="#[90]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_ui2f
 <LI><a href="#[93]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_ui2d
-<LI><a href="#[17f]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_f2d
 <LI><a href="#[8f]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_ddiv
 <LI><a href="#[96]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_d2f
 <LI><a href="#[142]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;get_node_receive_params
+<LI><a href="#[17f]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_f2d
 <LI><a href="#[17e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;pow
 <LI><a href="#[143]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;malloc
 <LI><a href="#[180]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;free
@@ -2748,10 +2748,10 @@ Global Symbols
 <P><STRONG><a name="[1a3]"></a>dlt645_1997_read_data</STRONG> (Thumb, 152 bytes, Stack size 104 bytes, dlt645_1997.o(i.dlt645_1997_read_data))
 <BR><BR>[Stack]<UL><LI>Max Depth = 520<LI>Call Chain = dlt645_1997_read_data &rArr; dlt645_1997_parsing_data &rArr; dlt645_data_parse_by_format_to_float &rArr; data_package_translate_to_int &rArr; pow &rArr; __kernel_poly &rArr; __aeabi_dadd &rArr; _double_epilogue &rArr; _double_round
 </UL>
-<BR>[Calls]<UL><LI><a href="#[1a1]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_1997_parsing_data
-<LI><a href="#[1a5]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_send_msg
+<BR>[Calls]<UL><LI><a href="#[1a5]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_send_msg
 <LI><a href="#[1a6]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_receive_msg
 <LI><a href="#[1a4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_memclr4
+<LI><a href="#[1a1]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_1997_parsing_data
 </UL>
 <BR>[Called By]<UL><LI><a href="#[182]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_read_data
 </UL>
@@ -2811,8 +2811,8 @@ Global Symbols
 <LI><a href="#[17e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;pow
 <LI><a href="#[183]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;data_package_translate_to_int
 </UL>
-<BR>[Called By]<UL><LI><a href="#[1a1]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_1997_parsing_data
-<LI><a href="#[1a9]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_2007_parsing_data
+<BR>[Called By]<UL><LI><a href="#[1a9]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_2007_parsing_data
+<LI><a href="#[1a1]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_1997_parsing_data
 </UL>
 
 <P><STRONG><a name="[185]"></a>dlt645_init</STRONG> (Thumb, 30 bytes, Stack size 8 bytes, dlt645_port.o(i.dlt645_init))
@@ -3229,8 +3229,8 @@ Global Symbols
 <LI><a href="#[15a]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__mathlib_dbl_divzero
 </UL>
 <BR>[Called By]<UL><LI><a href="#[17b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;data_acquisition
-<LI><a href="#[1a2]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_data_parse_by_format_to_float
 <LI><a href="#[183]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;data_package_translate_to_int
+<LI><a href="#[1a2]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;dlt645_data_parse_by_format_to_float
 </UL>
 
 <P><STRONG><a name="[176]"></a>put_fat</STRONG> (Thumb, 310 bytes, Stack size 32 bytes, ff.o(i.put_fat))

File diff suppressed because it is too large
+ 26 - 16
app/OBJ/lora_gateway_Target 1.dep


BIN
app/OBJ/main.crf


BIN
app/OBJ/node_data_acquisition.crf


BIN
app/OBJ/node_message.crf


BIN
app/OBJ/protocol.crf


BIN
app/OBJ/stm32f2xx_it.crf


+ 10 - 0
app/OBJ/stm32f2xx_it.d

@@ -36,3 +36,13 @@
 ..\obj\stm32f2xx_it.o: ..\Libraries\inc\misc.h
 ..\obj\stm32f2xx_it.o: ..\USER\main.h
 ..\obj\stm32f2xx_it.o: D:\workSoftware\stm32Software\mdk\mdkcore\ARM\ARMCC\Bin\..\include\stdio.h
+..\obj\stm32f2xx_it.o: ..\SYSTEM\includes\node_data_acquisition.h
+..\obj\stm32f2xx_it.o: ..\modbus\mmodbus.h
+..\obj\stm32f2xx_it.o: ..\modbus\mmodbusConfig.h
+..\obj\stm32f2xx_it.o: D:\workSoftware\stm32Software\mdk\mdkcore\ARM\ARMCC\Bin\..\include\stdbool.h
+..\obj\stm32f2xx_it.o: D:\workSoftware\stm32Software\mdk\mdkcore\ARM\ARMCC\Bin\..\include\string.h
+..\obj\stm32f2xx_it.o: ..\UCOS-II\Source\ucos_ii.h
+..\obj\stm32f2xx_it.o: ..\UCOS-II\CONFIG\os_cfg.h
+..\obj\stm32f2xx_it.o: ..\UCOS-II\Ports\os_cpu.h
+..\obj\stm32f2xx_it.o: ..\dlt\inc\dlt645.h
+..\obj\stm32f2xx_it.o: ..\dlt\port\dlt645_port.h

BIN
app/OBJ/task.crf


BIN
app/OBJ/usart.crf


+ 1 - 0
app/SYSTEM/includes/node_data_acquisition.h

@@ -4,4 +4,5 @@
 #include "dlt645.h"
 #include "dlt645_port.h"
 void data_acquisition(void);
+extern uint8_t protocol_485;
 #endif

+ 2 - 0
app/SYSTEM/includes/node_message.h

@@ -61,6 +61,8 @@ typedef struct _NODE_DEVICE_PARAMS
 }NODE_DEVICE_PARAMS;
 
 NODE_DEVICE_PARAMS *get_node_receive_params();
+
+extern uint8_t protocol_485;
 #endif
 
 #endif

+ 5 - 2
app/SYSTEM/source/gateway_message.c

@@ -26,7 +26,6 @@ void addSensorListParams(char *paramString, DEVICE_PARAMS *device);
  */
 void addGatewayParams(char *gatewayString)
 {
-
     parseStringField(gatewayString, "\"commandTopic\":\"", (char *)&gateway_config_params.commandTopic);
     parseStringField(gatewayString, "\"messageTopic\":\"", (char *)&gateway_config_params.messageTopic);
     parseStringField(gatewayString, "\"deviceId\":\"", (char *)&gateway_config_params.deviceId);
@@ -178,6 +177,7 @@ void addSensorListParams(char *paramString, DEVICE_PARAMS *device)
     {
     case DLT645_97:
     case DLT645_07:
+		{
         NODE_READ_DLT645_COMMAND *read_dlt645_command = malloc(sizeof(NODE_READ_DLT645_COMMAND));
         read_dlt645_command->Identification = parseIntField(paramString, "\"identifier645\":");
         parseStringField(paramString, "\"identifier\":\"", (char *)&read_dlt645_command->keyword);
@@ -203,10 +203,12 @@ void addSensorListParams(char *paramString, DEVICE_PARAMS *device)
             }
             current->nextParams = read_dlt645_command;
         }
+			}
         break;
     case MODBUS:
+		{
         NODE_READ_MODBUS_COMMAND *read_modbus_command = malloc(sizeof(NODE_READ_MODBUS_COMMAND));
-				parseStringField(paramString,"\"identifier\":\"",read_modbus_command->keyword);
+				parseStringField(paramString,"\"identifier\":\"",(char *)&read_modbus_command->keyword);
         read_modbus_command->bigLittleFormat = parseIntField(paramString, "\"bigLittleFormat\":");
         read_modbus_command->dataType = parseIntField(paramString, "\"dataType\":");
         read_modbus_command->decimalPoint = parseIntField(paramString, "\"precise\":");
@@ -227,6 +229,7 @@ void addSensorListParams(char *paramString, DEVICE_PARAMS *device)
             }
             current->nextParams = read_modbus_command;
         }
+			}
         break;
     default:
         break;

+ 4 - 1
app/SYSTEM/source/node_data_acquisition.c

@@ -2,6 +2,7 @@
 #include "node_message.h"
 
 #include <math.h>
+uint8_t protocol_485;                      //485回调函数会调用那个callback dlt645还是modbus dlt645为1 modbus为2
 void data_acquisition(void)
 {
 	NODE_DEVICE_PARAMS *node;
@@ -11,6 +12,7 @@ void data_acquisition(void)
 	{
 		if (node->params[i].protcol == MODBUS_READ)
 		{
+			protocol_485=1;
 			uint16_t data[node->params[i].modbus_read->registerLength / 2]; // modbus寄存器长度
 			mmodbus_set16bitOrder(node->params[i].modbus_read->bigLittleFormat);
 			if (node->params[i].modbus_read->functionCode == 0x03)
@@ -49,10 +51,11 @@ void data_acquisition(void)
 		}
 		else if (node->params[i].protcol == MODBUS_WRITE)
 		{
-		
+			protocol_485=1;
 		}
 		else if (node->params[i].protcol == DLT645_07 || node->params[i].protcol == DLT645_97)
 		{
+			protocol_485=2;
 			uint8_t read_buf[10];
 			
 			node->params[i].dlt645_params->rxLen = 0;

+ 23 - 13
app/SYSTEM/source/protocol.c

@@ -339,21 +339,21 @@ void nodeSendReadValue(uint8_t *string)
 			{
 				string[len] = 0x04;
 				len++;
-				memcpy(string[len], node_receive_params->params[i].dlt645_params->value, 4);
+				memcpy(&string[len], node_receive_params->params[i].dlt645_params->value, 4);
 				len += 4;
 			}
 			else if (node_receive_params->params[i].dlt645_params->rxLen == 5)
 			{
 				string[len] = 0x05;
 				len++;
-				memcpy(string[len], node_receive_params->params[i].dlt645_params->value, 5);
+				memcpy(&string[len], node_receive_params->params[i].dlt645_params->value, 5);
 				len += 5;
 			}
 			else if (node_receive_params->params[i].dlt645_params->rxLen == 9)
 			{
 				string[len] = 0x09;
 				len++;
-				memcpy(string[len], node_receive_params->params[i].dlt645_params->value, 9);
+				memcpy(&string[len], node_receive_params->params[i].dlt645_params->value, 9);
 				len += 9;
 			}
 			else
@@ -367,7 +367,7 @@ void nodeSendReadValue(uint8_t *string)
 			{
 				string[len] = 0x04;
 				len++;
-				memcpy(string[len], node_receive_params->params[i].dlt645_params->value, 4);
+				memcpy(&string[len], node_receive_params->params[i].dlt645_params->value, 4);
 				len += 4;
 			}
 			else
@@ -408,7 +408,7 @@ int GatewayProtocolAnalysis(uint8_t *string, uint16_t len)
 		if (currentNode == NULL)
 		{
 			// 没有找到对应该节点信息不是给本机
-			return;
+			return 0;
 		}
 		currentNodeId = currentNode->node_address[0] << 8 | currentNode->node_address[1];
 	}
@@ -460,14 +460,14 @@ int GatewayProtocolAnalysis(uint8_t *string, uint16_t len)
 				if (currentModbusParams->dataType == 0x01 && currentModbusParams->decimalPoint == 0x00) // modbus底层存储的数据类型 1INT 2float
 				{
 					uint32_t value;
-					value = string[index + 1] + string[index + 2] >> 8 + string[index + 3] >> 16 + string[index + 4] >> 24;
+					value = string[index + 1] + (string[index + 2] >> 8) + (string[index + 3] >> 16) + (string[index + 4] >> 24);
 					sprintf(json + strlen(json), "{\"deviceId\":\"%s\",\"%s\":%d},", currentDevice->deviceID, currentModbusParams->keyword, value);
 				}
 				else // 如果是int且有小数点,或者底层就是float按照float来计算
 				{
 					float value;
-					memcmp(&value, string[index + 1], 4);
-					sprintf(json + strlen(json), "{\"deviceId\":\"%s\",\"%s\":%d},", currentDevice->deviceID, value);
+					memcmp(&value, &string[index + 1], 4);
+					sprintf(json + strlen(json), "{\"deviceId\":\"%s\",\"%s\":%.2f},", currentDevice->deviceID,currentModbusParams->keyword,value);
 				}
 				index += 4;
 				break;
@@ -478,7 +478,14 @@ int GatewayProtocolAnalysis(uint8_t *string, uint16_t len)
 			if (currentModbusParams == NULL)
 			{
 				currentDevice = currentDevice->nextDevice;
-				currentModbusParams = currentDevice->params;
+				if(currentDevice->protocol==MODBUS)
+				{
+					currentModbusParams=currentModbusParams->nextParams;
+				}
+				else
+				{
+					currentDlt645Params=currentDlt645Params->nextParams;
+				}
 			}
 			break;
 
@@ -492,8 +499,8 @@ int GatewayProtocolAnalysis(uint8_t *string, uint16_t len)
 			case 0x04:
 			{
 				float value;
-				memcmp(&value, string[index + 1], 4);
-				sprintf(json + strlen(json), "{\"deviceId\":\"%s\",\"%s\":%d},", currentDevice->deviceID, currentDlt645Params->keyword, value);
+				memcmp(&value, &string[index + 1], 4);
+				sprintf(json + strlen(json), "{\"deviceId\":\"%s\",\"%s\":%.2f},", currentDevice->deviceID, currentDlt645Params->keyword, value);
 				index += 4;
 			}
 			break;
@@ -508,7 +515,7 @@ int GatewayProtocolAnalysis(uint8_t *string, uint16_t len)
 			case 9:
 			{
 				float value;
-				memcpy(&value, string[index + 1], 4);
+				memcpy(&value, &string[index + 1], 4);
 				sprintf(json + strlen(json), "{\"deviceId\":\"%s\",\"%s\":\"%02X%02X%02X%02X%02X%.2f\"},",
 						currentDevice->deviceID, currentDlt645Params->keyword, string[index + 9], string[index + 8], string[index + 7], string[index + 6], string[index + 5], value);
 				index+=9;
@@ -521,7 +528,10 @@ int GatewayProtocolAnalysis(uint8_t *string, uint16_t len)
 			if (currentDlt645Params == NULL)
 			{
 				currentDevice = currentDevice->nextDevice;
-				currentDlt645Params = currentDevice->params;
+				if(currentDevice->protocol==MODBUS)
+				{
+					
+				}
 			}
 			break;
 		default:

+ 1 - 2
app/SYSTEM/source/task.c

@@ -41,12 +41,11 @@ void data_task(void *pdata)
 	dlt645_init(100);
 	mmodbus_init(100);
 	
-	
-	
 	char *lora_config_json = mymalloc(SRAMEX, 9 * 1024);
 	read_file("lora_json.txt", lora_config_json);
 	addGatewayParams(lora_config_json);
 	myfree(SRAMEX, lora_config_json);
+	
 #ifdef MASTER
 	GATEWAY_PARAMS *get;
 	get= get_gateway_config_params();

+ 1 - 1
app/USER/main.c

@@ -22,7 +22,7 @@
 //设置任务堆栈大小
 #define START_STK_SIZE  	    128
 //任务堆栈
-OS_STK START_TASK_STK[START_STK_SIZE];
+__align(8) OS_STK START_TASK_STK[START_STK_SIZE];    
 //任务函数
 void start_task(void *pdata);
 	   

+ 14 - 1
app/USER/stm32f2xx_it.c

@@ -23,7 +23,9 @@
 /* Includes ------------------------------------------------------------------*/
 #include "stm32f2xx_it.h"
 #include "main.h"
-
+#include "node_data_acquisition.h"
+#include "mmodbus.h"
+#include "dlt645.h"
 /** @addtogroup Template_Project
   * @{
   */
@@ -118,6 +120,17 @@ void DebugMon_Handler(void)
 {
 }
 
+void USART_485_IRQHandler(void)
+{
+	if(protocol_485==1) //dlt645
+	{
+		dlt_callback();
+	}
+	else if(protocol_485==2)      
+  {
+		mmodbus_callback();
+	}
+}
 /**
   * @brief  This function handles PendSVC exception.
   * @param  None