Skip to content

1. Supported Areas

S7 driver supports the following memory areas. Addresses are case-insensitive.

Area CodeNameDescriptionAddress Format Example
DBData BlockGlobal Data BlockDB1.W10, DB10.INT20
IInputDigital InputI0.0 (Bit), IB0 (Byte), IW0 (Word)
QOutputDigital OutputQ0.0 (Bit), QB0 (Byte), QW0 (Word)
MMemoryInternal Flag/Intermediate VariableM0.0 (Bit), MB0 (Byte), MW0 (Word)
VV MemoryMapped to DB1 (Common for S7-200 Smart)V0.0 (Bit), VB0 (Byte), VW0 (Word)
TTimerTimer Current ValueT1, T10
CCounterCounter Current ValueC1, C20
DIInstance DBInstance Data BlockDI1.W0
LLocalLocal DataLB0, LW0
DPPeripheralsDirect Peripheral AccessDPB0, DPW0

Note

  • V Area Mapping: In NG Gateway S7 driver, V area is mapped to DB1 by default. E.g., VB100 is equivalent to DB1.B100.
  • DB Area Format: DB address must include block number, format is DB{BlockNo}.{Type}{Offset}.

2. Data Types and Prefixes (Transport Size)

The driver determines data read length and decoding method via Type Prefix in the address. Supports long naming and short naming (e.g., INT and I).

Type NameLong PrefixShort PrefixLength (Byte)Rust TypeDescription
BitBITX1/8boolBit access (Must specify .bit index; carried as 1 byte on wire)
ByteBYTEB1u8Single Byte (Convert on business side if i8 semantics needed)
CharCHARC1charSingle Char (Write/Read as 1 byte code value)
WordWORDW2u16Unsigned Word
IntINTI2i16Signed Integer
DWordDWORDDW4u32Unsigned Double Word
DIntDINTDI4i32Signed Double Integer
RealREALR4f32Float
TimeTIMET4chrono::DurationIEC Time (ms); Note difference from Area T (Timer)
DateDATE-2chrono::NaiveDateIEC Date (Driver decodes as date)
TimeOfDay-TOD4chrono::NaiveTimeTime of Day (ms), decoded as NaiveTime
S5TimeS5TIMEST2chrono::DurationS5 Format Time, decoded as Duration
DateTimeDATETIMEDT8chrono::NaiveDateTimeDATE_AND_TIME (BCD, 8 bytes)
DateTimeLongDATETIMELONGDTL12chrono::NaiveDateTimeDTL (12 bytes, S7-1200/1500)
StringSTRINGS256 (envelope)StringSTRING structure whole read (Latin-1): [max:u8][len:u8][payload...]
WStringWSTRINGWS512 (envelope)StringWSTRING structure whole read (UTF-16BE): [max:u16][len:u16][payload...]

Hint

  • If type prefix is not specified (and no decimal point), default parses as Byte (e.g., M10 equivalent to MB10).
  • If there is a decimal point but no type prefix (e.g., M10.2), auto parses as Bit.

3. Address Formats and Examples

The table below shows various common address spellings and their parsing results.

3.1 I/Q/M/V Area Examples

I/Q/M/V areas support three types of writing:

  1. Legacy Address: Common shorthands in KepServer/Step7 like ID0/MD200/VD100 (Note: Some are not directly supported in NG Gateway and need migration).
  2. NG Gateway Full Address: Use long type prefix (e.g., WORD/REAL/DINT), best readability.
  3. NG Gateway Short Address: Use short type prefix (e.g., W/R/DI) or omit type by rule (Recommend explicit type declaration).
Legacy AddressNG Gateway Full AddressNG Gateway Short AddressS7 Data TypeRust TypeDescription
I0.0IBIT0.0IX0.0BitboolI Area, Byte 0, Bit 0 (Bit access must include .bit)
Q1.7QBIT1.7QX1.7BitboolQ Area, Byte 1, Bit 7
M10.5MBIT10.5MX10.5BitboolM Area, Byte 10, Bit 5
V100.0DB1.BIT100.0VX100.0BitboolV Area mapped to DB1.* in driver (Equivalent to DB1.X100.0)
IB0IBYTE0IB0Byteu8I Area, Byte 0
QB10QBYTE10QB10Byteu8Q Area, Byte 10
MB20MBYTE20MB20Byteu8M Area, Byte 20
IW0IWORD0IW0Wordu16I Area, Unsigned 16-bit starting at Byte 0 (Big Endian)
QW4QWORD4QW4Wordu16Q Area, Unsigned 16-bit starting at Byte 4 (Big Endian)
MW10MWORD10MW10Wordu16M Area, Unsigned 16-bit starting at Byte 10 (Big Endian)
ID0IDWORD0IDW0DWordu32I Area, Unsigned 32-bit starting at Byte 0 (Big Endian); Please use IDW*/IDWORD* for migration
MD200MDINT200MDI200DInti32M Area, Signed 32-bit starting at Byte 200 (Big Endian); Legacy MD* semantics is "4 Bytes", explicitly declare DI/DINT in this driver
MD200MREAL200MR200Realf32M Area, IEEE-754 f32 starting at Byte 200 (Big Endian); If legacy MD* represents float, please use R/REAL
VD100DB1.DWORD100VDW100DWordu32V Area (DB1) Unsigned 32-bit starting at Byte 100 (Big Endian); Legacy VD* please change to VDW* or directly use DB1.DW*

