FTD2XX_NET.FTDI.SetCharacters C# (CSharp) Method

SetCharacters() public method

Sets an event character, an error character and enables or disables them.
public SetCharacters ( byte EventChar, bool EventCharEnable, byte ErrorChar, bool ErrorCharEnable ) : FT_STATUS
EventChar byte A character that will be tigger an IN to the host when this character is received.
EventCharEnable bool Determines if the EventChar is enabled or disabled.
ErrorChar byte A character that will be inserted into the data stream to indicate that an error has occurred.
ErrorCharEnable bool Determines if the ErrorChar is enabled or disabled.
return FT_STATUS
        public FT_STATUS SetCharacters(byte EventChar, bool EventCharEnable, byte ErrorChar, bool ErrorCharEnable)
        {
            // Initialise ftStatus to something other than FT_OK
            FT_STATUS ftStatus = FT_STATUS.FT_OTHER_ERROR;

            // If the DLL hasn't been loaded, just return here
            if (hFTD2XXDLL == IntPtr.Zero)
                return ftStatus;

            // Check for our required function pointers being set up
            if (pFT_SetChars != IntPtr.Zero)
            {
                tFT_SetChars FT_SetChars = (tFT_SetChars)Marshal.GetDelegateForFunctionPointer(pFT_SetChars, typeof(tFT_SetChars));

                if (ftHandle != IntPtr.Zero)
                {
                    // Call FT_SetChars
                    ftStatus = FT_SetChars(ftHandle, EventChar, Convert.ToByte(EventCharEnable), ErrorChar, Convert.ToByte(ErrorCharEnable));
                }
            }
            else
            {
                if (pFT_SetChars == IntPtr.Zero)
                {
                    LogB.Debug("FTD2XX: Failed to load function FT_SetChars.");
                }
            }
            return ftStatus;
        }