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

use it #1

Open
xietuliang opened this issue Apr 22, 2021 · 1 comment
Open

use it #1

xietuliang opened this issue Apr 22, 2021 · 1 comment

Comments

@xietuliang
Copy link

I have added the following code in file "ModBus/src/Request.h". When I want to use file "ModBus/src/SerialConnection.h" to communicate , I find there is no way to establish a bound connection between "modbus::PDU" and "modbus::Request".And I have to use this code "void SerialConnection::send_request(Request& request)" to send a request.

void Request::set_pdu(std::unique_ptr<PDU>& pdu_ptr) {
	pdu_ = std::move(pdu_ptr);
}

I'm a rookie. Please forgive me if I said something wrong.

@xeedjr
Copy link
Owner

xeedjr commented Jun 19, 2021

Hi Sorry for the long response.
Looks like that you need to use one of ReadHoldingRegistersRequest classes that are inherited from the Request class and have access to the internal field of _pdu.
And use ModbusSerialTransaction to execute transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants