소스 검색

[service_sw]add rs-485 test

balbekova 5 년 전
부모
커밋
21f7116598

+ 1 - 2
service_hw/Commands/bt_6701_commands.c

@@ -9,11 +9,10 @@
  * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
  *******************************************************************************
  */
-
+#include "common_config.h"
 #include "stm32f4xx.h"  
 #include "bt_6701_commands.h"
 #include "commands_api.h"
-#include "common_config.h"
 #include "gpio.h"
 #include "buttons.h"
 #include "led.h"

+ 20 - 1
service_hw/Commands/commands_api.c

@@ -9,12 +9,14 @@
  * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
  *******************************************************************************
  */
+#include "common_config.h" 
 #include "stm32f4xx.h"  
 #include "commands_api.h"
 #include "settings_api.h"
 #include "sys_api.h"
 #include "buttons.h"
 #include "led.h"
+#include "usart.h"
 #include "parameters.h"
 #include "bt_6701_settings.h"
 #include "bt_6701_commands.h"
@@ -23,6 +25,7 @@
 #include "http_server.h"
 #include "config_service.h"
 #include "rtc.h"
+#include "port_microrl.h"
 
 #include "FreeRTOS.h"
 #include "task.h"
@@ -59,6 +62,7 @@ bool testRtc = false;
 bool testSerno = false;
 bool testT2Ready = false;
 bool testSet = false;
+bool testRS485 = false;
 
 #define MSG_LEN   300
 char msg[MSG_LEN];
@@ -196,7 +200,22 @@ void TEST_SetTest(TEST_t state)
     if (state == TEST_WAIT)
         testState = state;
 }
-
+#ifdef PORTGW_ENABLE
+/**
+  * @brief  Отправка данных по интерфейсу RS485
+  */
+void COM_TestRS485(char *str, uint8_t len)
+{
+  if (str) {
+    uint8_t sent = rs485_send_block((uint8_t *)str, len);
+    sprintf(msg, "RS485 sent %d bytes", sent);
+    print(msg);
+  }
+  print("\r\n");
+  testRS485 = false;
+  return;
+}
+#endif
 /**
   * @brief  Считать статут тестирования (T0, T1, etc)
   */

+ 6 - 1
service_hw/Commands/commands_api.h

@@ -71,7 +71,12 @@ void vTestCommands(void *params);
   * @brief  
   */
 void TEST_SetTest(TEST_t state);
-
+#ifdef PORTGW_ENABLE
+/**
+  * @brief  Отправка данных по интерфейсу RS485
+  */
+void COM_TestRS485(char *str, uint8_t len);
+#endif
 
 extern bool ifTest_DEF;
 extern bool ifTest_SET;

+ 22 - 3
service_hw/Console/port_microrl.c

@@ -9,7 +9,7 @@
  * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
  *******************************************************************************
  */
-
+#include "common_config.h" 
 #include "stm32f4xx.h" 
 #include "port_microrl.h"
 #include "microrl.h"
@@ -81,6 +81,7 @@
 
 #define _CMD_SPIFLASH    "SPIFLASH"
 #define _CMD_U232        "U232"
+#define _CMD_U485        "U485"
 
 // arguments for set/clear
 #define _SCMD_PB  "port_b"
@@ -138,7 +139,8 @@ char * keyworld [] = {
   _CMD_RST,
 
   _CMD_SPIFLASH,
-  _CMD_U232
+  _CMD_U232,
+  _CMD_U485
 };
 
 // 'set/clear' command argements
@@ -311,7 +313,24 @@ int execute (int argc, const char * const * argv)
 		print ("\n\r");
 		return 0;
 	   }
-      
+#ifdef PORTGW_ENABLE
+      /* Отправка данных по интерфейсу RS485 (прием не проверяется) */
+      else if (strcmp (argv[i], _CMD_U485) == 0)
+      {
+        if (++i < argc)
+        {
+          len = strlen(argv[i]);
+          len = len < PARAM_LEN ? len : PARAM_LEN - 1;
+          strncpy(param, argv[i], len);
+          COM_TestRS485(param, len);
+        }
+        else {
+          COM_TestRS485(NULL, 0);
+        }
+        //print ("\n\r");
+        return 0;
+      }
+#endif
 	  /* -------------------------------------------------------------------- */
 	  /*                          Тесты этапа Т2                              */
 	  /* Статус тестера */

+ 1 - 0
service_hw/Hardware/hw_init.c

@@ -11,6 +11,7 @@
  */
 
 #include "stm32f4xx.h"  
+#include "common_config.h" 
 #include "hw_init.h"
 #include "wdg.h"
 #include "usart.h"

+ 2 - 1
service_hw/Makefile

@@ -21,6 +21,8 @@ CFLAGS += -DBT6702_SERVICE
 
 CFLAGS += -DPRINTF_$(shell echo $(PRINTF) | tr a-z A-Z)
 
+CFLAGS += -DHARDWARE_$(shell echo $(HARDWARE) | tr a-z A-Z)
+
 INCLUDES = -I../config
 INCLUDES += -I../stm32/stm32f4xx_spl/inc 
 INCLUDES += -I../stm32/system
@@ -61,7 +63,6 @@ CSRC += $(wildcard ../modules/common/*.c)
 CSRC += $(wildcard ../modules/*.c)
 
 CFLAGS += -DOS_FREERTOS
-CFLAGS += -DHARDWARE_$(shell echo $(HARDWARE) | tr a-z A-Z)
 
 #FreeRTOS
 LDSCRIPT := ../modules/startup/stm32_flash.ld

+ 1 - 1
service_hw/buttons/buttons.c

@@ -9,7 +9,7 @@
  * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
  *******************************************************************************
  */
-
+#include "common_config.h"
 #include "stm32f4xx.h"  
 #include "buttons.h"
 #include "led.h"

+ 2 - 0
service_hw/leds/led.c

@@ -9,11 +9,13 @@
  * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
  *******************************************************************************
  */
+#include "common_config.h" 
 #include "led.h"
 
 #include "FreeRTOS.h"
 #include "task.h"
 
+
 #define LEDS_EXPAND_OFF(id, ...) 		\
 		LED_Off(id);