Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am creating RTU using NModbus.
Installed NModbus package using following command in Package Manager Console
Install-Package NModbus
Now I am creating RTU by following line.
IModbusSerialMaster master = ModbusSerialMaster.CreateRtu(Port);
But I am getting error
'ModbusSerialMaster' is inaccessible due to its protection level
What is the reason and how can I create Modbus RTU to read and wrtite multiple register.
Thanks in advance.
Yes, it's because ModbusSerialMaster
is an internal class, as you can see in the source.
Browsing around the code, I suspect you want something like this:
IModbusFactory factory = new ModbusFactory();
IModbusSerialMaster = factory.CreateMaster(transport);
... where transport
is something that implements IModbusSerialTransport
.
Alternatively, if you don't need an IModbusSerialMaster
but an IModbusRtuTransport
you'd call CreateRtuTransport
:
IModbusFactory factory = new ModbusFactory();
IModbusRtuTransport = factory.CreateRtuTransport(resource);
... where resource
is something that implements IStreamResource
.
For anything further, I'd probably just clone the source code and browse around it to work out what you can do and what you need.
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.