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

How to get hexadecimal modbus rtu message data #257

Open
byte-voyager opened this issue Mar 29, 2024 · 2 comments
Open

How to get hexadecimal modbus rtu message data #257

byte-voyager opened this issue Mar 29, 2024 · 2 comments

Comments

@byte-voyager
Copy link

byte-voyager commented Mar 29, 2024

https://github.com/slowtec/tokio-modbus/blob/main/examples/rtu-server.rs

impl tokio_modbus::server::Service for Service {
    type Request = SlaveRequest<'static>;
    type Future = future::Ready<Result<Response, Exception>>;

    fn call(&self, req: Self::Request) -> Self::Future {
        match req.request {
            Request::ReadInputRegisters(_addr, cnt) => {
                let mut registers = vec![0; cnt.into()];
                registers[2] = 0x77;
                future::ready(Ok(Response::ReadInputRegisters(registers)))
            }
            Request::ReadHoldingRegisters(_, _) => {
                future::ready(Err(Exception::IllegalDataAddress))
            }
            _ => unimplemented!(),
        }
    }
}

It doesn't seem to get the full byte message in this example

@uklotzde
Copy link
Member

Is this a question or is this a bug report? Please provide a working, reproducible example.

@byte-voyager
Copy link
Author

Is this a question or is this a bug report? Please provide a working, reproducible example.

Hi, want to use for logging full messages to the database

@flosse flosse added the rtu label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants