2 years ago

#52608

test-img

lopes

How to use a modbus protocol with Django?

I'm using django to develop a monitoring system. This monitoring system uses the Modbus RTU communication protocol. A device can be used to use the inline form, as a device can have multiple records, this device is working properly. What happens is that I can't get the saved bank, because it needs the slave's data and the registration number to request the information. I'm using the mimimalmodbus library. Note: I can't get the slave_id and register_number from the database.

My code is in Views.py in django

instrument.serial.stopbits = 1
instrument.serial.timeout = 0.05 # seconds
instrument.serial.xonxoff = False
instrument.precalculate_read_size = False
instrument.mode = minimalmodbus.MODE_RTU # rtu or ascii mode

instrument = minimalmodbus.Instrument('/dev/ttyUSB1', 1)
a =instrument.read(register_number , slave_id)

django

django-views

django-templates

modbus

pymodbus

0 Answers

Your Answer

Accepted video resources