Exemplo n.º 1
0
        public string ParseResponse(string command, byte[] response_bytes)
        {
            IntPtr nativeBytes = IntPtr.Zero;

            try
            {
                nativeBytes = Marshal.AllocHGlobal(response_bytes.Length);
                Marshal.Copy(response_bytes, 0, nativeBytes, response_bytes.Length);
                object error;
                IntPtr rawDataBuffer = NativeMethods.rs2_terminal_parse_response(Handle, command, (uint)command.Length,
                                                                                 nativeBytes, (uint)response_bytes.Length, out error);

                IntPtr start = NativeMethods.rs2_get_raw_data(rawDataBuffer, out error);
                int    size  = NativeMethods.rs2_get_raw_data_size(rawDataBuffer, out error);

                byte[] managedBytes = new byte[size];
                Marshal.Copy(start, managedBytes, 0, size);
                NativeMethods.rs2_delete_raw_data(rawDataBuffer);

                return(System.Text.Encoding.Default.GetString(managedBytes));
            }
            finally
            {
                Marshal.FreeHGlobal(nativeBytes);
            }
        }
Exemplo n.º 2
0
        public byte[] SendReceiveRawData(byte[] command_bytes)
        {
            IntPtr nativeBytes = IntPtr.Zero;

            try
            {
                nativeBytes = Marshal.AllocHGlobal(command_bytes.Length);
                Marshal.Copy(command_bytes, 0, nativeBytes, command_bytes.Length);
                object error;
                IntPtr rawDataBuffer = NativeMethods.rs2_send_and_receive_raw_data(Handle, nativeBytes, (uint)command_bytes.Length, out error);

                IntPtr start = NativeMethods.rs2_get_raw_data(rawDataBuffer, out error);
                int    size  = NativeMethods.rs2_get_raw_data_size(rawDataBuffer, out error);

                byte[] managedBytes = new byte[size];
                Marshal.Copy(start, managedBytes, 0, size);
                NativeMethods.rs2_delete_raw_data(rawDataBuffer);

                return(managedBytes);
            }
            finally
            {
                Marshal.FreeHGlobal(nativeBytes);
            }
        }
Exemplo n.º 3
0
        byte[] GetByteArrayFromRawDataObject(IntPtr raw)
        {
            object error;
            var    start = NativeMethods.rs2_get_raw_data(raw, out error);
            var    size  = NativeMethods.rs2_get_raw_data_size(raw, out error);

            byte[] managedBytes = new byte[size];
            Marshal.Copy(start, managedBytes, 0, size);

            NativeMethods.rs2_delete_raw_data(raw);
            return(managedBytes);
        }
Exemplo n.º 4
0
        public byte[] ExportLocalizationMap()
        {
            object error;
            IntPtr rawDataBuffer = NativeMethods.rs2_export_localization_map(Handle, out error);

            IntPtr start = NativeMethods.rs2_get_raw_data(rawDataBuffer, out error);
            int    size  = NativeMethods.rs2_get_raw_data_size(rawDataBuffer, out error);

            byte[] managedBytes = new byte[size];
            Marshal.Copy(start, managedBytes, 0, size);
            NativeMethods.rs2_delete_raw_data(rawDataBuffer);

            return(managedBytes);
        }
Exemplo n.º 5
0
        public byte[] ParseCommand(string command)
        {
            object error;
            IntPtr rawDataBuffer = NativeMethods.rs2_terminal_parse_command(Handle, command, (uint)command.Length, out error);

            IntPtr start = NativeMethods.rs2_get_raw_data(rawDataBuffer, out error);
            int    size  = NativeMethods.rs2_get_raw_data_size(rawDataBuffer, out error);

            byte[] managedBytes = new byte[size];
            Marshal.Copy(start, managedBytes, 0, size);
            NativeMethods.rs2_delete_raw_data(rawDataBuffer);

            return(managedBytes);
        }