Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modbus RTU multiple devices per serial port. #211

Open
T1bbY opened this issue Oct 28, 2021 · 12 comments
Open

Modbus RTU multiple devices per serial port. #211

T1bbY opened this issue Oct 28, 2021 · 12 comments
Labels
help wanted Extra attention is needed

Comments

@T1bbY
Copy link

T1bbY commented Oct 28, 2021

Hello,

when i create multiple device's as ModbusRTU and want to use the same serial port, it does not work.
That make sense as it try's to open a new connection to the serial port.

But i habe a ModbusRTU with multiple devise's and all different ID's and i can only access one at a time.

Would be nice to add the possibility to communicate with multiple ID's on the same RTU connection.

Kindly regards :)

@unocelli
Copy link
Member

Hi, Thanks for the report.
I understand what you mean, I could try to share the connection with other devices and manage the flow and set the ID.

@zhang9591
Copy link

Hope to see this update!

@unocelli unocelli added the help wanted Extra attention is needed label Apr 16, 2022
@rvbatista
Copy link
Contributor

I studied the code a little bit and seems that need another layer for the physical connection (serial port) above the device layer, or assumes that the device is the serial port and each tag have the modbus unit id property. The same will apply to issue #755.

@unocelli
Copy link
Member

@rvbatista Hi, I have not yet examined it well, but I think it might be sufficient to map all tags of all devices configured as RTUs to one device by grouping them by Id.

@rvbatista
Copy link
Contributor

@unocelli this will be faster to do, but will break the timeout and connect logic. I'm not experienced in node and zero experience in angular, but it's I'm interested in trying to implement this modification.

@unocelli
Copy link
Member

@rvbatista polling waits for the response with await and before reading you can sets the respective deviceId, after correct mapping you extend _readMemory with the deviceId parameter and before reading it you sets the id client.setID(deviceId);

@unocelli
Copy link
Member

@rvbatista thinking back, maybe it is simpler to share the client component (ModbusRTU) between the different devices and define a main device (the first one) that handles the connection, in this case you don't have to make a new mapping but to synchronize the communication

@PaDaBooo
Copy link

I implemented the function of multiple SlaveID under ModbusRTU by adding a SlaveID property to each Tag.
Do you have a better solution?
If not, I will submit the server code tomorrow.

@PaDaBooo
Copy link

By the way, sharedDevices in src don't seem to be useful
image

@rvbatista
Copy link
Contributor

rvbatista commented Sep 19, 2023

By the way, sharedDevices in src don't seem to be useful image

@PaDaBooo this sharedDevices was the beginning of development and really does nothing at this moment. I didn't had much time to work with this issue. The solution that you implemented is not the best, but better to have something as work around than wait for the best solution.
Thank you.

@Github-User-002
Copy link

Hi there
I have over 4 modbus RTU devices and only 2 com ports on my pi4 screen
I have no opportunities to add one com port for every device on my modbus
Modbus is a bus that supports 16 bits of devices and not a point to point protocol
supporting only 1 device on a bus is a big failure and must be resolved

@fugreat
Copy link

fugreat commented Nov 6, 2024

I've found a method to reuse a serial port.
As we are aware, since version 1.2.1, Fuxa has enabled the reuse of Modbus TCP ports with mutex.
This presents us with an option to convert a serial port into a Modbus TCP port.
The tool mbusd is capable of performing this conversion.
To utilize this feature, you'll need to compile and install mbusd.

Usage Instructions:

For instance, if you have a serial port at /dev/ttyAMA2 and you wish to connect it to localhost on port 10001, you can use the following command:

sudo mbusd -L /tmp/mbusd.log -p /dev/ttyAMA2 -s 9600 -P 10001 -d -v9 -N1 -R20 -W110

Upon executing this command, you will have a Modbus TCP port accessible at 127.0.0.1:10001.

At FUXA, you can config like this:
image
"socket 复用" select the 1st option(leave bank)。

If you need further assistance or have more details to add, feel free to let me know!
And hope to help someone on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants