S7.Net Conversion methods to convert from Siemens numeric format to C# and back Converts a binary string to Int32 value Converts a binary string to a byte. Can return null. Converts the value to a binary string Helper to get a bit value given a byte and the bit index.
Get the bit at DB1.DBX0.5: byte data = ReadByte("DB1.DBB0"); bool bit = data.SelectBit(5);
The data to get from. The zero-based index of the bit to get. The Boolean value will get.
Helper to set a bit value to the given byte at the bit index.
Set the bit at index 4: byte data = 0; data.SetBit(4, true);
The data to be modified. The zero-based index of the bit to set. The Boolean value to assign to the bit.
Converts from ushort value to short value; it's used to retrieve negative values from words Converts from short value to ushort value; it's used to pass negative values to DWs Converts from UInt32 value to Int32 value; it's used to retrieve negative values from DBDs Converts from Int32 value to UInt32 value; it's used to pass negative values to DBDs Converts from float to DWord (DBD) Converts from DWord (DBD) to float COTP Protocol functions and types Describes a COTP TPDU (Transport protocol data unit) Reads COTP TPDU (Transport protocol data unit) from the network stream See: https://tools.ietf.org/html/rfc905 The socket to read from A cancellation token that can be used to cancel the asynchronous operation. COTP DPDU instance Describes a COTP TSDU (Transport service data unit). One TSDU consist of 1 ore more TPDUs Reads the full COTP TSDU (Transport service data unit) See: https://tools.ietf.org/html/rfc905 The stream to read from A cancellation token that can be used to cancel the asynchronous operation. Data in TSDU Types of S7 cpu supported by the library S7 200 cpu type Siemens Logo 0BA8 S7 200 Smart S7 300 cpu type S7 400 cpu type S7 1200 cpu type S7 1500 cpu type Types of error code that can be set after a function is called The function has been executed correctly Wrong type of CPU error Connection error Ip address not available Wrong format of the variable Wrong number of received bytes Error on send data Error on read data Error on write data Types of memory area that can be read Input area memory Output area memory Merkers area memory (M0, M0.0, ...) DB area memory (DB1, DB2, ...) Timer area memory(T1, T2, ...) Counter area memory (C1, C2, ...) Types S7 Bit variable type (bool) S7 Byte variable type (8 bits) S7 Word variable type (16 bits, 2 bytes) S7 DWord variable type (32 bits, 4 bytes) S7 Int variable type (16 bits, 2 bytes) DInt variable type (32 bits, 4 bytes) Real variable type (32 bits, 4 bytes) LReal variable type (64 bits, 8 bytes) Char Array / C-String variable type (variable) S7 String variable type (variable) S7 WString variable type (variable) Timer variable type Counter variable type DateTIme variable type IEC date (legacy) variable type DateTimeLong variable type S7 TIME variable type - serialized as S7 DInt and deserialized as C# TimeSpan Helper function to write to whole content of the given byte array to a memory stream. Writes all bytes in value from 0 to value.Length to the memory stream. Helper function to write the whole content of the given byte span to a memory stream. Creates an instance of S7.Net driver Creates an instance of S7.Net driver The length in bytes of DateTime stored in the PLC. The default port for the S7 protocol. The default timeout (in milliseconds) used for and . IP address of the PLC PORT Number of the PLC, default is 102 The TSAP addresses used during the connection request. CPU type of the PLC Rack of the PLC Slot of the CPU of the PLC Max PDU size this cpu supports Gets or sets the amount of time that a read operation blocks waiting for data from PLC. A that specifies the amount of time, in milliseconds, that will elapse before a read operation fails. The default value, , specifies that the read operation does not time out. Gets or sets the amount of time that a write operation blocks waiting for data to PLC. A that specifies the amount of time, in milliseconds, that will elapse before a write operation fails. The default value, , specifies that the write operation does not time out. Gets a value indicating whether a connection to the PLC has been established. The property gets the connection state of the Client socket as of the last I/O operation. When it returns false, the Client socket was either never connected, or is no longer connected. Because the property only reflects the state of the connection as of the most recent operation, you should attempt to send or receive a message to determine the current state. After the message send fails, this property no longer returns true. Note that this behavior is by design. You cannot reliably test the state of the connection because, in the time between the test and a send/receive, the connection could have been lost. Your code should assume the socket is connected, and gracefully handle failed transmissions. Creates a PLC object with all the parameters needed for connections. For S7-1200 and S7-1500, the default is rack = 0 and slot = 0. You need slot > 0 if you are connecting to external ethernet card (CP). For S7-300 and S7-400 the default is rack = 0 and slot = 2. CpuType of the PLC (select from the enum) Ip address of the PLC rack of the PLC, usually it's 0, but check in the hardware configuration of Step7 or TIA portal slot of the CPU of the PLC, usually it's 2 for S7300-S7400, 0 for S7-1200 and S7-1500. If you use an external ethernet card, this must be set accordingly. Creates a PLC object with all the parameters needed for connections. For S7-1200 and S7-1500, the default is rack = 0 and slot = 0. You need slot > 0 if you are connecting to external ethernet card (CP). For S7-300 and S7-400 the default is rack = 0 and slot = 2. CpuType of the PLC (select from the enum) Ip address of the PLC Port number used for the connection, default 102. rack of the PLC, usually it's 0, but check in the hardware configuration of Step7 or TIA portal slot of the CPU of the PLC, usually it's 2 for S7300-S7400, 0 for S7-1200 and S7-1500. If you use an external ethernet card, this must be set accordingly. Creates a PLC object with all the parameters needed for connections. For S7-1200 and S7-1500, the default is rack = 0 and slot = 0. You need slot > 0 if you are connecting to external ethernet card (CP). For S7-300 and S7-400 the default is rack = 0 and slot = 2. Ip address of the PLC The TSAP addresses used for the connection request. Creates a PLC object with all the parameters needed for connections. Use this constructor if you want to manually override the TSAP addresses used during the connection request. Ip address of the PLC Port number used for the connection, default 102. The TSAP addresses used for the connection request. Close connection to PLC Dispose Plc Object Connects to the PLC and performs a COTP ConnectionRequest and S7 CommunicationSetup. The token to monitor for cancellation requests. The default value is None. Please note that the cancellation will not affect opening the socket in any way and only affects data transfers for configuring the connection after the socket connection is successfully established. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous open operation. Reads a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests. If the read was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to read DB1.DBW200, this is 200. Byte count, if you want to read 120 bytes, set this to 120. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. Returns the bytes in an array Reads a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests. If the read was not successful, check LastErrorCode or LastErrorString. Buffer to receive the read bytes. The determines the number of bytes to read. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to read DB1.DBW200, this is 200. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. Returns the bytes in an array Read and decode a certain number of bytes of the "VarType" provided. This can be used to read multiple consecutive variables of the same type (Word, DWord, Int, etc). If the read was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to read DB1.DBW200, this is 200. Type of the variable/s that you are reading Address of bit. If you want to read DB1.DBX200.6, set 6 to this parameter. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. Reads a single variable from the PLC, takes in input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. If the read was not successful, check LastErrorCode or LastErrorString. Input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. Returns an object that contains the value. This object must be cast accordingly. Reads all the bytes needed to fill a struct in C#, starting from a certain address, and return an object that can be casted to the struct. Type of the struct to be readed (es.: TypeOf(MyStruct)). Address of the DB. Start byte address. If you want to read DB1.DBW200, this is 200. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. Returns a struct that must be cast. Reads all the bytes needed to fill a struct in C#, starting from a certain address, and returns the struct or null if nothing was read. The struct type Address of the DB. Start byte address. If you want to read DB1.DBW200, this is 200. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. Returns a nulable struct. If nothing was read null will be returned. Reads all the bytes needed to fill a class in C#, starting from a certain address, and set all the properties values to the value that are read from the PLC. This reads only properties, it doesn't read private variable or public variable without {get;set;} specified. Instance of the class that will store the values Index of the DB; es.: 1 is for DB1 Start byte address. If you want to read DB1.DBW200, this is 200. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. The number of read bytes Reads all the bytes needed to fill a class in C#, starting from a certain address, and set all the properties values to the value that are read from the PLC. This reads only properties, it doesn't read private variable or public variable without {get;set;} specified. To instantiate the class defined by the generic type, the class needs a default constructor. The class that will be instantiated. Requires a default constructor Index of the DB; es.: 1 is for DB1 Start byte address. If you want to read DB1.DBW200, this is 200. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. An instance of the class with the values read from the PLC. If no data has been read, null will be returned Reads all the bytes needed to fill a class in C#, starting from a certain address, and set all the properties values to the value that are read from the PLC. This reads only properties, it doesn't read private variable or public variable without {get;set;} specified. The class that will be instantiated Function to instantiate the class Index of the DB; es.: 1 is for DB1 Start byte address. If you want to read DB1.DBW200, this is 200. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. An instance of the class with the values read from the PLC. If no data has been read, null will be returned Reads multiple vars in a single request. You have to create and pass a list of DataItems and you obtain in response the same list with the values. Values are stored in the property "Value" of the dataItem and are already converted. If you don't want the conversion, just create a dataItem of bytes. The number of DataItems as well as the total size of the requested data can not exceed a certain limit (protocol restriction). List of dataitems that contains the list of variables that must be read. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. Read the PLC clock value. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous operation, with it's result set to the current PLC time on completion. Write the PLC clock value. The date and time to set the PLC clock to The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous operation. Read the current status from the PLC. A value of 0x08 indicates the PLC is in run status, regardless of the PLC type. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous operation, with it's result set to the current PLC status on completion. Write a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests. If the write was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to write DB1.DBW200, this is 200. Bytes to write. If more than 200, multiple requests will be made. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous write operation. Write a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests. If the write was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to write DB1.DBW200, this is 200. Bytes to write. If more than 200, multiple requests will be made. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous write operation. Write a single bit from a DB with the specified index. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to write DB1.DBW200, this is 200. The address of the bit. (0-7) Bytes to write. If more than 200, multiple requests will be made. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous write operation. Write a single bit from a DB with the specified index. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to write DB1.DBW200, this is 200. The address of the bit. (0-7) Bytes to write. If more than 200, multiple requests will be made. The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous write operation. Takes in input an object and tries to parse it to an array of values. This can be used to write many data, all of the same type. You must specify the memory area type, memory are address, byte start address and bytes count. If the read was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to read DB1.DBW200, this is 200. Bytes to write. The lenght of this parameter can't be higher than 200. If you need more, use recursion. The address of the bit. (0-7) The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous write operation. Writes a single variable from the PLC, takes in input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. Input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. Value to be written to the PLC The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous write operation. Writes a C# struct to a DB in the PLC The struct to be written Db address Start bytes on the PLC The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous write operation. Writes a C# class to a DB in the PLC The class to be written Db address Start bytes on the PLC The token to monitor for cancellation requests. The default value is None. Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases. A task that represents the asynchronous write operation. Write DataItem(s) to the PLC. Throws an exception if the response is invalid or when the PLC reports errors for item(s) written. The DataItem(s) to write to the PLC. Task that completes when response from PLC is parsed. Writes up to 200 bytes to the PLC. You must specify the memory area type, memory are address, byte start address and bytes count. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to read DB1.DBW200, this is 200. Bytes to write. The lenght of this parameter can't be higher than 200. If you need more, use recursion. A cancellation token that can be used to cancel the asynchronous operation. A task that represents the asynchronous write operation. Creates the header to read bytes from the PLC. The stream to write to. The number of items to read. Create the bytes-package to request data from the PLC. You have to specify the memory type (dataType), the address of the memory, the address of the byte and the bytes count. The stream to write the read data request to. MemoryType (DB, Timer, Counter, etc.) Address of the memory to be read Start address of the byte Number of bytes to be read Given a S7 variable type (Bool, Word, DWord, etc.), it converts the bytes in the appropriate C# format. Given a S7 (Bool, Word, DWord, etc.), it returns how many bytes to read. Byte lenght of variable Connects to the PLC and performs a COTP ConnectionRequest and S7 CommunicationSetup. Reads a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests. If the read was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to read DB1.DBW200, this is 200. Byte count, if you want to read 120 bytes, set this to 120. Returns the bytes in an array Reads a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests. If the read was not successful, check LastErrorCode or LastErrorString. Buffer to receive the read bytes. The determines the number of bytes to read. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to read DB1.DBW200, this is 200. Returns the bytes in an array Read and decode a certain number of bytes of the "VarType" provided. This can be used to read multiple consecutive variables of the same type (Word, DWord, Int, etc). If the read was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to read DB1.DBW200, this is 200. Type of the variable/s that you are reading Address of bit. If you want to read DB1.DBX200.6, set 6 to this parameter. Reads a single variable from the PLC, takes in input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. If the read was not successful, check LastErrorCode or LastErrorString. Input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. Returns an object that contains the value. This object must be cast accordingly. If no data has been read, null will be returned Reads all the bytes needed to fill a struct in C#, starting from a certain address, and return an object that can be casted to the struct. Type of the struct to be readed (es.: TypeOf(MyStruct)). Address of the DB. Start byte address. If you want to read DB1.DBW200, this is 200. Returns a struct that must be cast. If no data has been read, null will be returned Reads all the bytes needed to fill a struct in C#, starting from a certain address, and returns the struct or null if nothing was read. The struct type Address of the DB. Start byte address. If you want to read DB1.DBW200, this is 200. Returns a nullable struct. If nothing was read null will be returned. Reads all the bytes needed to fill a class in C#, starting from a certain address, and set all the properties values to the value that are read from the PLC. This reads only properties, it doesn't read private variable or public variable without {get;set;} specified. Instance of the class that will store the values Index of the DB; es.: 1 is for DB1 Start byte address. If you want to read DB1.DBW200, this is 200. The number of read bytes Reads all the bytes needed to fill a class in C#, starting from a certain address, and set all the properties values to the value that are read from the PLC. This reads only properties, it doesn't read private variable or public variable without {get;set;} specified. To instantiate the class defined by the generic type, the class needs a default constructor. The class that will be instantiated. Requires a default constructor Index of the DB; es.: 1 is for DB1 Start byte address. If you want to read DB1.DBW200, this is 200. An instance of the class with the values read from the PLC. If no data has been read, null will be returned Reads all the bytes needed to fill a class in C#, starting from a certain address, and set all the properties values to the value that are read from the PLC. This reads only properties, it doesn't read private variable or public variable without {get;set;} specified. The class that will be instantiated Function to instantiate the class Index of the DB; es.: 1 is for DB1 Start byte address. If you want to read DB1.DBW200, this is 200. An instance of the class with the values read from the PLC. If no data has been read, null will be returned Write a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests. If the write was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to write DB1.DBW200, this is 200. Bytes to write. If more than 200, multiple requests will be made. Write a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests. If the write was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to write DB1.DBW200, this is 200. Bytes to write. If more than 200, multiple requests will be made. Write a single bit from a DB with the specified index. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to write DB1.DBW200, this is 200. The address of the bit. (0-7) Bytes to write. If more than 200, multiple requests will be made. Write a single bit to a DB with the specified index. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to write DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to write DB1.DBW200, this is 200. The address of the bit. (0-7) Value to write (0 or 1). Takes in input an object and tries to parse it to an array of values. This can be used to write many data, all of the same type. You must specify the memory area type, memory are address, byte start address and bytes count. If the read was not successful, check LastErrorCode or LastErrorString. Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. Start byte address. If you want to read DB1.DBW200, this is 200. Bytes to write. The lenght of this parameter can't be higher than 200. If you need more, use recursion. The address of the bit. (0-7) Writes a single variable from the PLC, takes in input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. Input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. Value to be written to the PLC Writes a C# struct to a DB in the PLC The struct to be written Db address Start bytes on the PLC Writes a C# class to a DB in the PLC The class to be written Db address Start bytes on the PLC Write DataItem(s) to the PLC. Throws an exception if the response is invalid or when the PLC reports errors for item(s) written. The DataItem(s) to write to the PLC. Reads multiple vars in a single request. You have to create and pass a list of DataItems and you obtain in response the same list with the values. Values are stored in the property "Value" of the dataItem and are already converted. If you don't want the conversion, just create a dataItem of bytes. The number of DataItems as well as the total size of the requested data can not exceed a certain limit (protocol restriction). List of dataitems that contains the list of variables that must be read. Read the PLC clock value. The current PLC time. Write the PLC clock value. The date and time to set the PLC clock to. Read the current status from the PLC. A value of 0x08 indicates the PLC is in run status, regardless of the PLC type. The current PLC status. Represents an area of memory in the PLC Memory area to read Address of memory area to read (example: for DB1 this value is 1, for T45 this value is 45) Address of the first byte to read Length of data to read Provides a representation of the Transport Service Access Point, or TSAP in short. TSAP's are used to specify a client and server address. For most PLC types a default TSAP is available that allows connection from any IP and can be calculated using the rack and slot numbers. First byte of the TSAP. Second byte of the TSAP. Initializes a new instance of the class using the specified values. The first byte of the TSAP. The second byte of the TSAP. Implements a pair of TSAP addresses used to connect to a PLC. The local . The remote Initializes a new instance of the class using the specified local and remote TSAP. The local TSAP. The remote TSAP. Builds a that can be used to connect to a PLC using the default connection addresses. The remote TSAP is constructed using new Tsap(0x03, (byte) ((rack << 5) | slot)). The CPU type of the PLC. The rack of the PLC's network card. The slot of the PLC's network card. A TSAP pair that matches the given parameters. The is invalid. -or- The parameter is less than 0. -or- The parameter is greater than 15. -or- The parameter is less than 0. -or- The parameter is greater than 15. Extensions for Streams Reads bytes from the stream into the buffer until exactly the requested number of bytes (or EOF) have been read the Stream to read from the buffer to read into the offset in the buffer to read into the amount of bytes to read into the buffer returns the amount of read bytes Reads bytes from the stream into the buffer until exactly the requested number of bytes (or EOF) have been read the Stream to read from the buffer to read into the offset in the buffer to read into the amount of bytes to read into the buffer A cancellation token that can be used to cancel the asynchronous operation. returns the amount of read bytes Describes a TPKT Packet Reads a TPKT from the socket Async The stream to read from A cancellation token that can be used to cancel the asynchronous operation. Task TPKT Instace Contains the conversion methods to convert Bit from S7 plc to C#. Converts a Bit to bool Converts an array of bytes to a BitArray. The bytes to convert. A BitArray with the same number of bits and equal values as . Converts an array of bytes to a BitArray. The bytes to convert. The number of bits to return. A BitArray with bits. Contains the methods to read, set and reset bits inside bytes Returns the value of a bit in a bit, given the address of the bit Sets the value of a bit to 1 (true), given the address of the bit. Returns a copy of the value with the bit set. The input value to modify. The index (zero based) of the bit to set. The modified value with the bit at index set. Sets the value of a bit to 1 (true), given the address of the bit. The value to modify. The index (zero based) of the bit to set. Resets the value of a bit to 0 (false), given the address of the bit. Returns a copy of the value with the bit cleared. The input value to modify. The index (zero based) of the bit to clear. The modified value with the bit at index cleared. Resets the value of a bit to 0 (false), given the address of the bit The input value to modify. The index (zero based) of the bit to clear. Contains the methods to convert from bytes to byte arrays Converts a byte to byte array Converts a byte array to byte Contains the methods to convert a C# class to S7 data types Gets the size of the class in bytes. An instance of the class The offset of the current field. if this property belongs to a class being serialized as member of the class requested for serialization; otherwise, . the number of bytes Sets the object's values with the given array of bytes The object to fill in the given array of bytes The array of bytes The offset for the current field. if this class is the type of a member of the class to be serialized; otherwise, . Creates a byte array depending on the struct type. The struct object. The target byte array. The offset for the current field. A byte array or null if fails. Contains the conversion methods to convert Counter from S7 plc to C# ushort (UInt16). Converts a Counter (2 bytes) to ushort (UInt16) Converts a ushort (UInt16) to word (2 bytes) Converts an array of ushort (UInt16) to an array of bytes Converts an array of bytes to an array of ushort Create an instance of a memory block that can be read by using ReadMultipleVars Memory area to read Type of data to be read (default is bytes) Address of memory area to read (example: for DB1 this value is 1, for T45 this value is 45) Address of the first byte to read Addess of bit to read from StartByteAdr Number of variables to read Contains the value of the memory area after the read has been executed Create an instance of DataItem Create an instance of from the supplied address. The address to create the DataItem for. A new instance with properties parsed from . The property is not parsed from the address. Create an instance of from the supplied address and value. The address to create the DataItem for. The value to be applied to the DataItem. A new instance with properties parsed from and the supplied value set. Contains the conversion methods to convert Words from S7 plc to C#. Minimum allowed date for the IEC date type Maximum allowed date for the IEC date type Although the spec allows only a max date of 31-12-2168, the PLC IEC date goes up to 06-06-2169 (which is the actual WORD max value - 65535) Converts a word (2 bytes) to IEC date () Converts a to word (2 bytes) Converts an array of s to an array of bytes Converts an array of bytes to an array of s Contains the methods to convert between and S7 representation of datetime values. The minimum value supported by the specification. The maximum value supported by the specification. Parses a value from bytes. Input bytes read from PLC. A object representing the value read from PLC. Thrown when the length of is not 8 or any value in is outside the valid range of values. Parses an array of values from bytes. Input bytes read from PLC. An array of objects representing the values read from PLC. Thrown when the length of is not a multiple of 8 or any value in is outside the valid range of values. Converts a value to a byte array. The DateTime value to convert. A byte array containing the S7 date time representation of . Thrown when the value of is before or after . Converts an array of values to a byte array. The DateTime values to convert. A byte array containing the S7 date time representations of . Thrown when any value of is before or after . Contains the methods to convert between and S7 representation of DateTimeLong (DTL) values. The minimum value supported by the specification. The maximum value supported by the specification. Parses a value from bytes. Input bytes read from PLC. A object representing the value read from PLC. Thrown when the length of is not 12 or any value in is outside the valid range of values. Parses an array of values from bytes. Input bytes read from PLC. An array of objects representing the values read from PLC. Thrown when the length of is not a multiple of 12 or any value in is outside the valid range of values. Converts a value to a byte array. The DateTime value to convert. A byte array containing the S7 DateTimeLong representation of . Thrown when the value of is before or after . Converts an array of values to a byte array. The DateTime values to convert. A byte array containing the S7 DateTimeLong representations of . Thrown when any value of is before or after . Contains the conversion methods to convert DInt from S7 plc to C# int (Int32). Converts a S7 DInt (4 bytes) to int (Int32) Converts a int (Int32) to S7 DInt (4 bytes) Converts an array of int (Int32) to an array of bytes Converts an array of S7 DInt to an array of int (Int32) Contains the conversion methods to convert Real from S7 plc to C# double. Converts a S7 Real (4 bytes) to double Converts a S7 DInt to double Converts a S7 DWord to double Converts a double to S7 Real (4 bytes) Converts an array of double to an array of bytes Converts an array of S7 Real to an array of double Contains the conversion methods to convert DWord from S7 plc to C#. Converts a S7 DWord (4 bytes) to uint (UInt32) Converts 4 bytes to DWord (UInt32) Converts a uint (UInt32) to S7 DWord (4 bytes) Converts an array of uint (UInt32) to an array of S7 DWord (4 bytes) Converts an array of S7 DWord to an array of uint (UInt32) Contains the conversion methods to convert Int from S7 plc to C#. Converts a S7 Int (2 bytes) to short (Int16) Converts a short (Int16) to a S7 Int byte array (2 bytes) Converts an array of short (Int16) to a S7 Int byte array (2 bytes) Converts an array of S7 Int to an array of short (Int16) Converts a C# int value to a C# short value, to be used as word. Contains the conversion methods to convert Real from S7 plc to C# double. Converts a S7 LReal (8 bytes) to double Converts a double to S7 LReal (8 bytes) Converts an array of double to an array of bytes Converts an array of S7 LReal to an array of double Contains the conversion methods to convert Real from S7 plc to C# double. Converts a S7 Real (4 bytes) to float Converts a float to S7 Real (4 bytes) Converts an array of float to an array of bytes Converts an array of S7 Real to an array of float Contains the methods to convert from S7 strings to C# strings An S7 String has a preceeding 2 byte header containing its capacity and length The Encoding used when serializing and deserializing S7String (Encoding.ASCII by default) StringEncoding must not be null Converts S7 bytes to a string Converts a to S7 string with 2-byte header. The string to convert to byte array. The length (in characters) allocated in PLC for the string. A containing the string header and string value with a maximum length of + 2. Initializes a new instance of the class. The string type. Reserved length of the string in characters. Please use a valid value for the string type Gets the type of the string. The string type. Gets the reserved length of the string in characters. The reserved length of the string in characters. Gets the reserved length in bytes. The reserved length in bytes. String type. ASCII string. Unicode string. Contains the methods to convert from S7 wstrings to C# strings An S7 WString has a preceding 4 byte header containing its capacity and length Converts S7 bytes to a string Converts a to S7 wstring with 4-byte header. The string to convert to byte array. The length (in characters) allocated in PLC for the string. A containing the string header and string value with a maximum length of + 4. Contains the conversion methods to convert Real from S7 plc to C# float. Converts a S7 Real (4 bytes) to float Converts a S7 DInt to float Converts a S7 DWord to float Converts a double to S7 Real (4 bytes) Converts an array of float to an array of bytes Converts an array of S7 Real to an array of float Contains the methods to convert from S7 Array of Chars (like a const char[N] C-String) to C# strings Converts a string to of bytes, padded with 0-bytes if required. The string to write to the PLC. The amount of bytes reserved for the in the PLC. Converts S7 bytes to a string Contains the method to convert a C# struct to S7 data types Gets the size of the struct in bytes. the type of the struct the number of bytes Creates a struct of a specified type by an array of bytes. The struct type The array of bytes The object depending on the struct type or null if fails(array-length != struct-length Creates a byte array depending on the struct type. The struct object A byte array or null if fails. Converts the Timer data type to C# data type Converts the timer bytes to a double Converts a ushort (UInt16) to an array of bytes formatted as time Converts an array of ushorts (Uint16) to an array of bytes formatted as time Converts an array of bytes formatted as time to an array of doubles Contains the methods to convert between and S7 representation of TIME values. The minimum value supported by the specification. The maximum value supported by the specification. Parses a value from bytes. Input bytes read from PLC. A object representing the value read from PLC. Thrown when the length of is not 4 or any value in is outside the valid range of values. Parses an array of values from bytes. Input bytes read from PLC. An array of objects representing the values read from PLC. Thrown when the length of is not a multiple of 4 or any value in is outside the valid range of values. Converts a value to a byte array. The TimeSpan value to convert. A byte array containing the S7 date time representation of . Thrown when the value of is before or after . Converts an array of values to a byte array. The TimeSpan values to convert. A byte array containing the S7 date time representations of . Thrown when any value of is before or after . Converts an array of T to an array of bytes Converts an array of T repesented as S7 binary data to an array of T Contains the conversion methods to convert Words from S7 plc to C#. Converts a word (2 bytes) to ushort (UInt16) Converts 2 bytes to ushort (UInt16) Converts a ushort (UInt16) to word (2 bytes) Converts an array of ushort (UInt16) to an array of bytes Converts an array of bytes to an array of ushort