Click here to Skip to main content
15,887,485 members
Articles / Programming Languages / XML
Tip/Trick

Modbus TCP class

Rate me:
Please Sign up or sign in to vote.
4.89/5 (84 votes)
23 May 2014CPOL 1.7M   60.4K   154   171
A Modbus TCP class.

The project has moved to GIT

https://github.com/stephan1827/modbusTCP

Please download and ask questions from there.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems Engineer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
AnswerRe: Slave_ID and Slave_Address Pin
Stephan Stricker14-Jun-13 3:51
Stephan Stricker14-Jun-13 3:51 
Questionvalues of message Pin
monkar22-May-13 7:08
monkar22-May-13 7:08 
AnswerRe: values of message Pin
Stephan Stricker22-May-13 7:23
Stephan Stricker22-May-13 7:23 
GeneralRe: values of message Pin
monkar22-May-13 23:57
monkar22-May-13 23:57 
GeneralRe: values of message Pin
Stephan Stricker23-May-13 2:18
Stephan Stricker23-May-13 2:18 
GeneralRe: values of message Pin
monkar23-May-13 6:02
monkar23-May-13 6:02 
GeneralRe: values of message Pin
Stephan Stricker24-May-13 8:54
Stephan Stricker24-May-13 8:54 
QuestionRe: values of message Pin
vinnie_j26-Jul-13 3:11
vinnie_j26-Jul-13 3:11 
Hello Stephen,

I tried using the example in a different context, Instead of havin btnReadHoldReg_Click(..) invoke the callbacks I have an example that works on timers. Lets call this function ReadHoldReg_Click().

It works for a while, but then the "values" array becomes NULL Frown | :( and there is nothing to copy and an exception is thrown. Since my example is too big to debug I am trying to modify your example to work on "ticks" rather than "clicks" to see if the same undesired behavior can be somehow provoked.

Originally I tried using a Modbus driver from a different source, but this never worked. The connection dropped after a while and the reconnection sequence did not work for me.

https://groups.google.com/forum/#!topic/nmodbus-discuss/Tb834C5wnpU[^]

Has anyone experienced the "values" array in the frmStart.cs module going NULL?
....
C++
grpData.Text = "Read holding register";
globaldata = values;  // sometimes goes NULL


regards
Colm


modified 26-Jul-13 9:38am.

QuestionSiemens S1200 Pin
Andrea Feduzzi14-May-13 6:09
professionalAndrea Feduzzi14-May-13 6:09 
AnswerRe: Siemens S1200 Pin
Stephan Stricker22-May-13 7:13
Stephan Stricker22-May-13 7:13 
GeneralRe: Siemens S1200 Pin
Andrea Feduzzi31-May-13 6:19
professionalAndrea Feduzzi31-May-13 6:19 
GeneralMy vote of 5 Pin
JongchanAhn24-Mar-13 15:03
JongchanAhn24-Mar-13 15:03 
GeneralRe: My vote of 5 Pin
Andrea Feduzzi14-May-13 6:10
professionalAndrea Feduzzi14-May-13 6:10 
Questionproblem with writing to Siemens PLC holding register with MODBUS TCP Pin
Member 941116121-Dec-12 9:14
Member 941116121-Dec-12 9:14 
AnswerRe: problem with writing to Siemens PLC holding register with MODBUS TCP Pin
Stephan Stricker21-Dec-12 22:55
Stephan Stricker21-Dec-12 22:55 
GeneralRe: problem with writing to Siemens PLC holding register with MODBUS TCP Pin
Member 94111612-Jan-13 9:16
Member 94111612-Jan-13 9:16 
GeneralRe: problem with writing to Siemens PLC holding register with MODBUS TCP Pin
Stephan Stricker3-Jan-13 4:12
Stephan Stricker3-Jan-13 4:12 
GeneralRe: problem with writing to Siemens PLC holding register with MODBUS TCP Pin
Member 94111612-Jan-13 12:16
Member 94111612-Jan-13 12:16 
AnswerRe: problem with writing to Siemens PLC holding register with MODBUS TCP Pin
Andrea Feduzzi14-May-13 6:12
professionalAndrea Feduzzi14-May-13 6:12 
QuestionCan't Write Coils Pin
KitaMenang22-Nov-12 3:08
KitaMenang22-Nov-12 3:08 
AnswerRe: Can't Write Coils Pin
Stephan Stricker22-Nov-12 3:17
Stephan Stricker22-Nov-12 3:17 
Questionconvert error Pin
tomasz25616-Nov-12 2:28
tomasz25616-Nov-12 2:28 
AnswerRe: convert error Pin
Stephan Stricker18-Nov-12 8:44
Stephan Stricker18-Nov-12 8:44 
QuestionCan't open with free ms tools Pin
chris wedgwood26-Oct-12 4:09
chris wedgwood26-Oct-12 4:09 
AnswerRe: Can't open with free ms tools Pin
Stephan Stricker18-Nov-12 8:45
Stephan Stricker18-Nov-12 8:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.