Modbus TCP listener in C#.net

C

Thread Starter

chaitu18

Hi Friends,

I am new to this forum and i need your help to develop my first Modbus Application in c#.net.

Here is my requirement: I need to develop one TCP listener in c#.net which can handle multiple modbus clients and can communicate with them like sending proper command and getting response back and then storing data into the DB. i found one driver/.dll at http://www.nmodbus.com/ but i don't think it is useful for me as it has all inbuilt functionality for making connection and sending/receiving commands/responses.

My program will be simply opposite of that. it will be in listening mode. if it find any active connection, it will send command and get response back and store it into DB. i hope you will get idea on what actually i am looking for. Please help me from where to start. I will appreciate for any reply.

thanks in advance
 
A "TCP listener"? Do you mean a Modbus/TCP server? The client sends a request to the server, and the server responds. Is that what you mean?

However, you also said "if it find any active connection, it will send command and get response back and store it into DB". That's what *client* does. Your second and third paragraphs contradict one another. If you would like to clarify what you are doing, I might be able to help.

I wrote my own client and server Modbus/TCP classes in Python because there wasn't anything that let me do what I wanted directly. The off the shelf libraries all wanted to handle the connection directly, which meant that I couldn't use them in my applications (embed them in off the shelf servers).

Modbus is a very simple protocol. You can encode or decode a Modbus message with one line of Python. You could probably do the equivalent in a few dozen lines of C#. If I understand what I think you are trying to do, then I think that is what you will end up doing.
 
Automated Solutions offers a Modbus Slave (server) ActiveX Control that can be used in C# Windows Forms apps.

http://automatedsolutions.com/products/modbusslave.asp

Your application simply reads/writes from/to pre-defined arrays representing discrete inputs and outputs, and input and output registers. The control handles all Modbus commands in the background.

Free, fully functioning 30-day trial version is available for download.

-Mark
http://automatedsolutions.com
 
Top