public class AsyncSerialPortCommunicator extends Object implements gnu.io.SerialPortEventListener
Modifier and Type | Class and Description |
---|---|
static class |
AsyncSerialPortCommunicator.ModemType
Modemtyp.
|
Modifier and Type | Field and Description |
---|---|
private String[] |
antworten
Die Antworten vom Modem.
|
static String |
BUSY
BUSY-Meldung vom Modem.
|
protected String |
com
Name des ComPorts.
|
private static HashMap<String,Object> |
comLock
Comm-Port Lock Objekt.
|
static String |
CONNECT
CONNECT-Meldung vom Modem.
|
protected boolean |
debug
DEBUG.
|
private static long |
DEFAULT_TIMEOUT
Standard-Timeout.
|
static String |
ERROR
ERROR-Meldung vom Modem.
|
protected static de.bsvrz.sys.funclib.debug.Debug |
LOGGER
Der Logger.
|
static String |
NO_ANSWER
NO_ANSWER-Meldung vom Modem.
|
static String |
NO_CARRIER
NO_CARRIER-Meldung vom Modem.
|
static String |
NO_DIALTONE
NO_DIALTONE-Meldung vom Modem.
|
static String |
OK
OK-Antwort vom Modem.
|
private static int |
OPEN_TIMEOUT
Open-Timeout.
|
private static int |
PUFFER_GROESSE
Puffergröße.
|
protected AsyncSerialPortReader |
reader
Der Reader-Worker.
|
static String |
RING
RING-Meldung vom Modem.
|
protected gnu.io.SerialPort |
serialPort
Instanz der RX/TX seriellen Schnittstelle.
|
protected long |
timeout
Defaultwert für timeout = 10 Sekunden.
|
private static int |
WARTEZEIT_THREAD_ENDE
Wartezeit auf das Ende von Threads.
|
protected AsyncSerialPortWriter |
writer
Der Writer-Worker.
|
Constructor and Description |
---|
AsyncSerialPortCommunicator(String com,
int baud,
int inPufferSize,
int outPufferSize,
long timeout,
boolean swFlowControll)
Standardkonstruktor.
|
Modifier and Type | Method and Description |
---|---|
void |
beenden()
Beendet die WorkerThreads und schliesst die Schnittstelle.
|
void |
endBinaerModus()
Beendet den binären Modus.
|
static Object |
getLock(String com)
Gibt das Lock-Objekt für den Port zurück.
|
String |
getName()
Gibtt den Namen des Comm-Ports zurück.
|
long |
getTimeout()
Erfragt den eingestellten Timeout.
|
Collection<String> |
recvAlleATantworten()
Wartet auf eine der erwarteten AT-Antworten oder Timeout.
|
String |
recvATantwort()
Wartet auf eine der erwarteten AT-Antworten oder Timeout.
|
String |
recvATantwort(long waittimeout)
Wartet auf eine der erwarteten AT-Antworten oder einen bestimmten
Timeout.
|
Collection<String> |
recvATantwortMitKontroll()
Wartet bis max Timeout gekommen ist, oder eine von der erkannten AT
Antworten, Im Fall Timeout gekommen ist oder die Antwort ist negativ,
dann wird ein Exception geworfen sonst alle antworte die inzwischen
gekommen sind auser der ersten, die das Echo von dem Kommando ist.
|
String |
recvATResp()
Empfängt eine AT-Antwort.
|
boolean |
recvBytes(byte[] erwartet)
Wartet bis die erwartete ByteKette gekommen ist, oder timeout.
|
boolean |
sendByte(byte b)
Versendet ein Byte ohne modification.
|
boolean |
sendBytes(byte[] cmd)
Versendet Bytes ohne Modifikation.
|
boolean |
sendBytes(byte[] cmd,
int off,
int len)
Versendet Bytes ohne Modifikation.
|
boolean |
sendCmd(long waittimeout,
String cmd)
Versendet ein AT-Kommando.
|
boolean |
sendCmd(String cmd)
Versendet ein AT-Kommando.
|
Collection<String> |
sendCmdMitKontroll(String cmd)
Ein Wrapper für sendCmd + recvATantwortMitKontroll().
|
int |
sendData(byte[] data,
int off,
int len,
boolean reverseBitOrder)
Versendet Daten wobei die DLEs verdoppelt werden.
|
void |
serialEvent(gnu.io.SerialPortEvent event) |
void |
setDebug(boolean debug)
Setzt den Debug Modus.
|
void |
setTimeout(long t)
Stellt den Timeout ein.
|
void |
startBinaerModus()
Startet den binären Modus.
|
void |
test()
Testausgabe Schnittstellenparameter.
|
protected static final de.bsvrz.sys.funclib.debug.Debug LOGGER
public static final String OK
public static final String CONNECT
public static final String RING
public static final String NO_CARRIER
public static final String ERROR
public static final String NO_DIALTONE
public static final String BUSY
public static final String NO_ANSWER
private static final int WARTEZEIT_THREAD_ENDE
private static final long DEFAULT_TIMEOUT
private static final int OPEN_TIMEOUT
private static final int PUFFER_GROESSE
private final String[] antworten
protected gnu.io.SerialPort serialPort
protected AsyncSerialPortReader reader
protected AsyncSerialPortWriter writer
protected boolean debug
protected long timeout
protected String com
public AsyncSerialPortCommunicator(String com, int baud, int inPufferSize, int outPufferSize, long timeout, boolean swFlowControll) throws Exception
com
- Com-Portbaud
- BaudrateinPufferSize
- Grösse des Input-PuffersoutPufferSize
- Grösse des Output-Pufferstimeout
- Timeout in MilisekundenswFlowControll
- true
wenn Software-Datenflusssteuerung benutzt
werden sollException
- Initialisierungsausnahmepublic static Object getLock(String com)
com
- ComPortpublic void beenden()
public void endBinaerModus()
public String getName()
public long getTimeout()
public Collection<String> recvAlleATantworten()
public String recvATantwort()
public String recvATantwort(long waittimeout)
waittimeout
- Timeoutpublic Collection<String> recvATantwortMitKontroll() throws CommunicationException
CommunicationException
- bei Ausnahmenpublic String recvATResp()
public boolean recvBytes(byte[] erwartet)
erwartet
- erwartete ByteKettepublic boolean sendByte(byte b)
b
- ByteKommandopublic boolean sendBytes(byte[] cmd)
cmd
- BytesKommandopublic boolean sendBytes(byte[] cmd, int off, int len)
cmd
- BytesKommandooff
- Offsetlen
- Lengthpublic boolean sendCmd(long waittimeout, String cmd)
waittimeout
- Timeoutcmd
- AT Kommandopublic boolean sendCmd(String cmd)
cmd
- AT Kommandopublic Collection<String> sendCmdMitKontroll(String cmd) throws CommunicationException
cmd
- KommandoCommunicationException
- Fehlerpublic int sendData(byte[] data, int off, int len, boolean reverseBitOrder)
data
- Datenoff
- Offsetlen
- LängereverseBitOrder
- Flag, ob die Bitorder umgekehrt werden sollpublic void serialEvent(gnu.io.SerialPortEvent event)
serialEvent
in interface gnu.io.SerialPortEventListener
public void setDebug(boolean debug)
debug
- true/falsepublic void setTimeout(long t)
t
- Timeout in mspublic void startBinaerModus()
public void test()
Copyright © 2017 BitCtrl Systems GmbH. All rights reserved.