

Int errnum = Marshal.GetLastWin32Error () Static extern IntPtr strerror (int errnum) Private bool Poll(Stream stream, int timeout)īool poll_result = poll_serial (fd, out error, ReadTimeout) Static extern bool poll_serial (int fd, out int error, int timeout) SerialDataReceivedEventHandler handler = (SerialDataReceivedEventHandler) Events Void OnDataReceived (SerialDataReceivedEventArgs args)

Return id = PlatformID.Win32Windows || id = PlatformID.Win32NT // WinCE not supported New (new (this.EventThreadFunction)).Start() Public EnhancedSerialPort (string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits):base(portName, baudRate, parity, dataBits,stopBits)įieldInfo fieldInfo = BaseStream.GetType().GetField("fd", BindingFlags.Instance | BindingFlags.NonPublic) įd = (int)fieldInfo.GetValue(BaseStream) ĭisposedFieldInfo = BaseStream.GetType().GetField("disposed", BindingFlags.Instance | BindingFlags.NonPublic) įieldInfo = typeof(SerialPort).GetField("data_received", BindingFlags.Instance | BindingFlags.NonPublic) ĭata_received = fieldInfo.GetValue(this) Public EnhancedSerialPort (string portName, int baudRate, Parity parity, int dataBits) : base(portName, baudRate, parity, dataBits) Public EnhancedSerialPort (string portName, int baudRate, Parity parity) : base(portName, baudRate, parity) Public EnhancedSerialPort (string portName, int baudRate) :base(portName, baudRate) Public EnhancedSerialPort (string portName) : base(portName) Public EnhancedSerialPort (IContainer container) : base (container) Public class EnhancedSerialPort : SerialPort See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS, Unless required by applicable law or agreed to in writing, software You may obtain a copy of the License at you may not use this file except in compliance with the License.

Licensed under the Apache License, Version 2.0 (the "License")

SerialPort.Open() is not a virtual method, therefore I have hidden the method in order to add the thread creation.The only constructor of Mono SerialDataReceivedEventArgs class is marked internal and I have not figured out how to create the objects yet. currently DataReceived (object sender, SerialDataReceivedEventArgs e) event handler gets null value for parameter e.In case of future changes in Mono the application will break reflection is used to access three private members by their names.a standard Mono distribution can be used.Here is a derived class that does the same. The previous approach required rebuilding Mono with a small patch.
