Hello,
I would like to send from my PC (with Docklight or QModMaster) a value (random for the moment) via an USB-RS485 converter at an address in order to read/recuparate this value with my Raspberry (Slave) and display it on an LCD screen.
To do that,
I used the “Synchronous Server Example” below:
import ...
EN_485 = 4
GPIO.setmode(GPIO.BCM)
GPIO.setup(EN_485,GPIO.OUT)
GPIO.output(EN_485,GPIO.LOW)
# --------------------------------------------------------------------------- #
# configure the service logging
# --------------------------------------------------------------------------- #
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)
def run_server():
store = ModbusSlaveContext(
di=ModbusSequentialDataBlock(0, [0]*0xFF),
co=ModbusSequentialDataBlock(0, [0]*0xFF),
hr=ModbusSequentialDataBlock(0, [0]*0xFF),
ir=ModbusSequentialDataBlock(0, [0]*0xFF))
context = ModbusServerContext(slaves=store, single=True)
# ----------------------------------------------------------------------- #
# initialize the server information
# ----------------------------------------------------------------------- #
identity = ModbusDeviceIdentification()
identity.VendorName = 'Pymodbus'
identity.ProductCode = 'PM'
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/'
identity.ProductName = 'Pymodbus Server'
identity.ModelName = 'Pymodbus Server'
identity.MajorMinorRevision = '2.3.0'
# RTU:
StartSerialServer(context, framer=ModbusRtuFramer, identity=identity,
port='/dev/ttyAMA0', timeout=.005, baudrate=9600)
GPIO.cleanup()
if __name__ == "__main__":
run_server()
From Docklight I send the frame in hex: 01 06 0097 0003 A077 to write at the address 97 the value “3”.
This is my shell window when I run my code and I send the frame with Docklight :
My RPi receive the frame with the good address and value.
My question is: How can I do to recuperate this value I sent from my PC to display it on my LCD screen?
Thank you
PS: I don't have a lot of knowledges but i'm trying to learn :)
--
You received this message because you are subscribed to the Google Groups "pymodbus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymodbus+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pymodbus/2bf3c891-dde5-4a9f-8ad1-29e44828aa11n%40googlegroups.com.