You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the tcp server example, there is no example of execption responses. There is no response such as IllegalFunction or IllegalDataAddress. This can be verified by the example, which always return input registers data, because the data is generated based on the request register count:
fn call(&self, req: Self::Request) -> Self::Future {
match req {
Request::ReadInputRegisters(_addr, cnt) => {
let mut registers = vec![0; cnt.into()];
registers[2] = 77;
future::ready(Ok(Response::ReadInputRegisters(registers)))
}
_ => unimplemented!(),
}
}
}
How can i generate the exeption responses? Actually, this code just work if the registers vector was the same length specified in cnt from the request. If I generated a bigger register vector, something like that:
an error occurs, cause the response implements a for of each register in the vector, which is not the same number of registers requested by the client.
Thanks in advance,
Gustavo
The text was updated successfully, but these errors were encountered:
gustavowd
changed the title
How to generate the exception responses on the server side
How to generate the exception responses on the server side?
Feb 27, 2023
In the tcp server example, there is no example of execption responses. There is no response such as IllegalFunction or IllegalDataAddress. This can be verified by the example, which always return input registers data, because the data is generated based on the request register count:
fn call(&self, req: Self::Request) -> Self::Future {
match req {
Request::ReadInputRegisters(_addr, cnt) => {
let mut registers = vec![0; cnt.into()];
registers[2] = 77;
future::ready(Ok(Response::ReadInputRegisters(registers)))
}
_ => unimplemented!(),
}
}
}
How can i generate the exeption responses? Actually, this code just work if the registers vector was the same length specified in cnt from the request. If I generated a bigger register vector, something like that:
}
an error occurs, cause the response implements a for of each register in the vector, which is not the same number of registers requested by the client.
Thanks in advance,
Gustavo
The text was updated successfully, but these errors were encountered: