Serial
Use the MasterChannel::createSerialChannel method to create a channel bound to a serial port. It requires the same serial port configuration parameters as the outstation serial port API.
The master opens the serial port after MasterChannel.enable() is called. If the port can't be opened, or fails later, the master reopens it after a fixed retry delay.
- Rust
- C
- C++
- Java
- C#
let settings = SerialSettings {
baud_rate,
data_bits: data_bits.into(),
stop_bits: stop_bits.into(),
parity: parity.into(),
flow_control: flow_control.into(),
};
let channel = spawn_master_serial(
get_master_channel_config(master_address)?,
port,
settings,
Duration::from_secs(1),
LogListener::create("port"),
);
dnp3_master_channel_t *channel = NULL;
dnp3_param_error_t err = dnp3_master_channel_create_serial(
runtime,
get_master_channel_config(),
port,
dnp3_serial_settings_init(), // 9600 8N1, no flow control
1000, // retry opening the port every second
get_port_state_listener(),
&channel
);
// check error
auto channel = dnp3::MasterChannel::create_serial_channel(
runtime,
get_master_channel_config(),
port,
dnp3::SerialSettings(), // 9600 8N1, no flow control
std::chrono::seconds(1), // retry opening the port every second
create_port_state_listener()
);
MasterChannel channel =
MasterChannel.createSerialChannel(
runtime,
getMasterChannelConfig(),
port,
new SerialSettings(), // 9600 baud, 8 data bits, 1 stop bit, no parity, no flow control
Duration.ofSeconds(1), // try to open the port every second
state -> System.out.println("port state: " + state)
);
var channel = MasterChannel.CreateSerialChannel(
runtime,
GetMasterChannelConfig(),
port,
new SerialSettings(), // 9600 8N1, no flow control
TimeSpan.FromSeconds(1), // try to open the port every second
new LogListener("port")
);