STATUS (n)
Purpose Return the status of various system operations. Returned values may be dependent on the PLC model.
Function Returned value
STATUS (1) PLC Reset Status.
STATUS (2)

Used to check the status of a command sent to a device.

0 = command failure

1 = command successful

255 = End of File reached

Applies to the following TBASIC commands or tags (sent via PRINT command), except 255 will only be returned during file access. See the Extended File System chapter of the user manual for more information.

READMODBUS, WRITEMODBUS, READMB2, WRITEMB2 I2C_WRITE, I2C_READ
<READ>, <WRITE>, <APPEND> tags

Example :
IF STATUS(2) ' MODBUS READ/WRITE OK
...
ENDIF

STATUS (3) 0 - TCP/IP connection closed or last TCP operation failed
1 - TCP/IP connection established or last TCP operation successful
STATUS (4) (only for PLC with firmware r77 or above) - FTP transfer status.
0 : FTP client was idle or last FTP failed
1 : FTP data transfer just started
2 : 1st FTP segment transferred, now transferring the rest
3 : FTP data transfer completed.
STATUS (5) (only for PLC with firmware r78 and above) - return the main firmware version. E.g.firmware r78A will return 78.
STATUS (8)

PLC’s ID address stored in FRAM/EEPROM for host communication. Returned as an integer in the range 0-255 decimal or 00-FF Hex.

Note: if the ID is changed, a cold boot (power cycle) is required for STATUS(8) to return the new ID. Otherwise the previous ID is returned.

STATUS (14)

Ethernet Connection Status

A byte is returned and each of the first 7 bits represent a connection state for an incoming or outgoing Ethernet connection. Bit7 (MSB) is not used and can be ignored.

Bit# 6 5 4 3 2 1 0
State 1 1 1 1 1 1 1
0 0 0 0 0 0 0
Connection
Type
(Default)
Client MDBTCP MDBTCP MDBTCP FSERVER FSERVER FSERVER

Note:
Bit 6 will always represent the PLCs 1 client connection (outgoing), bits 4 and 5 will always represent Modbus TCP (incoming), and bit 0 will always represent an FSERVER connection (incoming). Bits 1,2, and 3 can be set to either type (view chapter 2 of the PLC user manual for more details). By default, there are 3 incoming connections for each type.

If any bit is set to ‘1’, that means the corresponding connection type is being used and is not available.

Any bits set to ‘0’ are free to be used (available connections).

Example:
STATUS(14) returns 11 => bits 0, 1, and 3 are on

Comment:
2 of 3 incoming FSERVER connections are used.
1 of 3 incoming MDBTCP connections are used.

Note : only for PLC with firmware r78 and above

STATUS (17)

Return IR Code

Specific only to F-series PLC with Infra-Red decoder. Returns the decoded IR remote code. See chapter 17 of the user manual for more details.

Note: the SETSYSTEM 17, 1 command must be executed first to enable the IR decoder.

STATUS (18)

Return current Real Time Clock value as a 6 digit integer from 000000 to 235959

Must be returned to a 32-bit variable.

Example:
At 00:12:05 => A = STATUS(18) returns 001205 to A.
At 12:00:05 => A = STATUS(18) returns 120005 to A.

Note: Only for PLCs with firmware r72 and above.

STATUS (19)

Return the file length of the currently opened file.

Example:
The currently open is 50kb =>
A = STATUS(19) returns 50000 to A.

See the Extended File System chapter in the PLC user manual for more information.

Note: only for PLCs with firmware r77 or above

STATUS (20) (only for PLC with firmware r77 or above) - FTP transfer status.
>=0: Number of bytes uploaded to FTP Server. Transfer is in progress.
< 0 : Total number of bytes uploaded. Transfer completed.
STATUS (21) (Only for PLC with firmware r78 and above) - Can be used to measure execution time.
This function returns the 32-bit value of a 10MHz free running counter in the CPU.   The difference between the values from two STATUS(21) gives the elapse time of a process in 0.1us. 
E.g:
    A = STATUS(21)
    CALL [somefunction]
    B = STATUS(21) - A

B is the execution time of [somefunction] in 0.1 microsecond.   (i.e. if B = 10000 => 1 ms)

Examples IF STATUS(2)    'MODBUS READ/WRITE OK
...
ELSE            'MODBUS READ/WRITE failed
...
ENDIF

backbutton.gif (507 bytes)  Basic to TBASIC Reference Manual