The high-performance event interface for native (C/C++) listeners.
This is a local interface, which means that it can only be used by the in-proc binary compatible clients, written, for example, in unmanaged C++ language.
After you first register your native listener with a call to IMonitoring.AddNativeListener method call, your native listener is queried for its capabilities through the call to the INativeListener.GetCaps method. If it returns ACCEPT_RAW
(value is 1
) value, the Serial Monitoring Control library will call the INativeListener.ProcessRAWBuffer with a pointer to a raw buffer. The raw buffer contains unparsed monitored data. This is the fastest method of getting data from the Serial Monitoring Control library. Using this method, you will be able to match the performance of the HHD Software Serial Monitor application. Note, that the raw listeners never get their OnXXX
methods called. All data is passed to the ProcessRAWBuffer
method and you must parse the data in your code. If you want the control to parse data for you, do not return ACCEPT_RAW
value from the GetCaps
method.
If your GetCaps
method returns zero, the control will parse the monitored data and call one of the following OnXXX
methods, described below. For performance reasons, if one of the methods ever returns E_NOTIMPL
error code, the control will stop parsing the corresponding request type and stop calling not implemented methods for your listener object. If you have multiple listeners registered for the single monitoring object, and one of your listeners returns E_NOTIMPL for one of the events, the control still continues processing and calling the method for other registered listeners.
Note, that the GetCaps
method is called immediately after you register your listener. The control will not call the method anymore, so you cannot change the type of the listener once it has been determined.
// This interface is not available in scripting environment
// This interface is not available in managed environment
struct INativeListener : IDispatch
{
// Methods
DWORD ${GetCaps}();
HRESULT ${ProcessRAWBuffer}(void * pData, DWORD Size);
HRESULT ${OnConnection}(FILETIME * fTime, BOOL bConnected, LPCTSTR DeviceName);
HRESULT ${OnOpen}(FILTIME * fTime, LPCTSTR ProcessName, ULONG ProcessId);
HRESULT ${OnClosed}(FILETIME * fTime);
HRESULT ${OnRead}(FILETIME * fTime, void * pData, ULONG Size);
HRESULT ${OnWrite}(FILETIME * fTime, void * pData, ULONG Size);
HRESULT ${OnTransmit}(FILETIME * fTime, void * pData, ULONG Size);
HRESULT ${OnBaudRate}(FILETIME * fTime, ULONG BaudRate, BOOL bGet);
HRESULT ${OnSerialChars}(FILETIME * fTime,
UCHAR Eof,
UCHAR Error,
UCHAR Break,
UCHAR Event,
UCHAR Xon,
UCHAR Xoff,
BOOL bGet);
HRESULT ${OnCommStatus}(FILETIME * fTime,
ULONG Errors,
ULONG HoldReasons,
ULONG AmountInInQueue,
ULONG AmountInOutQueue,
BOOL EofReceived,
BOOL WaitForImmediate);
HRESULT ${OnDTRRTS}(FILETIME * fTime, BOOL DTR, BOOL RTS);
HRESULT ${OnHandflow}(FILETIME * fTime,
ULONG ControlHandShake,
ULONG FlowReplace,
ULONG XonLimit,
ULONG XoffLimit,
BOOL bGet);
HRESULT ${OnLineControl}(FILETIME * fTime,
ULONG WordLength,
${STOPBITS} StopBits,
${PARITY} Parity,
BOOL bGet);
HRESULT ${OnStats}(FILETIME * fTime,
ULONG ReceivedCount,
ULONG TransmittedCount,
ULONG FrameErrorCount,
ULONG SerialOverrunErrorCount,
ULONG BufferOverrunErrorCount,
ULONG ParityErrorCount);
HRESULT ${OnTimeouts}(FILETIME * fTime,
ULONG ReadIntervalTimeout,
ULONG ReadTotalTimeoutMultiplier,
ULONG ReadTotalTimeoutConstant,
ULONG WriteTotalTimeoutMultiplier,
ULONG WriteTotalTimeoutConstant,
BOOL bGet);
HRESULT ${OnWaitMask}(FILETIME * fTime, ${EVENTS} WaitMask, BOOL bGet);
HRESULT ${OnPurge}(FILETIME * fTime, ${PURGE} Purge);
HRESULT ${OnSetQueueSize}(FILETIME * fTime, ULONG InSize, ULONG OutSize);
HRESULT ${OnSetBreak}(FILETIME * fTime, BOOL bOn);
HRESULT ${OnDTR}(FILETIME * fTime, BOOL bSet);
HRESULT ${OnReset}(FILETIME * fTime);
HRESULT ${OnRTS}(FILETIME * fTime, BOOL bSet);
HRESULT ${OnXOFF}(FILETIME * fTime);
HRESULT ${OnXON}(FILETIME * fTime);
HRESULT ${OnWaitOnMask}(FILETIME * fTime, ${EVENTS} WaitMask);
HRESULT ${OnGetModemStatus}(FILETIME * fTime, ${MODEMSTATUS} ModemStatus);
HRESULT ${OnGetProperties}(FILETIME * fTime,
USHORT PacketLength,
USHORT PacketVersion,
ULONG MaxTxQueue,
ULONG MaxRxQueue,
ULONG CurrentTxQueue,
ULONG CurrentRxQueue,
${BAUDRATES} MaxBaudRate,
${PROVIDERTYPE} ProviderType,
${PROVIDERCAPS} ProviderCaps,
${PROVIDERSETTABLE} ProviderSettableParams,
${BAUDRATES} SettableBaudRates,
${DATABITS_ST} SettableData,
${STOPPARITY_ST} SettableStopParity);
HRESULT ${OnClearStats}(FILETIME * fTime);
};
// This method is not available in scripting environment
// This method is not available in managed environment
DWORD GetCaps();
Return the listener capabilities to the Monitor. If your listener returns ACCEPT_RAW
value, it is considered the raw listener. The library will not parse the monitored data for a raw listener, instead, it will pass all data (buffered) to the INativeListener.ProcessRAWBuffer method.
This method is called only once.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT ProcessRAWBuffer(void * pData, DWORD Size);
pData
Size
pData
parameter.Called by the control to process the monitored events at the lowest possible level. You will find the documentation for the raw processing in a separate topic.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnConnection(FILETIME * fTime, BOOL bConnected, LPCTSTR DeviceName);
fTime
bConnected
DeviceName
Called when the control attaches/detaches itself to/from the serial device.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnOpen(FILTIME * fTime, LPCTSTR ProcessName, ULONG ProcessId);
fTime
ProcessName
ProcessId
Called when the device is opened by monitored application.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnClosed(FILETIME * fTime);
fTime
Called when the device is closed by monitored application.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnRead(FILETIME * fTime, void * pData, ULONG Size);
fTime
pData
Size
pData
parameter.Called when the monitored application is reading data.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnWrite(FILETIME * fTime, void * pData, ULONG Size);
fTime
pData
Size
pData
parameter.Called when the monitored application is writing data.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnTransmit(FILETIME * fTime, void * pData, ULONG Size);
fTime
pData
Size
pData
parameter.Called when the monitored application is transmitting data.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnBaudRate(FILETIME * fTime, ULONG BaudRate, BOOL bGet);
fTime
BaudRate
bGet
TRUE
if application is reading current baud rate, or FALSE
if it is changing it.Called when the monitored application retrieves/sets current baud rate.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnSerialChars(FILETIME * fTime,
UCHAR Eof,
UCHAR Error,
UCHAR Break,
UCHAR Event,
UCHAR Xon,
UCHAR Xoff,
BOOL bGet);
fTime
Eof
Error
Break
Event
Xon
Xoff
bGet
TRUE
if application is reading special characters, or FALSE
if it is changing them.Called when the monitored application retrieves/sets special serial characters.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnCommStatus(FILETIME * fTime,
ULONG Errors,
ULONG HoldReasons,
ULONG AmountInInQueue,
ULONG AmountInOutQueue,
BOOL EofReceived,
BOOL WaitForImmediate);
fTime
Errors
HoldReasons
AmountInInQueue
AmountInOutQueue
EofReceived
TRUE
if the EOF
has been received.WaitForImmediate
TRUE
if the port is in wait state.Called when the monitored application reads the comm port status.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnDTRRTS(FILETIME * fTime, BOOL DTR, BOOL RTS);
fTime
DTR
RTS
Called when the monitored application retrieves DTR and RTS line states.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnHandflow(FILETIME * fTime,
ULONG ControlHandShake,
ULONG FlowReplace,
ULONG XonLimit,
ULONG XoffLimit,
BOOL bGet);
fTime
ControlHandShake
FlowReplace
XonLimit
XoffLimit
bGet
TRUE
if the application reads the handshake information or FALSE
otherwise.// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnLineControl(FILETIME * fTime,
ULONG WordLength,
${STOPBITS} StopBits,
${PARITY} Parity,
BOOL bGet);
Called when the monitored application retrieves/sets the line control options (such as stop bits, parity and word length).
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnStats(FILETIME * fTime,
ULONG ReceivedCount,
ULONG TransmittedCount,
ULONG FrameErrorCount,
ULONG SerialOverrunErrorCount,
ULONG BufferOverrunErrorCount,
ULONG ParityErrorCount);
fTime
ReceivedCount
TransmittedCount
FrameErrorCount
SerialOverrunErrorCount
BufferOverrunErrorCount
ParityErrorCount
Called when the monitored application reads port statistics.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnTimeouts(FILETIME * fTime,
ULONG ReadIntervalTimeout,
ULONG ReadTotalTimeoutMultiplier,
ULONG ReadTotalTimeoutConstant,
ULONG WriteTotalTimeoutMultiplier,
ULONG WriteTotalTimeoutConstant,
BOOL bGet);
fTime
ReadIntervalTimeout
ReadTotalTimeoutMultiplier
ReadTotalTimeoutConstant
WriteTotalTimeoutMultiplier
WriteTotalTimeoutConstant
bGet
TRUE
if the application reads this information or FALSE
otherwise.Called when the monitored application retrieves/sets port timeouts.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnWaitMask(FILETIME * fTime, ${EVENTS} WaitMask, BOOL bGet);
fTime
WaitMask
bGet
TRUE
if the monitored application reads the wait mask or FALSE
otherwise.Called when the monitored application retrieves/sets the wait mask.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnPurge(FILETIME * fTime, ${PURGE} Purge);
fTime
Purge
Called when the monitored application purges the port.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnSetQueueSize(FILETIME * fTime, ULONG InSize, ULONG OutSize);
fTime
InSize
OutSize
Called when the monitored application sets queue sizes.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnSetBreak(FILETIME * fTime, BOOL bOn);
fTime
bOn
TRUE
if application sets the break signal, or FALSE
otherwise.Called when the monitored application sets/resets the break signal.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnDTR(FILETIME * fTime, BOOL bSet);
fTime
bSet
TRUE
if the application sets the DTR line state, or FALSE
if the application resets it.Called when the monitored application sets/resets DTR line state.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnReset(FILETIME * fTime);
fTime
Called when the monitored application resets the port.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnRTS(FILETIME * fTime, BOOL bSet);
fTime
bSet
TRUE
if the application sets the RTS line state, or FALSE
if the application resets it.Called when the monitored application sets/resets RTS line state.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnXOFF(FILETIME * fTime);
fTime
Called when the monitored application sends the XOFF character.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnXON(FILETIME * fTime);
fTime
Called when the monitored application sends the XON character.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnWaitOnMask(FILETIME * fTime, ${EVENTS} WaitMask);
fTime
WaitMask
Called when the monitored application waits on mask.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnGetModemStatus(FILETIME * fTime, ${MODEMSTATUS} ModemStatus);
fTime
ModemStatus
Called when the monitored application reads the modem status.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnGetProperties(FILETIME * fTime,
USHORT PacketLength,
USHORT PacketVersion,
ULONG MaxTxQueue,
ULONG MaxRxQueue,
ULONG CurrentTxQueue,
ULONG CurrentRxQueue,
${BAUDRATES} MaxBaudRate,
${PROVIDERTYPE} ProviderType,
${PROVIDERCAPS} ProviderCaps,
${PROVIDERSETTABLE} ProviderSettableParams,
${BAUDRATES} SettableBaudRates,
${DATABITS_ST} SettableData,
${STOPPARITY_ST} SettableStopParity);
fTime
PacketLength
PacketVersion
MaxTxQueue
MaxRxQueue
CurrentTxQueue
CurrentRxQueue
MaxBaudRate
ProviderType
ProviderCaps
ProviderSettableParams
SettableBaudRates
SettableData
SettableStopParity
Called when the monitored application retrieves the comm properties.
// This method is not available in scripting environment
// This method is not available in managed environment
HRESULT OnClearStats(FILETIME * fTime);
fTime
Called when the monitored application clears the statistics.