|
@@ -7,9 +7,9 @@ public class ArrowSerialPort : MonoBehaviour
|
|
|
{
|
|
{
|
|
|
private SerialPortUtilityPro serialPortUtility;
|
|
private SerialPortUtilityPro serialPortUtility;
|
|
|
private SerialPortUtilityPro.OpenSystem openMode = SerialPortUtilityPro.OpenSystem.PCI;
|
|
private SerialPortUtilityPro.OpenSystem openMode = SerialPortUtilityPro.OpenSystem.PCI;
|
|
|
- //private int baudrate = 115200;
|
|
|
|
|
|
|
+ private int baudrate = 115200;
|
|
|
//private int baudrate = 921600;
|
|
//private int baudrate = 921600;
|
|
|
- private int baudrate = 460800;
|
|
|
|
|
|
|
+ //private int baudrate = 460800;
|
|
|
private string PortName = "/dev/ttyS0";
|
|
private string PortName = "/dev/ttyS0";
|
|
|
private static Dictionary<string, int> _isInit = new();
|
|
private static Dictionary<string, int> _isInit = new();
|
|
|
public bool testMode = true;
|
|
public bool testMode = true;
|
|
@@ -147,7 +147,23 @@ public class ArrowSerialPort : MonoBehaviour
|
|
|
OnDeviceInfoBack(bytes);
|
|
OnDeviceInfoBack(bytes);
|
|
|
break;
|
|
break;
|
|
|
case 0x81://射击消息
|
|
case 0x81://射击消息
|
|
|
|
|
+ if (CommonConfig.bDisableBluetooth) {
|
|
|
|
|
+ // 获取当前时间
|
|
|
|
|
+ DateTime currentTime1 = DateTime.Now;
|
|
|
|
|
+ // 打印带毫秒的时间戳
|
|
|
|
|
+ Debug.Log("CurrentTime1:" + currentTime1 + ",format: " + currentTime1.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
OnDeviceShoot(bytes);
|
|
OnDeviceShoot(bytes);
|
|
|
|
|
+
|
|
|
|
|
+ if (CommonConfig.bDisableBluetooth) {
|
|
|
|
|
+ //3 - APP在收到射箭消息后,立即回复相同的内容给设备端;
|
|
|
|
|
+ serialPortUtility?.Write(bytes);
|
|
|
|
|
+ // 获取当前时间
|
|
|
|
|
+ DateTime currentTime2 = DateTime.Now;
|
|
|
|
|
+ // 打印带毫秒的时间戳
|
|
|
|
|
+ Debug.Log("CurrentTime2:" + currentTime2 + ",format: " + currentTime2.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
case 0x82://按键消息
|
|
case 0x82://按键消息
|
|
|
OnDeviceButton(bytes);
|
|
OnDeviceButton(bytes);
|
|
@@ -160,6 +176,31 @@ public class ArrowSerialPort : MonoBehaviour
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ if (CommonConfig.bDisableBluetooth) {
|
|
|
|
|
+ //byte[] bytes = new byte[] { 0x0A, 0x00, 0x00, 0x00, // 1st timestamp
|
|
|
|
|
+ // 0x0B, 0x00, 0x00, 0x00, // 2nd timestamp
|
|
|
|
|
+ // 0x00, 0x01, 0x00, 0x00 // 3rd timestamp
|
|
|
|
|
+ //};
|
|
|
|
|
+ if (bytes.Length == 12)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 解析并转换时间戳
|
|
|
|
|
+ for (int i = 0; i < bytes.Length; i += 4)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 提取 4 字节的时间戳
|
|
|
|
|
+ uint timestamp = BitConverter.ToUInt32(bytes, i);
|
|
|
|
|
+
|
|
|
|
|
+ // 转换为毫秒(单位是 100us)
|
|
|
|
|
+ float timeInMilliseconds = timestamp * 0.1f;
|
|
|
|
|
+
|
|
|
|
|
+ // 打印转换结果
|
|
|
|
|
+ Debug.Log($"Timestamp (U32): {timestamp} => Time: {timeInMilliseconds} ms");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool lightWaitClose = false;
|
|
bool lightWaitClose = false;
|