L&G Fugga PRV
L&G Fugga PRV communication protocol
Supported device types and versions
This protocol provides data reading/writing into Landis&Gyr devices, type PRV 1.xx, and 2.xx.
Communication line configuration
Communication line category: Serial.
Baud rate and transmission parameters are defined according to the parameters of the communication software in PRV.
Communication station configuration
Communication protocol: L&G FUGGA PRV
The station address is in the range of 0 up to 255. It is in decimal format according to the station number in the communication software in PRV (see below).
Station protocol parameters
You can define the following parameters:
Table 1
Keyword | Full name | Meaning | Unit | Default value |
|---|---|---|---|---|
MR | Retry Count | The number of repeated requests if the communication error occurs. | - | 3 |
MWR | Max Wait Retry | Maximum retries of reading the response until it is completed. | - | 14 |
RT | Retry Timeout | The delay between request repetitions in case of a communication error. | s.ms | 1.000 s |
WT | Wait Timeout | The delay between reading the response until it is completed. | ms | 300 millisec. |
WFT | Wait First Timeout | The first wait after the request has been sent before reading the response. | ms | 1200 millisec. |
RD | Request Delay | Delay before sending the request. | ms | 1000 millisec. |
MBS | Maximum Buffer Size | Maximum size of request in bytes. | byte | 60 |
DOFF | Date Offset | The correction of the date offset in PRV and D2000 System. D2000 System interprets the date as a number of days from 1-1-1972. To test PRV 1.64 (SW ver. 4.04) we had to set the value 20089 because PRV implements the date from 1-1-1917. | - | 4806 |
A string containing the protocol parameters is defined as follows:
Key_word=value;Key_word=value; ...
Example:
MR=4;RD=500;
If there is used a keyword with an invalid value in the initialization string, there will be used corresponding default value according to the table 1.
I/O tag configuration
I/O tags: AI, AO, CI, CO, DI, DO, TIR, TOR, TIA, TOA
The address must be in text format for configuration. In comparison with the implementation in D2000 ver.3.xx, the range of types is not limited. The table shows the writing format of some types:
Type in D2000 v.3.xx | Write in D2000 v.4.x | Example |
|---|---|---|
I/O | $xxx.name | $120.HW |
PLT | PLTx.name | PLT5.PAR1 |
ZON | ZONx.name |
|
RGB | RGBx.name |
|
VIP | VIPx.name |
|
CVP | CVPx.name |
|
@MGR | @MGRx.name |
|
@MGG | @MGGx.name |
|
@SEZ | @SEZx.name |
|
@AI | @AIx.name |
|
@AO | @AOx.name |
|
@DI | @DIx.name |
|
@DO | @DOx.name |
|
@CI | @CIx.name |
|
@PHON | @PHONx.name |
|
@RING | @RINGx.name |
|
TTY | TTYx.name |
|
@PBUS | @PBUSx.name |
|
@MBUS | @MBUSx.name |
|
@OS | @OSx.name |
|
@BLN | @BLNx.name |
|
@BPS | @BPSx.name |
|
TSK | [tsknr]name | [10]S2 |
SYS | name | DATE |
PRV (Fugga) protocol
Format of the message:
<STX><ADDRESS><FUNCTION><SEQ><CONTENT OF MESSAGE><ETX/ETB><CRC>
STX - Start of text, character 0x02
ADDRESS - double-digits in ASCII format - the range from 01 - 99.
FUNCTION - double-digits in ASCII format - the function number. The number 50 is added to the function number in response.
SEQ – a consecutive number of message - one byte - the values 0x41 – 0x5A
CONTENT OF MESSAGE - a message in ASCII format - the parts of the message are separated by “;”.
ETX - end of message
ETB - end of the block
CRC - checksum CRC-CCITT Cyclic Redundancy Check according to IBM
to PRV - 6 bytes ASCII
from PRV - 2 bytes binary
Acknowledgment:
ACK - O.K. - the message contains the ACK character
NAK - error - the message contains the NAK character
Functions:
Function | Number | Content of message | Response |
|---|---|---|---|
Config Check | 01 | Config ID | ACK/NAK |
New Point Def | 02 | ID:NAME;0:ConfigId; | ACK/NAK(memory) |
Delete Point | 03 | ID;ConfigId; | ACK |
Read All | 04 | --- | ID:VALUE;... |
ReadAllContinue | 05 | INDEX | ID:VALUE;... |
Set Output | 06 | ID=Value; | ACK |
Reset PRV | 07 | --- | ACK |
Clear Config | 08 | --- | ACK |
Solution of problematic situations
On the D2000 System side:
1. PRV does not respond in a defined limit.
2. Wrong checksum.
The message is repeated N-times - all necessary parameters can be set by the station protocol parameters.
On the PRV side:
Wrong checksum - PRV does not respond.
Changes in PRV (Fugga) protocol ver. 1.02
Usage: The communication with PRV1/PRV2 via the serial lines and a radio modem with OnLine configuration of transmitted values.
New features in comparison with ver. 1.01:
time I/O tags were implemented
optimization of communication - only the value changes are transmitted
The number of transmitted tags from one station is max. 255.
Communication parameters on the PRV side:
Task 3:
Communication port number in PRV: PRT variable <1..3>
Station address: variable AD$ - the address always consists of two digits, e.g. “01” - address 1.
Communication task number - 3 is the default. If it needs to be changed, modify tasks 254 and 253 - a restart after power failure and WatchDog Error. Task 4 must be modified - the references to the local variables of task 3.
WatchDog number - 7 is the default. If it needs to be changed, modify the task 253 and set a new WatchDog number in the calling of WADO function on line 305.
The maximum size of the transmitted message to PC - BLK variable - the limit is 160.
Baud rate: The parameter TTYPRT.BD on line 60.
Task number for data acquisition: Task 4 is used. If it needs to be changed, the task number on line 48 must be modified - the start of Task 4.
Task 4:
Parameter TSKFRM$ - defines an output format of the task. Actually, it defines an accuracy of transmitted float numbers.
Parameter WAIT DURING 5 on line 70 defines a value acquisition period in seconds.
Task listing for ver. 1.02
.TSK 31 -- FUGGA PROTOCOL (C) IPESOFT 1997 V 1.025 ad$ := "21"; -- station address10 er := 1 ; cf$ ="";RT$ := "";mx:=10015 sl := 2; bl = 60; cn := 1; wx := 5;20 DIM N$(mx); DIM V$(mx); DIM NW(mx);25 FOR I := 1 TO mx26 V$(I) := ""; NW(I) := 0;27 NEXT I;48 STOP 4; RUN 4;40 TSKPRP:=350 TSKTTY:=155 TSKPRIO:=1556 SYSDIAG:=0;58 ON ERROR GOTO 700060 TTY1.BD=1920061 -- TTY1.PARCHK = 062 TTY1.SSB = 070 TTY1.NOEC=172 TTY1.NCON=174 TTY1.MOD=076 TTY1.NWCR=178 TTY1.NFCR=179 TTY1.NOX=1;80 INITTY190 BEGIN_INKEY100 cm$ := "" ;C$ := ""; ax$ := "";fn$ := "";CR$ := "";WT:=0200 ST := 1; fc := 0;300 INKEY A$305 WADO(7,60) ; -- 7 is Watch Dog number310 IF A$="" THEN WT := WT + 1 ELSE WT:= 0;320 IF WT > wx THEN GOTO 100330 IF WT > 0 THEN WAIT DURING 1; GOTO 300400 FOR RI:= 1 TO LEN(A$)450 C$ := A$[RI..RI]500 ON ST GOSUB 600,800,1000,1200,1300,950,3000540 cm$ := cm$ + C$550 NEXT RI560 GOTO 300600 IF C$ = CHR$(2) THEN ST:= 2; ax$:="" ELSE ST:= 1610 IF C$ = CHR$(24) THEN ST:=7;620 cm$ := ""700 RETURN800 ax$ := ax$ + C$820 IF LEN(ax$) < 2 THEN RETURN;830 IF ax$ = ad$ THEN fn$:= "";ST := 3 ELSE ST := 1;900 RETURN950 RT$ := C$; ST := 4;960 RETURN1000 fn$ := fn$ + C$1020 IF LEN(fn$) < 2 THEN RETURN1025 fc := VAL(fn$); ST := 6;1030 fn$ := STR$(fc+50);1040 RETURN1200 IF (C$ = CHR$(3)) OR (C$ = CHR$(23)) THEN ST := 5; CR$ := ""1210 RETURN1300 CR$ := CR$ + C$ ; C$ := "";C4$ := "";1320 IF LEN(CR$) = 6 THEN GOTO 1400;1340 RETURN1400 C1 := VAL(CR$[1..3]); C2 := VAL(CR$[4..6]);C1$ := "";1410 C1$ := CHR$(C1) + CHR$(C2);1415 C4$ := CRC$(4,cm$)1420 IF C1$ = C4$ THEN GOTO 1500 ELSE ST := 1;1430 RETURN1500 ON fc GOSUB 2100,2200,2300,2400,2500,2600,2700,28001505 ST := 1;cm$ := ""1510 RETURN2100 ET := INSTR(7,cm$,";");2110 FOR I := 1 TO mx2115 IF N$(I) <> "" THEN NW(I) := 1;2117 NEXT I;2120 IF cm$[7..ET-1] = cf$ THEN GOTO 2125 ELSE 21302125 SB(CHR$(6),3,ad$,fn$,RT$); RETURN2130 SB(CHR$(21),3,ad$,fn$,RT$); RETURN2200 S := 72210 FM := FREE2220 IF FM < 1000 THEN SB(CHR$(21),3,ad$,fn$,RT$); RETURN2230 E := INSTR(S,cm$,":")2240 ix := VAL(cm$[S..E-1]);2245 IF ix > mx THEN SB(CHR$(21),3,ad$,fn$,RT$); RETURN;2250 ET := INSTR(E+1,cm$,";");2255 IF ix = 0 THEN cf$ := cm$[E+1..ET-1]; GOTO 2270;2260 N$(ix) := cm$[E+1..ET-1];2270 S := ET+1;2280 IF cm$[S..S] = CHR$(3) THEN GOTO 2290 ELSE GOTO 22102290 SB(CHR$(6),3,ad$,fn$,RT$); RETURN;2300 E := INSTR(cm$,";")2340 ix := VAL(cm$[7..E-1]);2350 N$(ix) := ""2360 ET := INSTR(E+1,cm$,';')2370 cf$ := cm$[E+1..ET-1]2380 SB(CHR$(6),3,ad$,fn$,RT$)2390 RETURN2400 cn := 1;2402 SB$ := "" ;VL$ := ""2405 FOR I:= cn TO mx2407 IF NW(I) = 0 THEN GOTO 24202408 IF N$(I) = "" THEN GOTO 24202410 SB$:=SB$+STR$(I)+":"+V$(I)+";"; NW(I):=0; IF LEN(SB$)>bl THEN GOTO 24452420 NEXT I2430 SB(SB$,3,ad$,fn$,RT$)2440 RETURN2445 SB(SB$,23,ad$,fn$,RT$);RETURN;2500 cn := VAL(cm$[7..9]); GOTO 24022600 E := INSTR(cm$,"=")2640 ix := VAL(cm$[7..E-1]);2645 ET := INSTR(E+1,cm$,";");2650 LVAL(N$(ix)) := VAL(cm$[E+1..ET-1])2660 SB(CHR$(6),3,ad$,fn$,RT$)2665 V$(ix) := STR$(VAL(N$(ix)));2667 NW(ix) := 1;2670 RETURN2700 SB(CHR$(21),3,ad$,fn$,RT$)2701 RETURN2800 FOR I:= 1 TO mx2810 N$(I) := ""; V$(I) := ""; NW(I) := 0;2820 NEXT I2825 cf$ := ""2830 SB(CHR$(6),3,ad$,fn$,RT$)2840 RETURN3000 fn$ := fn$ + C$3010 IF LEN(fn$) = 5 THEN GOTO 31003020 RETURN3100 IF fn$ = "FUGGA" THEN GOTO 32003150 ST := 1; fn$ := ""; RETURN;3200 WADO(7,-1);SDTTY1;SYSDIAG := 1; STOP;7000 ON er GOTO 8100,82007100 RESUME 1008100 RESUME 100;8200 er := 1;8300 VL$ := "???";8400 RESUME 2410;9999 END.TSK 410 ON ERROR GOTO 200;15 TSKFRM$ :=:(S:2) -- output format - transmission of float values20 VL$ := ""30 FOR I:= 1 TO [3]mx40 IF [3]N$(I) = "" THEN GOTO 60 ELSE VL$ := STR$(VAL([3]N$(I)));50 IF VL$ <> [3]V$(I) THEN [3]V$(I) := VL$; [3]NW(I) := 1;60 NEXT I65 WADO(6,20); -- watch dog for task 470 WAIT DURING 5; -- value acquisition period80 GOTO 20200 VL$ := "???";210 RESUME 50;500 END.TSK 2535 EA := EVADR10 IF EA=$340.ADR AND $340.ERR = 20 AND $340.ER1=7 THEN GOTO 30 ELSE GOTO 10020 ; -- 7 is Watch Dog number, 3 is the communication task number30 WADO(7,-1); STOP 3; RUN 3,40; GOTO 200100 IF EA=$340.ADR AND $340.ERR = 20 AND $340.ER1=6 THEN GOTO 130 ELSE GOTO 200130 WADO(6,-1); STOP 4; RUN 4; GOTO 200200 ENDEXITTSK 2545555 RUN 3,40EXIT\
.PROC SBENTRY (IN:B$,Ex,A$,F$,R$)1050 BF$:=CHR$(2)+A$+F$+R$+B$+CHR$(Ex)