Please note: The Serial I/O protocol can generally read or write any byte string
(i.e. Not necessarily only ASCII character strings)
2
For readability, this example uses Port 1 on the CMM and the status- and control references are mapped to %I1 and %Q1
3
4
Call Read Block
5 #ALW_ON CALL
SIO_Re...
%S00007
6
Call Write Block
7 #ALW_ON CALL
SIO_Wr...
%S00007
8
Extra Commands and Status Bits
The below commands are not used in the Read- and Write blocks above, but may be useful for troubleshooting or recovery
More detail about status- and control bit locations and meaning available in GFK-2460 Chapter 4
9
Reset Port 1 on CMM + Clear Application Input Buffer
10 Reset_Port BLK CLR Q00067
WORD
%Q00067
32 Reset_Port
AI0001 IN R
%AI0001
11
Flush Port 1 Input Buffer (on CMM)
12 Flush_Port Q00083
%Q00083
Flush_Port
R
13
Port 1 is ready (OK)
May be used as permissive
14 I00129 Port_Ready
%I00129
15
Port 1 Receive Error
In this implementation, this bit may be almost always on because the read command is issued continuously and many of them time out
(Actually only off, directly after byte string was successfully received)
16 I00065 Read_Error
%I00065
17
Port 1 Transmit Error
18 I00065 Write_Error
%I00065
%Q00001 %I00001
5
Read Request finished (Read Command Bit = Read Status Bit)
6
Read Requests may also finish through error, timeout or missing data or delimiter, i.e. no (or partial) data received
- Check number of bytes last read. If bytes read > 0, a string (with delimiter) was read and may be copied to the application
7
Copy string read to application memory (AppReadBuffer)
8 ARRAY
MOVE
BYTE
1024
AI0001 SR DS AppReadBu...
%AI0001
1 SNX
1 DNX
BytesRead N
%I00177
9
Toggle read command bit to start next Read Request
10 CmdRead CmdRead
%Q00001 %Q00001
11
SKIP
12
5
No Write Request pending (Write Command Bit = Write Status Bit)
Write status bit 'echoes' write command bit when finished
%Q00002 %I00002
CmdWrite WriteFinish...
%Q00002 %I00002
7
Write ASCII String every 2 seconds when port is ready
8 Tick_Write PortReady TMR Tick_Write
THOUS
TmrWrite
2000 PV CV
9 Tick_Write SKIP
JUMPN
10
Copy string to write from application memory (AppWriteBuffer)
Adjust string length to write
11 ARRAY MOVE
MOVE INT
BYTE
1024 1
AppWriteBu... SR DS AQ0001 12 IN Q BytesToWrite
%AQ0001 %Q00113
1 SNX
1 DNX
12 N
12
Toggle write command bit to start next Write Request
%Q00002 %Q00002
14
SKIP
15