Wish list : Which feature would you like to see in modbus-tk

233 views
Skip to first unread message

luc

unread,
May 24, 2011, 9:20:28 AM5/24/11
to modbus-tk
Hello all,

I am thinking of potential improvements to the modbus-tk lib. Is there
anything that you would like to see in the lib?

Thanks in advance for your feedback.

Best
luc

Jonathan Dobson

unread,
Jul 15, 2011, 11:31:10 AM7/15/11
to modb...@googlegroups.com
Support RTU over TCP out of the box?  From here (https://groups.google.com/forum/#!topic/modbus-tk/99LdDVAIgjE) you mentioned it would be easy to implement.

luc

unread,
Jul 15, 2011, 1:42:09 PM7/15/11
to modb...@googlegroups.com
Hi Jonathan and Thanks for this feedback.
That's a good idea
Best
luc

Knucklehead

unread,
Jul 17, 2011, 10:24:15 PM7/17/11
to modbus-tk

I would like to execute a MODBUS (read) command and have the
data value come back into some sort of structure for me to be able
to format as I please.

Is this doabel with the current implementation? If not, I would like
to
be able to do this.

Luc JEAN

unread,
Jul 18, 2011, 2:44:32 AM7/18/11
to modb...@googlegroups.com
Hello,

Yes I think it can be done. The data comes back as a tuple. Then you can format it as you want.
I am not sure if it meets your needs. Any example of what you want to achieve?

Best
luc

2011/7/18 Knucklehead <jmg...@gmail.com>

Knucklehead

unread,
Jul 18, 2011, 5:44:08 PM7/18/11
to modbus-tk

I would like to execute the command, save the vale then print it in my
format:


values = master.execute(slave, cst.READ_COILS, 0, 4)
count = 1
for v in values:
print "COIL %d = %d" % (count, v)
count = count + 1


Thanks for your support.


On Jul 18, 1:44 am, Luc JEAN <luc.j...@gmail.com> wrote:
> Hello,
>
> Yes I think it can be done. The data comes back as a tuple. Then you can
> format it as you want.
> I am not sure if it meets your needs. Any example of what you want to
> achieve?
>
> Best
> luc
>
> 2011/7/18 Knucklehead <jmg....@gmail.com>

Luc JEAN

unread,
Jul 19, 2011, 1:41:20 AM7/19/11
to modb...@googlegroups.com
We can imagine to add a callback optional arg to the execute method. This callback would be called for every value returned.
But I am not sure this callback feature is really required because you can iterate easily in your own code.
In your example, i don't see a big need of such a callback.
If you use the enumerate function, it is just 3 lines of code:


values = master.execute(slave, cst.READ_COILS, 0, 4)
for i, v in enumerate(values):
    print 'COIL', (i+1), '=', v

I think it is ok to format the results like this.

Anyway, thanks for this idea.
Best
luc

2011/7/18 Knucklehead <jmg...@gmail.com>




--
http://www.apidev.fr

Knucklehead

unread,
Jul 19, 2011, 12:28:30 PM7/19/11
to modbus-tk

Thanks for your support.

After sending the last comment I tried the code and it pretty much
worked.
I am now able to do what I was wishing for.

As far as I am concerned, there is no need for a callback mechanism.


On Jul 19, 1:41 am, Luc JEAN <luc.j...@gmail.com> wrote:
> We can imagine to add a callback optional arg to the execute method. This
> callback would be called for every value returned.
> But I am not sure this callback feature is really required because you can
> iterate easily in your own code.
> In your example, i don't see a big need of such a callback.
> If you use the enumerate function, it is just 3 lines of code:
>
> values = master.execute(slave, cst.READ_COILS, 0, 4)
> for i, v in enumerate(values):
>     print 'COIL', (i+1), '=', v
>
> I think it is ok to format the results like this.
>
> Anyway, thanks for this idea.
> Best
> luc
>

Hector Simosa

unread,
Aug 16, 2013, 9:30:02 AM8/16/13
to modb...@googlegroups.com

I am new to modbus standard and after googling found Modbus-TK. It seems to be an awesome application from what I read, but I was unable to find how to use it. There are many examples but not one explanation on how to use it.

Please, will anyone tell me where I can find info regarding the proper methodology to use modbus-tk?. Believed Modbus-TK needs a good manual describing how to use it.


Also, how modbus-tk defines the addresses for different registers. It seems differs from modbus standard. For example I grasp the following command from rtumaster_example.py:

logger.info(master.execute(1, cst.READ_HOLDING_REGISTERS, 100, 3))


Modbus standard assign to FC 03 read HOLDING_REGISTERS the register set from 40000 to 50000, how modbus-tk change to a 100?

What I am missing?

Thanks

Hector

alex chiosso

unread,
Aug 16, 2013, 9:39:27 AM8/16/13
to modb...@googlegroups.com
Hi Hector .

Because FC03 is the function that point to the HOLDING REGISTER and the modbus offset is 40000 that means that 100 is corresponding to the register 40100 so you do not have to explicitly declare the address but only the offset inside the HOLDING REGISTER area .

Regards
Alex


--
You received this message because you are subscribed to the Google Groups "modbus-tk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modbus-tk+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hector Simosa

unread,
Aug 16, 2013, 3:06:27 PM8/16/13
to modb...@googlegroups.com

Thanks for your clear answer.

Hector

Gerry Murray

unread,
Sep 10, 2013, 12:04:52 PM9/10/13
to modb...@googlegroups.com
Hi Luc

It would be nice if the logger could format its messages in hex.
I've been able to hex format the returned tuples without trouble but it would be nice to see all the traffic in hex.

Other than that, I've found the toolkit immensely useful.
In case you're interested in my use of modbus tk, here's what I'm doing.

I'm designing the hardware and software for industrial monitoring products and there's a massive amount of coding/testing to be done.
Here's how I've been doing my testing
From my embedded C file in MPLAB, I paste all the holding register enums in to a C# application that I use to generate a Python file that contains all the named holding registers, explicitly numbered eg
BM_BRANCH_SUMMARY_REGISTERS_BASE = 2000
BM_BRANCH_STRIP_ADDRESS = 2001
BM_BRANCH_SERIAL_NUMBER_HIGH = 2002
BM_BRANCH_SERIAL_NUMBER_LOW = 2003
BM_SOFTWARE_VERSION = 2004

I include the python file at script run time and then I'm able run modbus tk scripts that use the named register rather than difficult to maintain addresses. eg :

master.execute(1, cst.WRITE_SINGLE_REGISTER, mydefines.BM_COMMAND_UNLOCK_REGISTER, output_value=0x55aa)

This means that I can change my software, move holding registers, and it's a 3 minute task to re-create a Python defines file to allow re-testing.

The biggest benefit for me though is that I can run complex scripts looping 1000's of times to verify my code to high degree of confidence.

Hope you found this interesting and thanks again for a great tool.

Gerry

Luc JEAN

unread,
Sep 10, 2013, 12:18:52 PM9/10/13
to modb...@googlegroups.com
Hi Gerry,

Thanks for the suggestion. I would integrate that into a next version. However, I am quite busy and I don't think that I can do something before the beginning of 2014. I hope this can wait :)

Thanks also for the feedback. It's nice to know that this lib is useful. It's the primary goal. Just one question, why do you use C# to generate the python file? Isn't it easier to make this config generator in python? Are you more comfortable in C#?

Best
luc  


2013/9/10 Gerry Murray <clay...@gmail.com>

--

Gerry Murray

unread,
Sep 10, 2013, 4:31:32 PM9/10/13
to modb...@googlegroups.com
Hi Luc

No hurry on the hex formatted output. It more than meets my needs as it stands.

Got it in one: Yes, C# is my comfort zone for desktop apps. Very much a beginner with Python but it speaks well for your toolkit that I was able to get up and running with it in about an hour.
Hopefully, with the small challenges I'll have to face with my test scripts, I'll be able to pick up some skills on Python.

Thanks and best wishes.

Gerry Murray
Glasgow
Scotland
Reply all
Reply to author
Forward
0 new messages