3.2 DB Area Examples

DB Area address must start with DB, followed by block number. Format: DB{BlockNo}.{Type}{Offset}.

Migration Reminder

NG Gateway current address parser (See ng-gateway-southward/s7/src/protocol/frame/addr.rs) does not support Siemens legacy "Combined Prefix" like DBX/DBB/DBW/DBD (e.g., DB1.DBD100). Please use NG Gateway Full/Short Address in the table below.

Legacy AddressNG Gateway Full AddressNG Gateway Short AddressS7 Data TypeRust TypeDescription
DB1.DBX0.0DB1.BIT0.0DB1.X0.0BitboolDB1, Byte 0 Bit 0 (Bit must be written as *.Xbyte.bit or *.BITbyte.bit)
DB10.DBB0DB10.BYTE0DB10.B0Byteu8DB10, Byte 0
DB10.DBW2DB10.WORD2DB10.W2Wordu16DB10, Unsigned 16-bit starting at Byte 2 (Big Endian)
DB10.DBW4DB10.INT4DB10.I4Inti16DB10, Signed 16-bit starting at Byte 4 (Big Endian)
DB1.DBD0DB1.DWORD0DB1.DW0DWordu32DB1, Unsigned 32-bit starting at Byte 0 (Big Endian)
DB1.DBD4DB1.DINT4DB1.DI4DInti32DB1, Signed 32-bit starting at Byte 4 (Big Endian)
DB1.DBD8DB1.REAL8DB1.R8Realf32DB1, IEEE-754 f32 starting at Byte 8 (Big Endian); Legacy DBD* only means "4 Bytes", must explicitly declare DW/DI/R in this driver
DB2.STRING0DB2.STRING0DB2.S0StringStringS7 STRING Structure ([max:u8][len:u8][payload...], Latin-1), address should point to structure start offset
DB2.WSTRING100DB2.WSTRING100DB2.WS100WStringStringS7 WSTRING Structure ([max:u16][len:u16][payload...], UTF-16BE), address should point to structure start offset
-DB5.DATETIME0DB5.DT0DateTimechrono::NaiveDateTime8 Bytes DATE_AND_TIME (BCD)
-DB5.DATETIMELONG0DB5.DTL0DateTimeLongchrono::NaiveDateTime12 Bytes DTL (S7-1200/1500); Different from DT, nanosecond field is 24-bit BE

Best Practices and Common Pitfalls

  • Explicitly Declare Type: For production environment, recommend using short and explicit type prefixes (e.g., DB1.R8, MDI200), avoiding ambiguity from implicit Byte (e.g., M10).
  • Bit Address must include .bit: E.g., QX1 will be judged illegal in driver, must be written as QX1.0 (See parser test cases).
  • Legacy DBD/MD/VD only represents "4 Bytes": In NG Gateway syntax, must specify which of DW (u32) / DI (i32) / R (f32) it is.
  • V Area is Syntactic Sugar for DB1: VB100 is equivalent to DB1.B100. When collaborating across teams/troubleshooting, writing DB1.* directly is usually more intuitive.
  • STRING/WSTRING offset points to structure start: STRING/WSTRING variables in PLC contain length header (2/4 bytes). Driver reads and decodes the whole structure, offset should not point to the first character.
  • Endianness and Alignment: Numeric types use Big Endian encoding per S7 convention. Recommend natural alignment by type (Word starts at even, DWord/Real starts at multiple of 4) to improve readability and reduce potential overhead on PLC side.

3.3 Timer / Counter Examples

AddressTypeDescription
T1TimerTimer T1
C10CounterCounter C10

Released under the Apache License 2.0.