Herunterladen Inhalt Inhalt Diese Seite drucken

Checksum.crc16_Dnp3; Checksum.lrc - IFTOOLS MSB-RS485-PLUS Handbuch

Inhaltsverzeichnis

Werbung

18.2. ALLGEMEINE ERWEITERUNGEN FÜR ALLE VIEWS
Protokollmonitor Beispiel
1
function o u t ( )
2
l o c a l t g = t e l e g r a m s . t h i s ( )
3
e x t r a c t t h e a p p l i c a t i o n data and s u b s t i t u t e DLE DLE
4
l o c a l data = t g : s t r i n g ( ) : sub (6 ,
5
checksum v a l i d a t i o n , t h e CRC16 i s c a l c u l a t e d from t h e STN ( 3 t h
b y t e ) ,
6
STX ( 5 t h b y t e ) , t h e a p p l i c a t i o n data AND t h e f i n a l ETX
7
l o c a l data = t g : s t r i n g ( ) : sub ( 3 , 3 ) . . t g : s t r i n g ( ) : sub ( 5 , 5 ) . . data . .
8
9
l o c a l cks = checksum . c r c 1 6 _d f 1 ( data )
10
box . t e x t { c a p t i o n ="Checksum " , cks }
11
end
18.2.4.5

checksum.crc16_dnp3

Liefert die CRC16 Prüfsumme des gegebenen Datenstrings als 16 Bit Integer
wie im DNP3 Protokoll spezifiziert.
checksum.crc16_dnp3(String )
String: Die Datensequenz als Lua String
Protokollmonitor Beispiel
1
function o u t ( )
2
t h e f o l l o w i n g code checks t h e c o n t e n t o f t h e e n t i r e message
except
3
f o r t h e l a s t two b y t e ( which are t h e checksum i t s e l f )
l o c a l cks = checksum . crc16_dnp3 ( t e l e g r a m s . t h i s ( ) : s t r i n g ( ) : sub (1 ,
4
)
5
box . t e x t { c a p t i o n ="Checksum " , cks }
end
6
18.2.4.6

checksum.lrc

Ein Prüfsummenalgorithmus basierend auf dem Longitudinal Redundancy Checking
wie er z.B. in Modbus ASCII Übertragungen verwendet wird. Das Resultat ist
ein einzelnes Byte (8 Bit Wert).
checksum.lrc(String )
String: Die Daten als Lua String
Protokollmonitor Beispiel
1
function o u t ( )
2
i n Modbus ASCII each b y t e i s s e n t as a two ASCII c h a r a c t e r s b u t
3
t h e checksum i s c a l c u l a t e d b e f o r e encoding t h e message . So we
4
must decode i t
5
l o c a l b i n d a t a = base16 . decode ( t e l e g r a m s . t h i s ( ) : s t r i n g ( ) : sub (2 ,
)
5) : gsub ( ' ' \ 0 1 6 \ 0 1 6 ' ' , ' ' \ 0 1 6 ' ' )
t g : s t r i n g ( ) : sub( 3, 3)
f i r s t w i t h base16 . decode
3)
3)
229

Werbung

Inhaltsverzeichnis
loading

Inhaltsverzeichnis