示例#1
0
        public void WriteBytes(byte[] data, ulong offset, RWMethod method)
        {
            lock (_sync)
            {
                var cmd = method switch
                {
                    RWMethod.Heap => SwitchCommand.Poke((uint)offset, data),
                    RWMethod.Main => SwitchCommand.PokeMain(offset, data),
                    RWMethod.Absolute => SwitchCommand.PokeAbsolute(offset, data),
                    _ => SwitchCommand.Poke((uint)offset, data)
                };

                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep((data.Length / 256) + 100);
            }
        }
示例#2
0
        public byte[] ReadBytes(ulong offset, int length, RWMethod method)
        {
            lock (_sync)
            {
                var cmd = method switch
                {
                    RWMethod.Heap => SwitchCommand.Peek((uint)offset, length),
                    RWMethod.Main => SwitchCommand.PeekMain(offset, length),
                    RWMethod.Absolute => SwitchCommand.PeekAbsolute(offset, length),
                    _ => SwitchCommand.Peek((uint)offset, length)
                };

                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep((length / 256) + 100);
                var buffer = new byte[(length * 2) + 1];
                var _      = ReadInternal(buffer);
                return(Decoder.ConvertHexByteStringToBytes(buffer));
            }
        }