Browse Source

打印日志添加时间

slambb 10 months ago
parent
commit
ceb92e2fd2
2 changed files with 18 additions and 12 deletions
  1. 6 6
      Assets/BowArrow/Scenes/Login.unity
  2. 12 6
      Assets/BowArrow/Scripts/ArrowSerialPort.cs

+ 6 - 6
Assets/BowArrow/Scenes/Login.unity

@@ -13946,9 +13946,9 @@ RectTransform:
   m_Father: {fileID: 2086638595}
   m_RootOrder: 1
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchorMin: {x: 0, y: 1}
+  m_AnchorMax: {x: 0, y: 1}
+  m_AnchoredPosition: {x: 0, y: -90.325}
   m_SizeDelta: {x: 760, y: 100.7}
   m_Pivot: {x: 0, y: 0.5}
 --- !u!114 &1621113221
@@ -16590,9 +16590,9 @@ RectTransform:
   m_Father: {fileID: 2086638595}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchorMin: {x: 0, y: 1}
+  m_AnchorMax: {x: 0, y: 1}
+  m_AnchoredPosition: {x: 160, y: -17.825}
   m_SizeDelta: {x: 160, y: 27}
   m_Pivot: {x: 1, y: 0.5}
 --- !u!114 &1829322616

+ 12 - 6
Assets/BowArrow/Scripts/ArrowSerialPort.cs

@@ -137,7 +137,9 @@ public class ArrowSerialPort : MonoBehaviour
         {
             msg += bytes[i].ToString("x2") + " ";
         }
-        LOG($"{PortName} 收到串口信息  msg={msg}!");
+        // 获取当前时间
+        DateTime currentTime = DateTime.Now;
+        LOG($"{PortName} 收到串口信息  msg={msg}!,接收时间:" + currentTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
         if (bytes[0] == 0xAA)
         {
             var cmdID = bytes[1];
@@ -151,18 +153,22 @@ public class ArrowSerialPort : MonoBehaviour
                         // 获取当前时间
                         DateTime currentTime1 = DateTime.Now;
                         // 打印带毫秒的时间戳
-                        Debug.Log("CurrentTime1:" + currentTime1 + ",format: " + currentTime1.ToString("yyyy-MM-dd HH:mm:ss.fff"));
+                        Debug.Log("射箭前:CurrentTime1: " + currentTime1.ToString("yyyy-MM-dd HH:mm:ss.fff"));
+                        //3 - APP在收到射箭消息后,立即回复相同的内容给设备端;
+                        serialPortUtility?.Write(bytes);
+                        DateTime currentTime3 = DateTime.Now;
+                        // 打印带毫秒的时间戳
+                        Debug.Log("*** 回复相同的内容给设备端 CurrentTime3: " + currentTime3.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                     }
 
                     OnDeviceShoot(bytes);
 
-                    if (CommonConfig.bDisableBluetooth) {
-                        //3 - APP在收到射箭消息后,立即回复相同的内容给设备端;
-                        serialPortUtility?.Write(bytes);
+                    if (CommonConfig.bDisableBluetooth) 
+                    {
                         // 获取当前时间
                         DateTime currentTime2 = DateTime.Now;
                         // 打印带毫秒的时间戳
-                        Debug.Log("CurrentTime2:" + currentTime2 + ",format: " + currentTime2.ToString("yyyy-MM-dd HH:mm:ss.fff"));
+                        Debug.Log("射箭后:CurrentTime2: " + currentTime2.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                     }
                     break;
                 case 0x82://按键消息