GithubHelp home page GithubHelp logo

modbus-tcp-tutorials's People

Contributors

simplyautomationized avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

modbus-tcp-tutorials's Issues

Crash when attempting to add input registers

First of all to thank you for your contribution. Your tutorials have helped me a lot to understand the protocol.

I am trying to replicate the same tempSensors project. I used your code for the Modbus server with a simple client code.
My problem is that I get the following error when reviewing the server query:

DEBUG:pymodbus.factory:Factory Request[ReadInputRegistersRequest: 4]
DEBUG:pymodbus.datastore.context:validate: fc-[4] address-1: count-1
DEBUG:pymodbus.datastore.context:getValues fc-[4] address-1: count-1
Unhandled Error
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/twisted/python/log.py", line 103, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/usr/local/lib/python3.5/dist-packages/twisted/python/log.py", line 86, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/usr/local/lib/python3.5/dist-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/local/lib/python3.5/dist-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
--- ---
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
why = selectable.doRead()
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/tcp.py", line 243, in doRead
return self._dataReceived(data)
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/tcp.py", line 249, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/usr/local/lib/python3.5/dist-packages/pymodbus/server/asynchronous.py", line 70, in dataReceived
unit=units)
File "/usr/local/lib/python3.5/dist-packages/pymodbus/framer/socket_framer.py", line 153, in processIncomingPacket
self._process(callback)
File "/usr/local/lib/python3.5/dist-packages/pymodbus/framer/socket_framer.py", line 181, in _process
callback(result) # defer or push to a thread?
File "/usr/local/lib/python3.5/dist-packages/pymodbus/server/asynchronous.py", line 91, in _execute
self._send(response)
File "/usr/local/lib/python3.5/dist-packages/pymodbus/server/asynchronous.py", line 100, in _send
pdu = self.framer.buildPacket(message)
File "/usr/local/lib/python3.5/dist-packages/pymodbus/framer/socket_framer.py", line 206, in buildPacket
data = message.encode()
File "/usr/local/lib/python3.5/dist-packages/pymodbus/register_read_message.py", line 79, in encode
result += struct.pack('>H', register)
struct.error: required argument is not an integer

DEBUG:pymodbus.server.asynchronous:Client Disconnected: [Failure instance: Traceback: <class 'struct.error'>: required argument is not an integer.

It seems that the register_read_message method requires an integer.
I don't know if you could help me with this problem.

Thank you

the client code:

from pymodbus.client.sync import ModbusTcpClient as ModbusClient

import logging

FORMAT = ('%(asctime)-15s %(threadName)-15s '
'%(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger()
log.setLevel(logging.DEBUG)

client = ModbusClient('localhost', port=502)
connection = client.connect()
print("Connected: " + str(connection))

request = client.read_input_registers(0, 1)

if request.isError():
# handle error, log?
print('Modbus Error:', request)
else:
result = request.registers
print(result)

client.close()

how get unit id of client

I am making a server in pymodbus and I need to save in the database as I do to tell the database this data was sent by that client.

Because there will be 200 connected clients, I need to know that the data that I received who sent it. How would you do that.. I have sampling time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.