Completed Script
// Receive 1 byte of print permit data from the printer.
if([r:EXT_SIO_RECV]==1) // When number of received data is 1.
{
_strset(databuf0, "") // Initialize data buffer 0.
IO_READ_EX([p:EXT_SIO], databuf0, 1) // Read out to data buffer 0.
_dlcopy([w:[#MEMLINK]0100], databuf0, 0, 1)
// Store values from data buffer 0 to internal device.
}
endif
// Decide if start from print permit data.
if([b:[#MEMLINK]005000]==1 and [b:[#MEMLINK]000100]==0x31) // When printer start switch is ON.
{ // 1 byte of print permit data is 1 (ASCII).
Call INIT // Call initialize communication.
Call PINIT // Call initialize printer.
Call Print // Send print data, start printing.
clear([b:[#MEMLINK]005000]) // Printer start switch OFF.
}
endif
if([b:[#MEMLINK]005000]==1 and [b:[#MEMLINK]000100]==0x30) // When printer start switch is ON.
{ // 1 byte of print permit data is 1 (ASCII).
clear([b:[#MEMLINK]005000]) // Printer start switch OFF.
}
endif
Function Summary
When the Printer Start Button (internal device 005000) turns ON, the script evaluates whether or not to start printing from the first byte of Print Permit data.
The Print Permit data performs the following actions as an example of the printer specifications.
Print Preparation OK: Send 0x31 (ASCII code "1") to the device/PLC.
Print Preparation NG: Send 0x30 (ASCII code "0") to the device/PLC.
The display unit receives the Print Permit data in databuf0 and this data is moved to accessible internal device 100 with the following script handling.
When internal device 100 = 0x31 (ASCII code for the value "1"), printing starts. When internal device is 0x30 (ASCII code for "0"), the display unit returns to the beginning of the script and repeats this process until it receives 0x31.