예제 #1
0
        /// <summary>
        /// Pops the COM port configuration dialog and returns the selected settings.
        /// </summary>
        /// <exception cref="OperationCanceledException">Thrown if the dialog is cancelled.</exception>
        public unsafe static CommunicationsConfig CommunicationsConfigDialog(string port, WindowHandle parent)
        {
            CommunicationsConfig config = GetDefaultCommunicationsConfig(port);

            Error.ThrowLastErrorIfFalse(
                Imports.CommConfigDialogW(port, parent, ref config));

            return(config);
        }
예제 #2
0
        /// <summary>
        /// Get the default config values for the given com port.
        /// </summary>
        /// <param name="port">Simple name only (COM1, not \\.\COM1)</param>
        public unsafe static CommunicationsConfig GetDefaultCommunicationsConfig(string port)
        {
            CommunicationsConfig config = new CommunicationsConfig();
            uint size = (uint)sizeof(CommunicationsConfig);

            Error.ThrowLastErrorIfFalse(
                Imports.GetDefaultCommConfigW(port, ref config, ref size));

            return(config);
        }
예제 #3
0
        public unsafe static CommunicationsConfig GetCommunicationsConfig(SafeFileHandle fileHandle)
        {
            CommunicationsConfig config = new CommunicationsConfig();
            uint size = (uint)sizeof(CommunicationsConfig);

            Error.ThrowLastErrorIfFalse(
                Imports.GetCommConfig(fileHandle, ref config, ref size));

            return(config);
        }
예제 #4
0
        /// <summary>
        /// Pops the COM port configuration dialog and returns the selected settings.
        /// </summary>
        /// <exception cref="OperationCanceledException">Thrown if the dialog is cancelled.</exception>
        public unsafe static CommunicationsConfig CommunicationsConfigDialog(string port, WindowHandle parent)
        {
            CommunicationsConfig config = GetDefaultCommunicationsConfig(port);

            if (!Imports.CommConfigDialogW(port, parent, ref config))
            {
                throw Error.GetExceptionForLastError();
            }

            return(config);
        }
예제 #5
0
        /// <summary>
        /// Get the default config values for the given com port.
        /// </summary>
        /// <param name="port">Simple name only (COM1, not \\.\COM1)</param>
        public unsafe static CommunicationsConfig GetDefaultCommunicationsConfig(string port)
        {
            CommunicationsConfig config = new CommunicationsConfig();
            uint size = (uint)sizeof(CommunicationsConfig);

            if (!Imports.GetDefaultCommConfigW(port, ref config, ref size))
            {
                throw Error.GetExceptionForLastError();
            }

            return(config);
        }
예제 #6
0
        public unsafe static CommunicationsConfig GetCommunicationsConfig(SafeFileHandle fileHandle)
        {
            CommunicationsConfig config = new CommunicationsConfig();
            uint size = (uint)sizeof(CommunicationsConfig);

            if (!Imports.GetCommConfig(fileHandle, ref config, ref size))
            {
                throw Error.GetExceptionForLastError();
            }

            return(config);
        }