COM: serial communication to receive and send via COM ports(H+)

⇒Home ⇒Contents ⇒more on Input-Output
(⇒Optional Keywords Syntax)

Bookmarks:
  ⇒control and debug com port i/o   ⇒initialize com port   ⇒read from com port   ⇒write to com port

Optional keywords:
Bauds CheckSum ChecksumBits ChecksumVal Comport DataBits DouBLe Echo ERror ExitOnInput IgnoreInput Lastchar LastcharX OnErroritem Parity Receive Send StopBits Timeout WaitBIts Waitbyte
setup options type mini sample

initialize COM port

Comport

num c=4 serial port (1-8), default is 1

Bauds

num b=9600 baudrate, default is 9600
possible baudrates: 110, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200

Parity

txt p="odd" "None", "Odd", "Even", "Mark", "Space", default is "E"

DataBits

num db=8 5-8, default is 8

StopBits

num sb=1.5 1, 1.5 or 2. Default is 2
  • COM(Com=Port, B=BAUDS, P=Parity, DB=DataBits, SB=StopBits, Echo=echo)
output options

write to COM port

Send

txt s=text send up to LEN(text) bytes

CheckSum

--- cs send current 1 byte checksum

ExitOnInput

TXT eoi=intrpt stop sending if any byte is received
  • COM(Send=":", ChkBits=8, Send="Alice to Bob "//TRIM(text)//". OK?", ChkSum)
input options

read from COM port

Receive

TXT r=text receive up to LEN(text) bytes

IgnoreInput

TXT ii=last empty input buffer except last byte

Timeout

num t=100 maximum time in msec to wait for next input byte

Waitbyte

txt w="x" ignore all input up to "x", an error is generated on Timeout

WaitBIts

num wbi=128 ignore input until the specific bit pattern is found, an error is generated on Timeout
CheckSum --- cs compare current checksum (excluding the last byte) with the last byte
  • rc = COM(Timeout=3000, Wait=":", Last="?", ChkBits=8, Receive=txt, R=c1, ChkSum)
control options

control and debug COM port i/o

ChecksumBits

num cb=7
  • start lowbits checksum (in or out), default is 8
  • cb=0: IEOR(sum, ICHAR(byte)) (LRC)

ChecksumVal

NUM cv=sum set argument to current checksum

DouBLe

txt dbl=DLE doubles DLE for

next

send or receive

Echo

num e=hdle for debugging echo all COM port traffic to
  • WINDOW(WIN=handle, font="terminal") ! the terminal font has equal character spacing and shows (DOS) symbols for nonprintable characters

Lastchar

txt l="x" send/receive up to and including the occurence of first "x"

LastcharX

txt lx=$CR send/receive up to but excluding the first $CR character

OnErroritem

num oei=3 on error continue with item 3. If this item does not exist return with returncode = itemnr (useful to debug)

ERror

LBL er=99 on error jump to error label 99

How your donation will be used, and how to get a HicEst key code in return


©2000-2010 Georg Petrich, HicEst Instant Prototype Computing. All rights reserved.
Impressum