Browse Source

串口修改

yangxingliang 1 year ago
parent
commit
43ed4b48eb

+ 1 - 1
Assets/BowArrow/InfraredCamera/InfraredDemo.cs

@@ -82,7 +82,7 @@ public class InfraredDemo  : JCUnityLib.ViewBase
         GUIStyle labelFont = new GUIStyle();
         labelFont.normal.textColor = new Color(1, 0.6f, 0.6f);
         labelFont.fontSize = Mathf.CeilToInt(Screen.height * 0.03f);
-        GUI.Label(new Rect(Screen.width / 100, Screen.height / 100, 100, 100), "game-20241111-1449-5-1", labelFont);
+        GUI.Label(new Rect(Screen.width / 100, Screen.height / 100, 100, 100), "game-20241111-1740-5-1", labelFont);
     }
 
     void Update()

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

@@ -62,7 +62,7 @@ public class ArrowSerialPort : MonoBehaviour
 #if UNITY_ANDROID && !UNITY_EDITOR
             Invoke("TrySerialOpenPort", 1f);
 #endif
-            LOG($"{PortName} 串口打开失败 重试中", true);
+            // LOG($"{PortName} 串口打开失败 重试中", true);
         }
         else if (msg.Equals("OPENED"))
         {
@@ -136,11 +136,11 @@ public class ArrowSerialPort : MonoBehaviour
     public void RequestDeviceIno()
     {
         List<byte> data = new List<byte>();
-        data[0] = 0xAA;//起始码
-        data[1] = 0x80;//命令号
-        data[2] = 0x05;//长度
-        data[3] = 0x85;//异或校验
-        data[4] = 0x55;//结束码
+        data.Add(0xAA);//起始码
+        data.Add(0x80);//命令号
+        data.Add(0x05);//长度
+        data.Add(0x85);//异或校验
+        data.Add(0x55);//结束码
         serialPortUtility?.Write(data.ToArray());
     }
     #endregion

+ 6 - 5
Assets/BowArrow/Scripts/SerialPortExample.cs

@@ -315,14 +315,14 @@ public class SerialPortExample : MonoBehaviour
         {
             logStr += $"i={bytes[i]}-";
         }
-        Debug.Log($"{PortName} 接收到的串口命令:{logStr}");
+        Debug.Log($"<color=#FF0000>{PortName} 接收到的串口命令:{logStr}</color>");
 
         if (bytes[0] == 0xAA)
         {
             if (bytes[1] == 0x55)//旧
             {
-                if (!PortName.Contains("/dev/ttyS8"))
-                    return;
+                // if (!PortName.Contains("/dev/ttyS8"))
+                //     return;
 
                 if (bytes[4] == 0xA6)//投币
                 {
@@ -336,8 +336,9 @@ public class SerialPortExample : MonoBehaviour
             }
             else
             {
-                if (!PortName.Contains("/dev/ttyS0"))
-                    return;
+                // if (!PortName.Contains("/dev/ttyS0"))
+                //     return;
+                
                 //0x04:为按键是否按下的命令
                 if (bytes[1] == 0x04)//退出
                 {