I’m going to need more detail to be able to help?
What does your configuration look like?
What exactly is the error message and where do you see it?
How is the physical device connected and configured?
Is anything sent from the port?
Are there any further device diagnostics?
Unfortunately with all serial communications, including modbus, just one configuration error or wiring error on the master or slave will mean the communications doesn’t work. The process to solve this is really to carefully check every step.
If I was debugging your system, I would first extract as much detail on the error as possible to see if that helps.
Try answering these questions.
Does the master send a modbus request?
Is it at the right baud rate, parity etc?
Does the slave see the request?
Do it’s comms settings match?
Is the UID correct?