absolute beginner in Python (and Linux for that matter) trying to setup a modbus RTU master to control a stepper motor.
Eventually I will try to implement the solution on a Raspberry Pi, but for now I'm trying to get it to work on a Windows machine. I have python 3.8 installed and am using Pycharm as the IDE.
I think that for my purpose the library 'minimalmodbus' will have everything I need. However, I haven't figured out how to properly open the port yet. I'm trying to follow the documentation here: https://minimalmodbus.readthedocs.io/en/stable/index.html
My particular slave device happens to be at 115200 baud, whereas the default port in minimalmodbus is at 19200.
In the examples this is given:
instrument = minimalmodbus.Instrument('/dev/ttyUSB1', 1, minimalmodbus.MODE_ASCII)
instrument.serial.port # this is the serial port name
instrument.serial.baudrate = 19200 # Baud
Further in the documentation it states the following, which I don't think I've understood:
The module level constants minimalmodbus.BAUDRATE etc were removed in version 1.0
Anyway, this is what I have tried:
instrument = minimalmodbus.Instrument('COM5', 1, minimalmodbus.MODE_RTU)
instrument.serial.BAUDRATE = 115200
First line is accepted fine, the 2nd one is not. Same scenario for .baudrate . I must be missing something obvious.
Thanks!
Turns out that .baudrate was actually correct and compiled/executed as expected. Pycharm just indicated for some reason that "baudrate" could have been a typo