mathiask88 / node-snap7

node.js wrapper for snap7
MIT License
162 stars 59 forks source link

How to get Merker block size #33

Closed BrkDalkiran closed 5 years ago

BrkDalkiran commented 6 years ago

Hi there, Thank you for your great package ... We can get dbblocksize with 'GetAgBlockInfo' method and 'MC7Size' field. We need to read Merker data from PLC and plan to use MBRead method. But we don't want read single address and we want full block. So we need MerkerBlock size. Is there a method or property for this requirement. Thank you.

mathiask88 commented 6 years ago

I don't know if I understand your question right, but AFAIK the Merker blocks are a hardware dependent configuration. For example a S7-312 has Merkerbits from 0.0 to 255.7, Merkerbytes from 0 to 255, Merkerwords from 0 to 254 and Merkerdoublewords from 0 to 252.

BrkDalkiran commented 6 years ago

I use the GetCpuInfo for hardware check. It's work on S7-3XX and S7-4XX, 'ModuleTypeName' is enough for check. We set the 'Amount' value accordingly. For example: if (cpuResult == 'CPU 3') { Amount = 8192; } if (cpuResult == 'CPU 4') { Amount = 4096; }

We added a new PLC on system. This is a S7-1200. GetCpuInfo is not working on this. Error num: 12582912, error text: 'Item not available' How else can we control it?

BrkDalkiran commented 6 years ago

I have read these notes : http://snap7.sourceforge.net/snap7_client.html#target_compatibility It is possible the problem is S7-1200 not supporting snap7 protocol fully.

mathiask88 commented 6 years ago

Hey, Siemens has a new protocol for their new 1200,1500. They still support the legacy protocol, but not for all functions. That's the reason for the compatibility table. If the CPUs have these fixed sizes you could try to read MB4097 and if that errors it is a 4096er and if it works it's probably a 8192er. Or hardcode it, or store it in a DB . What's the reason that you want to read this from the CPU and don't hard code it like 192.x.x.x has 4096 merker bytes?