We have Siemens PLC S7-300 with Ethernet communication port.
Which type of java or other language coding available for getting the frame data of plc.?
this PLC communicate only with step-7 software.
This frame structure data also can store in xml of some text file so we can continuous send it to internet.
Please help me
There are 3rd party libraries that allow that. At our company we are using Accon AGLink. It's a native library, but it also provides a .NET wrapper. The library is somewhat fast. You could also try this one (indi.an PLCCom) which is managed, and not so fast, but it has a free version.
Alternatively you could try setting up an OPC server and read the PLC data using an OPC client, but they are somewhat expensive.
Have a look at Snap7, which is written in C but with many wrappers and ports available, including Python, Node.js, .NET, C#, Arduino, and one in Java called Moka7, since you asked.
From the official documentation:
Snap7 is an open source, 32/64 bit, multi-platform Ethernet communication suite for interfacing natively with Siemens S7 PLCs. The
new CPUs 1200/1500, the old S7200, the small LOGO 0BA7/0BA8 and SINAMICS Drives are also partially supported.
I'm assuming that your setup consists on an S7-300 CPU with a CP 343 communication module. To read data from the CPU, the system must be running an S7 server (configurable via NetPro, inside SIMATIC Manager, as explained in the Siemens commissioning manual). The remote machine should be using the Snap7 client library.
The library includes functions to read different memory areas, such as the process inputs (I), process outputs (Q), merkers (M), timers (T), and counters (C), as well as general purpose data blocks (DBs). If the server is enabled, and the configuration is not restricted (for instance to a certain IP address) the client should have access by default to at least the I's, Q's and M's, as well as to some system properties (like the CPU model and the firmware version).
For your case in Java, have a look at the Moka7 documentation, which can be found in the same download package. There are several code examples to get started.
If successful, the ReadArea function will return hex data of the bytes you specified (i.e. the memory position to start reading from, and the number of bytes). As a remark, remember that most Siemens PLCs are big-endian, so you may have to make a conversion if you're reading memory areas that hold data in different types.
Related
There are multiple network adapters of the same model in the target computer. As below, they are all Intel I211.
PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03\0060E0FFFF6336A000
Name: Intel(R) I211 Gigabit Network Connection
Hardware IDs:
PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03
PCI\VEN_8086&DEV_1539&SUBSYS_00008086
PCI\VEN_8086&DEV_1539&CC_020000
PCI\VEN_8086&DEV_1539&CC_0200
Compatible IDs:
PCI\VEN_8086&DEV_1539&REV_03
PCI\VEN_8086&DEV_1539
PCI\VEN_8086&CC_020000
PCI\VEN_8086&CC_0200
PCI\VEN_8086
PCI\CC_020000&DT_0
PCI\CC_020000
PCI\CC_0200&DT_0
PCI\CC_0200
PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03\0060E0FFFF6336A100
Name: Intel(R) I211 Gigabit Network Connection #2
Hardware IDs:
PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03
PCI\VEN_8086&DEV_1539&SUBSYS_00008086
PCI\VEN_8086&DEV_1539&CC_020000
PCI\VEN_8086&DEV_1539&CC_0200
Compatible IDs:
PCI\VEN_8086&DEV_1539&REV_03
PCI\VEN_8086&DEV_1539
PCI\VEN_8086&CC_020000
PCI\VEN_8086&CC_0200
PCI\VEN_8086
PCI\CC_020000&DT_0
PCI\CC_020000
PCI\CC_0200&DT_0
PCI\CC_0200
How do I update driver for a specific one of these same model adapters by devcon, C++ or C#? For example, update by the unique device instance ID (ex: PCI\VEN_8086&DEV_1539&SUBSYS_00008086&REV_03\0060E0FFFF6336A100)
Thanks
EDIT:
I've searched APIs for this but they all use hardware ID to update the driver, which will update all of the same model adapters' drivers.
Ex: C++'s UpdateDriverForPlugAndPlayDevicesA and devcon's update command.
EDIT2:
The motivation of this issue is that we are using an RTOS (real-time OS, RTX64) and we want to establish a real-time network communication (EtherCAT connection) with other devices by the RTOS. We need to update one of the adapters' driver to the driver provided by RTX64, so that this adapter can be used by it.
The only workable solution for us to just update one of them is using Windows' "Device Manager". (There's no same model adapters in the below picture, it's just shows how to update by device manager manually)
We are asking our users to do this manual update after installing our software. It's not convenient for them. So we are trying to find an automatic way to do this.
Since Device Manager in Windows can do this, we suppose that there's an API can do this too.
Two workarounds. One minimizes manual customer interaction when updating the device driver, the other fully automates the process, but requires coding in a BASIC like language.
The first one consists on automatically showing the Hardware Update Wizard for that particular device instance, using the API function DiShowUpdateDevice as described in the previous link.
The second one is to use the free AutoIt automation software. With it you can automate basically everything in a Windows system, it's very powerful and I've used it in conjunction with web bots and automatic web testing (non-headless). I've also used it in double-click roll-outs of Windows systems and many sysadmin tasks.
As a remark, you could also mix both approaches. First, use DiShowUpdateDevice to show the wizard and then an AutoIt script can automatically perform UI interaction, the client won't have to do anything at all.
This is not really a average Programmer Problem.
Driver Programming - as a subset of Realtime Programming - is a highly specialized field. The average C# or C++ .NET Programmer will rarely have to deal with stuff like pointers and neer with assembler level code. But for those two, it is their daily bread and butter. I can not give you little more then general advice:
My first advice for you is to get somebody elses code to make that decision and installation. Usually drivers of one Manufacturer are distributed in packages. Wich do understand how to deal with idenitifcation of the hardware. Usually those installers also have a silent mode. So it comes down to calling them and intercepting the console output/looking for the return value.
My second advice, is to use their name as listed in the Device Manager. Optionally get them renamed manually. It is not that reliable as strings are quite patient and easily changed/missmatched, but it would get you somewhere to start from.
But as I understand it your problem is worse then just general driver updates. You have two instances of the same Hardware, and want to use different drivers for each. Wich is a order worse:
I am not even sure this is possible. Since the driver folder still uses the good old "only one file of each name" approach, it is propable that you can not use different drivers for different instances of the same hardware. Unless you define your own driver storage location.
I have no idea why you would do that. The average enduser programm does not need to worry about even selecting wich interface it will use. It just hands it's request off the to network stack and does not deal with layer 3 or below. Servers may have to pick a specific adapter to listen on, or just listen on both in paralell. But even those do not care for the driver version in use. They do not even care if it is a real, physical interface - after all missclassification like with early Bluetooth and Virtual Devices like for Virtual Machine Monitors/PDF printers are a thing.
So it honestly sounds like you got a XY Problem, with this idea being the (propably wrong) Y, to your real X.
We are using protocol buffers messages over grpc to implement a micro service architecture between several components developed in several languages (c# - c++ - java).
One of our component has the responsibility to persist those messages in a document store. Currently we are using mongodb with the c# driver and protocol buffers c# generated classes required hand written serialization/deserialization code to work with c# driver).
Is there any document store / database that could store directly protocol buffers message (not as binary blob) and enable query on those messages properties ?
You could write a "redis module" (4.0) to do the job, similar to how rejson is implemented; redis modules allow you to put your own code 100% inside the server. You'd need to think about how schemas should work, though, and what operations you want to support against the data; essentially: can you leave it raw in a single binary string, or will you need to extract the data inside the server, just using the raw API on the boundary?
Actually I have three questions:
1- According to Nazar Grynko answer, Is it only intercepting the three functions(send , recv,and connect) will help me to anticipate all the packet in my machine?
2- If I hooked the three functions, How to get an IntPtr which points to a sockaddr structure from a P/Invoked native function?
3- Send, and recv are not having sockaddr, so how to figure out the addresses?
Thank you in advance.
The functions you described are a part of the POSIX standard. This means that when you use these functions on Windows, you're actually calling a wrapper that eventually translates to a system call. You can send packets without the use of this function (e.g, by using the Windows API).
See answer number one. This won't help you. You'd also have to provide a hook for all processes.
The functions you describe use a file descriptor which is a POSIX construct, and are user-mode simulated on other systems.
To inspect your traffic you must use a driver that will do it for you. You might want to look at Pcap.Net which is a C# project aimed exactly at your problem, and provides the driver and API necessary.
We create client-server erp system with huge amount(in the future) of data and use c# for client and c for server. We started with xml for small requests/responses and it looks ok for now. But what is the best data exchange format for increasing amount of data per response(up to 100MB i think)?
P.S.
Highest priority is encode/decode speed.
We use Sockets to transfer data.
It really depends on what kind of data you are going to send to and receive back from the server. If “data” is some sort of a buffer with the known length and the usual operations are to put / get an object to / from the server, then I would recommend you to take a look at HTTP: it's a very simple protocol, there are many libraries and applications that support it, you can easily extend the protocol, add an encryption (HTTPS) and compression (gzip), and this protocol is easy to debug and work with.
If you want to send network packets that contain many data fields of different types, then you want to encode and decode such packet (serialize) before sending to the network. There are a plenty of open source libraries in the Internet which support both C and C# languages (you can even write your own implementation, it's not that hard). I would recommend you to take a look at XML / JSON (text-based standards for data exchange), you will find it much more easier to debug communication problem when working with a textural data.
Hope it helps !
I would suggest to take a look at JSON:
http://www.json.org/
How can we implement ASTM protocol in C# to read data from Clinical Device ?
Can any one suggest open source framework to write ASTM segments ?
I've been doing this since Mar of 2008 . I do not know one. Beside this not all of these diagnostic devices 100% compatible with ASTM 1394 . Especially package checksum calculation differs .
But I've infrastructures for Com port and TCP-IP level communications. Using USB directly is not commonly preferable because of the data-loss occurrences. Building an infrastructure for physical layer is logical. Because its a real standard but even for HL7 people use segments carelessly.In practice,this can happen; Lets put the patient insurance number to 11.segment ! But it could be 5 digits integer in standard. They don't care.
Have a look into this http://makecircuits.com/blog/2010-06-25-astm-protocol.html
But you should write on your own.
These guys are saying they had produced one which supports RS232, Bluetooth, HID, USB or network socket connection for ASTM
http://www.deepsoftware.com/nrcomm/astm.html It is not free and probobly won't help for the varity reasons I shared. It says HID supported. HID is Human Interface Driver for USB as you know, just a few diagnostic devices use USB directly. Most of them use USB to send data to their inner central stations and provide you over TCP/IP. But some significant devices support USB directly but not with HID , they had coded their own drivers. Such as Welch Allyn's Propaq LT,its a handy monitor for US army use.
All the best!
Be aware ASTM 1381 & 1394 protocol specs are now maintained by CLSI as LIS01-xx and LIS02-xx (https://clsi.org/standards/products/automation-and-informatics/documents/lis01/). If I am not mistaken there are nuget packages available for LIS01 & LIS02.
Don't think there is open source available.
But you might check http://www.deepsoftware.com/nrcomm/astm.html
the first step you need to understand ASTM, is that you have to work with Control Characters, , , these are not symbols, these are not string, these are not numbers.
so the first step in c# es convert these Control Characters
static string enq = char.ConvertFromUtf32(5);
static string ack = char.ConvertFromUtf32(6);