state Init
// commands here
end state
Char Hex Meaning
==== ==== =======
NUL 0x00 Ctrl-@ | NULL
SOH 0x01 Ctrl-A | START OF HEADING
STX 0x02 Ctrl-B | START OF TEXT
ETX 0x03 Ctrl-C | END OF TEXT
EOT 0x04 Ctrl-D | END OF TRANSMISSION
ENQ 0x05 Ctrl-E | ENQUIRY
ACK 0x06 Ctrl-F | ACKNOWLEDGE
BEL 0x07 Ctrl-G | BELL
BS 0x08 Ctrl-H | BACKSPACE
HT 0x09 Ctrl-I | HORIZONTAL TABULATION
LF 0x0A Ctrl-J | LINE FEED
VT 0x0B Ctrl-K | VERTICAL TABULATION
FF 0x0C Ctrl-L | FORM FEED
CR 0x0D Ctrl-M | CARRIAGE RETURN
SO 0x0E Ctrl-N | SHIFT OUT
SI 0x0F Ctrl-O | SHIFT IN
DLE 0x10 Ctrl-P | DATA LINK ESCAPE
DC1 0x11 Ctrl-Q | DEVICE CONTROL 1
DC2 0x12 Ctrl-R | DEVICE CONTROL 2
DC3 0x13 Ctrl-S | DEVICE CONTROL 3
DC4 0x14 Ctrl-T | DEVICE CONTROL 4
NAK 0x15 Ctrl-U | NEGATIVE ACKNOWLEDGE
SYN 0x16 Ctrl-V | SYNCHRONOUS IDLE
ETB 0x17 Ctrl-W | END OF TRANSMISSION BLOCK
CAN 0x18 Ctrl-X | CANCEL
EM 0x19 Ctrl-Y | END OF MEDIUM
SUB 0x1A Ctrl-Z | SUBSTITUTE
ESC 0x1B Ctrl-[ | ESCAPE
FS 0x1C Ctrl-\ | FILE SEPARATOR
GS 0x1D Ctrl-] | GROUP SEPARATOR
RS 0x1E Ctrl-^ | RECORD SEPARATOR
US 0x1F Ctrl-_ | UNIT SEPARATOR
DEL 0x7F Ctrl-? | DELETE
state Init
send("<ACK>");
end state
NOTE: Control characters must be enclosed with prefix "<" and suffix ">"
state Init
// define a global variable
our $BUFFER = "";
jump(Receive);
end state
state Receive
recv();
$len = length($DATA_PACKET);
if("$len > 0") {
// 1. buffer the incoming data
$BUFFER += $DATA_PACKET;
call(Parser);
}
end state
state Parser
// 2. scan your buffer to find complete data
// command "match" will check if buffer matches a regular expression
if(match($BUFFER, "(?<WILLDELETE>.*?<STX>(?<DATA>.*?)<ETX>(?<CHECKSUM>[0-9A-F]{2}))")) {
// Received complete data
// 3. remove the used data from the buffer
$lenData = length($WILLDELETE);
$BUFFER = remove($BUFFER, 0, $lenData);
// Do operations with the other parsed fields. $DATA and $CHECKSUM in this example.
}
end state
The application provides many, many options and abilities to help you work with serial ports. It supports a rich programming language, including variables, expression evaluation, debugging, ... you name it. It supports over 50 useful commands -- too many to describe in this article.
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (2)
Commented:
One of the very first projects I worked on (back in about 1980), was an interpretive language for use in controlling a modem during the log-in process when connecting to remote host systems (such as CompuServe). It is VERY useful to be able to just tweak a script and retry -- much better than re-coding!
Author
Commented:Yes, I hate re-compile big projects over and over again.That is why I developed this application.
by the way I will appreciate, if you can change the link.
Thank you again.