Parcourir la source

串口请求数据

yangxingliang il y a 1 an
Parent
commit
d7494bd329
1 fichiers modifiés avec 4 ajouts et 16 suppressions
  1. 4 16
      Assets/BowArrow/Scripts/SerialPortExample.cs

+ 4 - 16
Assets/BowArrow/Scripts/SerialPortExample.cs

@@ -54,13 +54,10 @@ public class SerialPortExample : MonoBehaviour
         serialPortUtility.Open();
         serialPortUtility.Open();
 
 
         LOG($"{PortName} 串口打开");
         LOG($"{PortName} 串口打开");
-        // if (PortName.Contains("/dev/ttyS0"))
-        // {
-            //拉取二维码
-            RequestUrl(dataIndex);
-            //拉取后台数据
-            ReqSettingData();
-        // }
+        //拉取二维码
+        RequestUrl(dataIndex);
+        //拉取后台数据
+        ReqSettingData();
 #endif
 #endif
 #if UNITY_EDITOR
 #if UNITY_EDITOR
         TestBackUrl();
         TestBackUrl();
@@ -126,9 +123,6 @@ public class SerialPortExample : MonoBehaviour
 
 
     void OnUrlPayResponse(byte[] bytes)
     void OnUrlPayResponse(byte[] bytes)
     {
     {
-        if (!PortName.Contains("/dev/ttyS0"))
-            return;
-
         //计算校验值
         //计算校验值
         byte tempResponseCheck = 0;
         byte tempResponseCheck = 0;
         for (int i = 2; i < bytes.Length - 1; i++)
         for (int i = 2; i < bytes.Length - 1; i++)
@@ -321,9 +315,6 @@ public class SerialPortExample : MonoBehaviour
         {
         {
             if (bytes[1] == 0x55)//旧
             if (bytes[1] == 0x55)//旧
             {
             {
-                // if (!PortName.Contains("/dev/ttyS8"))
-                //     return;
-
                 if (bytes[4] == 0xA6)//投币
                 if (bytes[4] == 0xA6)//投币
                 {
                 {
                     Debug.Log("旧版投币数量:" + bytes[4]);
                     Debug.Log("旧版投币数量:" + bytes[4]);
@@ -336,9 +327,6 @@ public class SerialPortExample : MonoBehaviour
             }
             }
             else
             else
             {
             {
-                // if (!PortName.Contains("/dev/ttyS0"))
-                //     return;
-                
                 //0x04:为按键是否按下的命令
                 //0x04:为按键是否按下的命令
                 if (bytes[1] == 0x04)//退出
                 if (bytes[1] == 0x04)//退出
                 {
                 {