|
|
@@ -8,7 +8,7 @@ public class ArrowSerialPort : MonoBehaviour
|
|
|
private SerialPortUtilityPro serialPortUtility;
|
|
|
private SerialPortUtilityPro.OpenSystem openMode = SerialPortUtilityPro.OpenSystem.PCI;
|
|
|
private int baudrate = 115200;
|
|
|
- private string PortName = "/dev/ttyS1";
|
|
|
+ private string PortName = "/dev/ttyS0";
|
|
|
private static Dictionary<string, int> _isInit = new();
|
|
|
public bool testMode = false;
|
|
|
private void Awake()
|
|
|
@@ -108,7 +108,12 @@ public class ArrowSerialPort : MonoBehaviour
|
|
|
/// <param name="bytes"></param>
|
|
|
private void PhraseData(byte[] bytes)
|
|
|
{
|
|
|
- LOG($"{PortName} 收到串口信息!");
|
|
|
+ string msg = string.Empty;
|
|
|
+ for (int i = 0; i < bytes.Length; i++)
|
|
|
+ {
|
|
|
+ msg += bytes[i].ToString("x2") + " ";
|
|
|
+ }
|
|
|
+ LOG($"{PortName} 收到串口信息 msg={msg}!");
|
|
|
if (bytes[0] == 0xAA)
|
|
|
{
|
|
|
var cmdID = bytes[1];
|
|
|
@@ -154,10 +159,10 @@ public class ArrowSerialPort : MonoBehaviour
|
|
|
{
|
|
|
Debug.Log($"{PortName} 收到设备信息响应!");
|
|
|
var check = bytes[1] + bytes[2] + bytes[3] + bytes[4];//校验:命令+长度+数据内容
|
|
|
- if (check != bytes[5])
|
|
|
- LOG("OnDeviceInfoBack 数据校验错误!");
|
|
|
- else
|
|
|
- {
|
|
|
+ //if (check != bytes[5])
|
|
|
+ // LOG("OnDeviceInfoBack 数据校验错误!");
|
|
|
+ //else
|
|
|
+ //{
|
|
|
//0x01 HOUYI Pro
|
|
|
//0x02 ARTEMIS Pro
|
|
|
//0x03 Pistol 1
|
|
|
@@ -182,7 +187,7 @@ public class ArrowSerialPort : MonoBehaviour
|
|
|
//刷新界面
|
|
|
var setting = FindAnyObjectByType<CustomUIView.BoxUserSettings>();
|
|
|
setting?.FlushDeviceSelect();
|
|
|
- }
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -193,10 +198,10 @@ public class ArrowSerialPort : MonoBehaviour
|
|
|
LOG($"{PortName} 收到设备射击消息!");
|
|
|
|
|
|
var check = bytes[1] + bytes[2] + bytes[3] + bytes[4];//校验:命令+长度+数据内容
|
|
|
- if (check != bytes[5])
|
|
|
- {
|
|
|
- LOG("OnDeviceShoot 数据校验错误!");
|
|
|
- }else
|
|
|
+ //if (check != bytes[5])
|
|
|
+ //{
|
|
|
+ // LOG("OnDeviceShoot 数据校验错误!");
|
|
|
+ //}else
|
|
|
SerialPortHelper.shoot?.Invoke(bytes);
|
|
|
}
|
|
|
|
|
|
@@ -208,11 +213,17 @@ public class ArrowSerialPort : MonoBehaviour
|
|
|
{
|
|
|
Debug.Log($"{PortName} 收到设备按键消息!");
|
|
|
var check = bytes[1] + bytes[2] + bytes[3];//校验:命令+长度+数据内容
|
|
|
- if (check != bytes[4])
|
|
|
+ //if (check != bytes[4])
|
|
|
+ //{
|
|
|
+ // LOG("OnDeviceButton 数据校验错误!");
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ if (bytes[3] == 0x01 || bytes[3] == 0x02 || bytes[3] == 0x03)
|
|
|
{
|
|
|
- LOG("OnDeviceButton 数据校验错误!");
|
|
|
+ //开机
|
|
|
+ RequestDeviceIno();
|
|
|
+ return;
|
|
|
}
|
|
|
- else
|
|
|
SerialPortHelper.aim?.Invoke(bytes);
|
|
|
}
|
|
|
|