pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.23k stars 911 forks source link

Request for feature of "native or a RFC 2217 implementation of the Serial class, depending on port/url" #316

Closed madhujk closed 3 years ago

madhujk commented 6 years ago

Versions

Pymodbus Specific

Description

What were you trying, what has happened, what went wrong, and what did you expect?

Code and Logs

 # code and logs here.
dhoomakethu commented 6 years ago

@madhujk Could you provide more info on your request ?

madhujk commented 6 years ago

It is a request to support both, local ports and remote ports servers supporting rfc2217 format , format: rfc2217://:[?

Pyserial support above url handler to connect to remote ports with "serial_for_url()".

pymodbus dymanically can connect to local port or remote port based on input to the server

dhoomakethu commented 6 years ago

@madhujk thanks for the idea. Its good to have but I do not see much users for this feature. I will leave this open for anyone to go ahead and implement and raise a PR. Feel free to contribute.

isj4 commented 5 years ago

I need this, specifically the "hwgrep://" syntax. Scenario: Remote box, two FTDI RS-485 USB adapters, other USB devices also show up as /dev/ttyUSB*, so I cannot rely on the device names as they change on reboot. So ideally I would specify the serial ports to be: "hwgrep://0403:6001" and "hwgrep://0403:6001&n=2"

I hacked the pymodbus module, sync.py, ModbusSerialClient.connect() Instead of:

        self.socket = serial.Serial(port=self.port,
                                    timeout=self.timeout,
                                    bytesize=self.bytesize,
                                    stopbits=self.stopbits,
                                    baudrate=self.baudrate,
                                    parity=self.parity)

I use this:

        self.socket = serial.serial_for_url(self.port,
                                            timeout=self.timeout,
                                            bytesize=self.bytesize,
                                            stopbits=self.stopbits,
                                            baudrate=self.baudrate,
                                            parity=self.parity)

That's it. Works for me.

dhoomakethu commented 5 years ago

@isj4 Thanks for the workaround, I will see if this is something we can support from the pymodbus library directly

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

isj4 commented 3 years ago

I still need this.