diff --git a/Assets/Scenes/WACVR.unity b/Assets/Scenes/WACVR.unity index faa81c4..b0d6d8f 100644 --- a/Assets/Scenes/WACVR.unity +++ b/Assets/Scenes/WACVR.unity @@ -3884,10 +3884,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c08c82d8bfafe7b4bb4386ab2dd79d9c, type: 3} m_Name: m_EditorClassIdentifier: - SettingData_114_Text: {fileID: 4900000, guid: daf159283ab4eaa4184a6824a7eace94, - type: 3} - SettingData_168_Text: {fileID: 4900000, guid: 7c31fb9ac50e1bb439de11b1fdd013bc, - type: 3} --- !u!1 &918186758 GameObject: m_ObjectHideFlags: 0 @@ -7151,7 +7147,6 @@ GameObject: m_Component: - component: {fileID: 1740661842} - component: {fileID: 1740661841} - - component: {fileID: 1740661840} - component: {fileID: 1740661839} m_Layer: 0 m_Name: Camera @@ -7193,14 +7188,6 @@ MonoBehaviour: m_RequiresDepthTexture: 0 m_RequiresColorTexture: 0 m_Version: 2 ---- !u!81 &1740661840 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1740661838} - m_Enabled: 1 --- !u!20 &1740661841 Camera: m_ObjectHideFlags: 0 diff --git a/Assets/Script/Serial.cs b/Assets/Script/Serial.cs index b1e1fe8..8d30fdb 100644 --- a/Assets/Script/Serial.cs +++ b/Assets/Script/Serial.cs @@ -1,46 +1,59 @@ using UnityEngine; using System.IO.Ports; using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Collections; public class Serial : MonoBehaviour { + + const byte CMD_GET_SYNC_BOARD_VER = 0xa0; + const byte CMD_NEXT_READ = 0x72; + const byte CMD_GET_UNIT_BOARD_VER = 0xa8; + const byte CMD_MYSTERY1 = 0xa2; + const byte CMD_MYSTERY2 = 0x94; + const byte CMD_START_AUTO_SCAN = 0xc9; + const byte CMD_BEGIN_WRITE = 0x77; + const byte CMD_NEXT_WRITE = 0x20; + static SerialPort ComL = new SerialPort ("COM5", 115200); static SerialPort ComR = new SerialPort ("COM6", 115200); - List inBytes; - List Bytes; + byte inByte; + string SYNC_BOARD_VER = "190523"; + string UNIT_BOARD_VER = "190514"; + string read1 = " 0 0 1 2 3 4 5 15 15 15 15 15 15 11 11 11"; + string read2 = " 11 11 11 128 103 103 115 138 127 103 105 111 126 113 95 100"; + string read3 = " 101 115 98 86 76 67 68 48 117 0 82 154 0 6 35 4"; + byte[] SettingData_160 = new byte[8]; - byte[] SettingData_114 = new byte[81]; - byte[] SettingData_168 = new byte[45]; byte[] SettingData_162 = new byte[7]; byte[] SettingData_148 = new byte[7]; byte[] SettingData_201 = new byte[7]; int TouchPackCounter = 0; static byte[] TouchPackL = new byte[36]; static byte[] TouchPackR = new byte[36]; - public TextAsset SettingData_114_Text; - public TextAsset SettingData_168_Text; bool StartUp = false; void Start() { ComL.Open(); ComR.Open(); - Debug.Log("Touch Serial Started"); + Debug.Log("Touch Serial Initializing.."); SetSettingData_160(); SetSettingData_201(); SetSettingData_162(); SetSettingData_148(); - SettingData_114 = ByteHelper.ConvertTextToByteArray(SettingData_114_Text); - SettingData_168 = ByteHelper.ConvertTextToByteArray(SettingData_168_Text); + // SettingData_168 = ByteHelper.ConvertTextToByteArray(SettingData_168_Text); } // Update is called once per frame void Update() { - ReadHead(ComL); - ReadHead(ComR); + if(ComL.IsOpen) + ReadHead(ComL, 0); + if (ComR.IsOpen) + ReadHead(ComR, 1); //SendTouch(ComL, TouchPackL); //SendTouch(ComR, TouchPackR); if (Input.GetKeyDown(KeyCode.M)) @@ -64,62 +77,103 @@ public class Serial : MonoBehaviour } } - void ReadHead(SerialPort Serial) + void ReadHead(SerialPort Serial, int side) { - while (Serial.BytesToRead > 0) + if(Serial.BytesToRead > 0) { inByte = Convert.ToByte(Serial.ReadByte()); - if (inByte == 144 || inByte == 148 || inByte == 154 || inByte == 160 || inByte == 162 || inByte == 168 || inByte == 201) - { - SendResp(Serial); - break; - } + var data = Serial.ReadExisting(); + SendResp(Serial, side, data); } + } - void SendResp(SerialPort Serial) + void SendResp(SerialPort Serial, int side, string data) { switch(inByte) { - case 160: + case CMD_GET_SYNC_BOARD_VER: + //Response: cmd byte + sync board ver + checksum StartUp = false; - Serial.Write(SettingData_160, 0, SettingData_160.Length); - Debug.Log(SettingData_160.Length); + List syncbytes = new List(); + syncbytes.Add(inByte); + syncbytes.AddRange(ByteHelper.ConvertStringToByteArray(SYNC_BOARD_VER)); + byte syncCheckSum = (byte)44; + syncbytes.Add(syncCheckSum); + Serial.Write(syncbytes.ToArray(), 0, syncbytes.Count); + Debug.Log($"GET SYNC BOARD VER {side}"); //Bytes.Clear(); break; - case 114: + case CMD_NEXT_READ: + //Response: corresponding read bytes + checksum StartUp = false; - Debug.Log(114); - Serial.Write(SettingData_114, 0, 81); + Debug.Log($"Side {side} NEXT READ {Convert.ToByte(data[2])}"); + switch (Convert.ToByte(data[2])) + { + case 0x30: + var bytes = ByteHelper.ConvertStringToByteArray(read1); + bytes.Add(ByteHelper.CalCheckSum(bytes.ToArray(), bytes.Count)); + Debug.Log("Read 1"); + Serial.Write(bytes.ToArray(), 0, bytes.Count); + break; + case 0x31: + var bytes2 = ByteHelper.ConvertStringToByteArray(read2); + bytes2.Add(ByteHelper.CalCheckSum(bytes2.ToArray(), bytes2.Count)); + Debug.Log("Read 2"); + Serial.Write(bytes2.ToArray(), 0, bytes2.Count); + break; + case 0x33: + var bytes3 = ByteHelper.ConvertStringToByteArray(read3); + bytes3.Add(ByteHelper.CalCheckSum(bytes3.ToArray(), bytes3.Count)); + Debug.Log("Read 3"); + Serial.Write(bytes3.ToArray(), 0, bytes3.Count); + break; + default: + Debug.Log("Extra Read"); + break; + } + // Serial.Write(SettingData_114, 0, 81); //Bytes.Clear(); break; - case 168: + case CMD_GET_UNIT_BOARD_VER: + //Response: cmd byte + sync board ver bytes + 'L'/'R' based on side + unit board ver bytes x6 + checksum StartUp = false; - Serial.Write(SettingData_168, 0, 45); - Debug.Log(168); + List unitBytes = new List(); + byte sideByte = (side == 0 ? Convert.ToByte('R') : Convert.ToByte('L')); + byte unitCheckSum = (side == 0 ? (byte)118 : (byte)104); + unitBytes.Add(inByte); + unitBytes.AddRange(ByteHelper.ConvertStringToByteArray(SYNC_BOARD_VER)); + unitBytes.Add(sideByte); + for (int i = 0; i < 6; i++) + unitBytes.AddRange(ByteHelper.ConvertStringToByteArray(UNIT_BOARD_VER)); + unitBytes.Add(unitCheckSum); + Serial.Write(unitBytes.ToArray(), 0, unitBytes.Count); + Debug.Log($"GET UNIT BOARD VER {side}"); //Bytes.Clear(); break; - case 162: + case CMD_MYSTERY1: StartUp = false; Serial.Write(SettingData_162, 0, 3); - Debug.Log(162); - Debug.Log(SettingData_162.Length); - Debug.Log("RX: "+SettingData_162[0]+"-"+ - SettingData_162[1]+"-"+ - SettingData_162[2]); + Debug.Log($"MYSTERY 1 SIDE {side}"); //Bytes.Clear(); break; - case 148: + case CMD_MYSTERY2: StartUp = false; Serial.Write(SettingData_148, 0, 3); - Debug.Log(148); + Debug.Log($"MYSTERY 2 SIDE {side}"); //Bytes.Clear(); break; - case 201: + case CMD_START_AUTO_SCAN: Serial.Write(SettingData_201.ToArray(), 0, 3); - Debug.Log(201); + Debug.Log($"START AUTO SCAN SIDE {side}"); //Bytes.Clear(); StartUp = true; break; + case CMD_BEGIN_WRITE: + // Debug.Log($"Begin Write For Side {side}"); + break; + case CMD_NEXT_WRITE: + // Debug.Log($"Continue Write For Side {side}"); + break; case 154: StartUp = false; Debug.Log("BAD"); @@ -206,10 +260,17 @@ public static class ByteHelper _CheckSumByte ^= _PacketData[i]; return _CheckSumByte; } + public static List ConvertStringToByteArray(string data) + { + List tempList = new List(100); + for(int i = 0; i < data.Length; i++) + tempList.Add(Convert.ToByte(data[i])); + return tempList; + } public static byte[] ConvertTextToByteArray(TextAsset TextObj) { var splitedData = TextObj.text.Split(Convert.ToChar("\n")); - byte[] tempList = new byte[100]; + byte[] tempList = new byte[splitedData.Length]; for (int i = 0; i < splitedData.Length; i++) tempList[i] = Convert.ToByte(splitedData[i]); return tempList; diff --git a/Assets/Script/SettingData_114.txt b/Assets/Script/SettingData_114.txt deleted file mode 100644 index ba9a6b9..0000000 --- a/Assets/Script/SettingData_114.txt +++ /dev/null @@ -1,81 +0,0 @@ -32 -32 -32 -32 -48 -32 -32 -32 -32 -48 -32 -32 -32 -32 -49 -32 -32 -32 -32 -50 -32 -32 -32 -32 -51 -32 -32 -32 -32 -52 -32 -32 -32 -32 -53 -32 -32 -32 -49 -53 -32 -32 -32 -49 -53 -32 -32 -32 -49 -53 -32 -32 -32 -49 -53 -32 -32 -32 -49 -53 -32 -32 -32 -49 -53 -32 -32 -32 -49 -49 -32 -32 -32 -49 -49 -32 -32 -32 -49 -49 -13 \ No newline at end of file diff --git a/Assets/Script/SettingData_114.txt.meta b/Assets/Script/SettingData_114.txt.meta deleted file mode 100644 index f3f1b57..0000000 --- a/Assets/Script/SettingData_114.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: daf159283ab4eaa4184a6824a7eace94 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Script/SettingData_168.txt b/Assets/Script/SettingData_168.txt deleted file mode 100644 index ce02d16..0000000 --- a/Assets/Script/SettingData_168.txt +++ /dev/null @@ -1,45 +0,0 @@ -168 -49 -57 -48 -53 -50 -51 -82 -49 -57 -48 -53 -49 -52 -49 -57 -48 -53 -49 -52 -49 -57 -48 -53 -49 -52 -49 -57 -48 -53 -49 -52 -49 -57 -48 -53 -49 -52 -49 -57 -48 -53 -49 -52 -118 \ No newline at end of file diff --git a/Assets/Script/SettingData_168.txt.meta b/Assets/Script/SettingData_168.txt.meta deleted file mode 100644 index 590d78c..0000000 --- a/Assets/Script/SettingData_168.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 7c31fb9ac50e1bb439de11b1fdd013bc -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/uWindowCapture/Assets/Prefabs/uWC Window Object Child.prefab b/Assets/uWindowCapture/Assets/Prefabs/uWC Window Object Child.prefab index d505053..7a4da84 100644 Binary files a/Assets/uWindowCapture/Assets/Prefabs/uWC Window Object Child.prefab and b/Assets/uWindowCapture/Assets/Prefabs/uWC Window Object Child.prefab differ diff --git a/Assets/uWindowCapture/Assets/Prefabs/uWC Window Object.prefab b/Assets/uWindowCapture/Assets/Prefabs/uWC Window Object.prefab index fe9232b..f452883 100644 Binary files a/Assets/uWindowCapture/Assets/Prefabs/uWC Window Object.prefab and b/Assets/uWindowCapture/Assets/Prefabs/uWC Window Object.prefab differ diff --git a/Assets/uWindowCapture/Samples/Window List/uWC Window List Item.prefab b/Assets/uWindowCapture/Samples/Window List/uWC Window List Item.prefab index cf3528e..a0d97a3 100644 Binary files a/Assets/uWindowCapture/Samples/Window List/uWC Window List Item.prefab and b/Assets/uWindowCapture/Samples/Window List/uWC Window List Item.prefab differ diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 5c608a2..d53945b 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -137,8 +137,6 @@ PlayerSettings: bundleVersion: 0.1.0 preloadedAssets: - {fileID: 11400000, guid: 74eeb7429f216ca45a7093c586513e98, type: 2} - - {fileID: -6265376527240436808, guid: 5e2dc0db42cc5b3459a781fecb0b76f9, type: 2} - - {fileID: -6348321304186183749, guid: 6460523340b221f4ea5611d2c011a26c, type: 2} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1