|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.discotools.io.aprs.tnc.TncDialect
public class TncDialect
TNC terminal mode dialect declaration class.
Terminal mode allows clients to communicate with the TNC using “english-like” command strings.
Following sentences are required:
S_HEAD
- Packet header sequence
Field Summary | |
---|---|
static String |
A_DELIMITER
DELIMITER argument in a dialect understood by target TNC (TERMINAL mode only). |
static String |
A_OFF
OFF argument in a dialect understood by target TNC. |
static String |
A_ON
ON argument in a dialect understood by target TNC. |
static String |
B_RESET
RESET command batch in a dialect understood by target TNC. |
static String |
B_SETUP
SETUP command batch in a dialect understood by target TNC. |
static String |
C_BAUD
BAUD command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_COMMENT
COMMENT command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_COMPRESS
COMPRESS command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_DISPLAY
DISPLAY command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_MODE
MODE command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_MYCALL
MYCALL command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_POSITION
POSITION command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_STATUS
STATUS command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_SYMBOL
SYMBOL command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_TIMESTAMP
TIMESTAMP command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_VELOCITY
VELOCITY command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
C_VERSION
VERSION command in a dialect understood by target TNC (TERMINAL mode only). |
static String |
D_DELIMITER
Default delimiter. |
static String |
D_OFF
Default OFF argument value. |
static String |
D_ON
Default ON argument value. |
static String |
D_TIMEOUT
Default timeout (in milliseconds). |
static String |
K_ENTER
ENTER key in a dialect understood by target TNC (TERMINAL mode only). |
static String |
R_BAUD
TNC response to C_BAUD . |
static String |
R_COMMENT
TNC response to C_COMMENT . |
static String |
R_COMPRESS
TNC response to C_COMPRESS . |
static String |
R_DISPLAY
TNC response to C_DISPLAY . |
static String |
R_MODE
TNC response to C_MODE . |
static String |
R_MYCALL
TNC response to C_MYCALL . |
static String |
R_POSITION
TNC response to C_POSITION . |
static String |
R_RESET
TNC response to B_RESET . |
static String |
R_SETUP
TNC responses to B_SETUP . |
static String |
R_STATUS
TNC response to C_STATUS . |
static String |
R_SYMBOL
TNC response to C_SYMBOL . |
static String |
R_TERMINAL
Command prompt text returned by TNC in TERMINAL mode as a response to K_ENTER without any command text. |
static String |
R_TIMESTAMP
TNC response to C_TIMESTAMP . |
static String |
R_VELOCITY
TNC response to C_VELOCITY . |
static String |
R_VERSION
TNC response to C_VERSION . |
static Set<String> |
REQUIRED
Set of required sentences. |
static String |
S_HEAD
Characters which mark the start of a TNC terminal mode sentence. |
static String |
S_TAIL
Characters which mark the end of a TNC terminal mode sentence. |
static String |
S_TIMEOUT
TNC terminal mode sentence timeout (in milliseconds). |
Constructor Summary | |
---|---|
TncDialect(InputStream dialect)
Construct dialect from InputStream
The stream is kept open after this construction
|
|
TncDialect(Properties dialect)
Construct dialect from Properties
Given properties are copied (dialects are immutable)
|
|
TncDialect(String file)
Construct dialect from file. |
|
TncDialect(URL url)
Construct dialect from URL. |
Method Summary | |
---|---|
String[] |
batch(String sentence,
Object... args)
Lookup command batch |
String |
command(String sentence,
boolean isOn)
Lookup command on the format: COMMAND ON | OFF |
String |
command(String sentence,
Object... args)
Lookup command on the format: COMMAND [arg1... |
String |
get(String sentence)
Lookup given dialect sentence (see public constants). |
String |
get(String sentence,
String use)
Lookup given dialect sentence (see public constants). |
String |
getCOMMENT(String comment)
Lookup C_COMMENT command. |
String |
getCOMPRESS(boolean isOn)
Lookup C_COMPRESS command. |
String |
getDELIMITER()
Lookup A_DELIMITER argument value. |
String |
getENTER()
Lookup K_ENTER key. |
byte[] |
getHEAD()
Lookup sentence S_HEAD (terminator). |
String |
getOFF()
Lookup A_OFF argument value. |
String |
getON()
Lookup A_ON argument value. |
String |
getPOSITION(String argument)
Lookup C_POSITION command. |
String |
getRESET()
Lookup B_RESET command |
String |
getSETUP()
Lookup B_SETUP command batch |
byte[] |
getTAIL()
Lookup sentence S_TAIL (terminator). |
String |
getTERMINAL()
Lookup R_TERMINAL response value. |
String |
getTIMEOUT()
Lookup sentence S_TIMEOUT value. |
boolean |
isBatch(String sentence)
Check if given string is a supported command. |
boolean |
isCommand(String sentence)
Check if given string is a supported command. |
boolean |
isResponse(String command,
String response)
Check if given payload is response to given command. |
boolean |
isTerminal(String response)
Check if given string is a R_TERMINAL response. |
protected void |
prepare()
|
boolean |
supports(String sentence)
Check if TNC supports (understand) given sentence |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String S_HEAD
NOTE: You can specify any Unicode character with a \uXXXX escape sequence. Use this to encode non-printable ASCII characters.
public static final String S_TAIL
NOTE: You can specify any Unicode character with a \uXXXX escape sequence. Use this to encode non-printable ASCII characters.
public static final String S_TIMEOUT
Used by TncProtocol
to determine command response timeout.
Default value is "1000".
#D_TIMEOUT}.
,
Constant Field Valuespublic static final String A_ON
Default value is "ON".
public static final String A_OFF
Default value is "OFF".
public static final String A_DELIMITER
This key delimit each commands in a command batch. Default: ';'
TncDialect#B_SETUP} - Setup command batch
,
TncDialect#B_RESET} - Reset command batch
,
Constant Field Valuespublic static final String D_ON
public static final String D_OFF
public static final String D_DELIMITER
public static final String D_TIMEOUT
public static final String K_ENTER
This key instructs the TNC to run previously transmitted command.
public static final String R_TERMINAL
K_ENTER
without any command text.
String comparison is case-insensitive and regexp is supported.
The framework use this to:
public static final String B_SETUP
This batch is typically executed by the TncProtocol
immediately after a serial connection is established. It is usually
a series of commands which enters the TNC into the communication
mode implemented by the protocol.
Each response must be delimited by the D_DELIMITER
character.
For example, a
Tracker2
TNC is in terminal mode on port A, but the protocol requested is KISS.
The protocol performs a B_SETUP
lookup which returns the
following commands:
ABAUD 9600 AMODE KISSwhich forces the TNC into KISS mode.
This command batch is accompanied by B_RESET
, which is
typically executed just before the connection is closed.
The general idea here is to leave the TNC in the same state as
it was before before #C_SETUP
was performed.
Although this command batch is usually executed in pairs with
B_RESET
, it could be performed at any point by the
client code or the framework if necessary.
public static final String R_SETUP
B_SETUP
.
Each response must be delimited by the D_DELIMITER
character.
String comparison is case-insensitive and regexp is supported.
public static final String B_RESET
This command is typically executed by the protocol just
before the serial connection is closed. The general idea here
is to leave the TNC in the same state as it was before before
#C_SETUP
was performed.
Each response must be delimited by the D_DELIMITER
character.
Although this command batch is usually executed in pairs with
B_SETUP
, it could be performed at any point by the
client code or the framework if necessary.
public static final String R_RESET
B_RESET
.
String comparison is case-insensitive and regexp is supported.
public static final String C_BAUD
Sets baud rate for serial port. Default is 4800 baud.
public static final String R_BAUD
C_BAUD
.
String comparison is case-insensitive and regexp is supported.
public static final String C_MODE
Sets mode for primary serial port.
public static final String R_MODE
C_MODE
.
String comparison is case-insensitive and regexp is supported.
public static final String C_MYCALL
Sets the TNC's callsign and optional SSID: <xxxxxx-nn>
public static final String R_MYCALL
C_MYCALL
.
String comparison is case-insensitive and regexp is supported.
public static final String C_COMMENT
Sets beacon text / comment string.
public static final String R_COMMENT
C_COMMENT
.
String comparison is case-insensitive and regexp is supported.
public static final String C_COMPRESS
Enables Base91 compressed format for position transmissions.
public static final String R_COMPRESS
C_COMPRESS
.
String comparison is case-insensitive and regexp is supported.
public static final String C_POSITION
Sets fixed position or enable GPS: <hhmm.mmx hhhmm.mmx> | GPS
public static final String R_POSITION
C_POSITION
.
String comparison is case-insensitive and regexp is supported.
public static final String C_STATUS
Status packets are sent every n transmissions, or if set to 0, status text is sent as part of the position packet.
public static final String R_STATUS
C_STATUS
.
String comparison is case-insensitive and regexp is supported.
public static final String C_SYMBOL
APRS symbol character, optionally preceded by symbol table or overlay identifier.
public static final String R_SYMBOL
C_SYMBOL
.
String comparison is case-insensitive and regexp is supported.
public static final String C_TIMESTAMP
Report time information in the position packet.
public static final String R_TIMESTAMP
C_TIMESTAMP
.
String comparison is case-insensitive and regexp is supported.
public static final String C_VELOCITY
Enables transmission of velocity (course and speed) information in the position packet.
public static final String R_VELOCITY
C_VELOCITY
.
String comparison is case-insensitive and regexp is supported.
public static final String C_DISPLAY
Lists all configuration parameters.
public static final String R_DISPLAY
C_DISPLAY
.
String comparison is case-insensitive and regexp is supported.
public static final String C_VERSION
Displays firmware version number.
public static final String R_VERSION
C_VERSION
.
String comparison is case-insensitive and regexp is supported.
public static final Set<String> REQUIRED
Constructor Detail |
---|
public TncDialect(String file) throws IOException
dialect
- - InputStream
instance
IOException
public TncDialect(URL url) throws IOException
dialect
- - InputStream
instance
IOException
ClassLoader#getSystemResource(String)}
public TncDialect(InputStream dialect) throws IOException
InputStream
The stream is kept open after this construction
dialect
- - InputStream
instance
IOException
ClassLoader#getSystemResource(String)}
public TncDialect(Properties dialect)
Properties
Given properties are copied (dialects are immutable)
dialect
- - Properties
instanceMethod Detail |
---|
public boolean supports(String sentence)
sentence
- - see public constants.public boolean isCommand(String sentence)
sentence
- - sentence part of dialectpublic boolean isBatch(String sentence)
sentence
- - sentence part of dialectpublic boolean isTerminal(String response)
R_TERMINAL
response.
response
- - received payloadpublic boolean isResponse(String command, String response)
response
- - received payloadpublic String get(String sentence)
public String get(String sentence, String use)
public String command(String sentence, boolean isOn)
ON
| OFF
sentence
- - command sentenceisOn
- - if true
, ON
is used,
OFF
otherwise
public String command(String sentence, Object... args)
sentence
- - command sentenceargs
- - optional array
public String[] batch(String sentence, Object... args)
sentence
- - command sentenceargs
- - optional array
public byte[] getHEAD()
S_HEAD
(terminator).
public byte[] getTAIL()
S_TAIL
(terminator).
public String getENTER()
K_ENTER
key.
public String getDELIMITER()
A_DELIMITER
argument value.
public String getTIMEOUT()
S_TIMEOUT
value.
public String getON()
A_ON
argument value.
public String getOFF()
A_OFF
argument value.
public String getTERMINAL()
R_TERMINAL
response value.
public String getCOMMENT(String comment)
C_COMMENT
command.
public String getCOMPRESS(boolean isOn)
C_COMPRESS
command.
public String getPOSITION(String argument)
C_POSITION
command.
public String getSETUP()
B_SETUP
command batch
public String getRESET()
B_RESET
command
public String toString()
toString
in class Object
protected void prepare() throws IllegalArgumentException
IllegalArgumentException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |