public interface ISerialComDataListener
The interface ISerialComDataListener should be implemented by class who wish to receive data from serial port.
| Modifier and Type | Method and Description |
|---|---|
void |
onDataListenerError(int errorNum)
This method is called whenever an error occurred the data listener mechanism.
|
void |
onNewSerialDataAvailable(byte[] data)
This method is called whenever data is received on serial port.
|
void onNewSerialDataAvailable(byte[] data)
This method is called whenever data is received on serial port.
The class implementing this interface is expected to override onNewSerialDataAvailable() method. This method gets called from the looper thread associated with the corresponding listener (handler).
Application may tune the behavior by using fineTuneReadBehaviour() API.
data - bytes read from serial port.void onDataListenerError(int errorNum)
This method is called whenever an error occurred the data listener mechanism.
This methods helps in creating fault-tolerant and recoverable application design in case unexpected situations like serial port removal, bug encountered in OS or driver during operation occurs. In a nutshell situations which are outside the scope of scm may be handled using this method.
Developer can implement different recovery policies like unregister listener, close com port and then open and register listener again. Another policy might be to send email to system administrator so that he can take appropriate actions to recover from situation.
Swing/AWT GUI applications might play beep sound to inform user about port addition or removal.
errorNum - operating system specific error numberCopyright © 2017. All rights reserved.