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.
Unlike the outstation API, the master API opens the serial port API lazily after MasterChannel.enable()
is called. It will try to open the port
if the operation fails.
note
The LinkErrorMode
is internally set to Discard
for serial communication channels.
- Rust
- C
- C++
- Java
- C#
let channel = spawn_master_serial(
get_master_channel_config()?,
"/dev/ttySIM0", // change this for your system
SerialSettings::default(),
Duration::from_secs(1),
NullListener::create(),
);
dnp3_master_channel_t *channel = NULL;
dnp3_param_error_t err = dnp3_master_channel_create_serial(
runtime,
get_master_channel_config(),
"/dev/pts/4",
dnp3_serial_settings_init(),
1000,
get_port_state_listener(),
&channel
);
// check error
dnp3::EndpointList endpoints(std::string("127.0.0.1:20000"));
auto channel = dnp3::MasterChannel::create_serial_channel(
runtime,
get_master_channel_config(),
"/dev/pts/4",
dnp3::SerialSettings(),
std::chrono::seconds(5),
std::make_unique<PortStateListener>()
);
MasterChannel channel =
MasterChannel.createSerialChannel(
runtime,
getMasterChannelConfig(),
"/dev/pts/4", // replace with a real port
new SerialSettings(),
Duration.ofSeconds(5),
new TestPortStateListener());
var channel = MasterChannel.CreateSerialChannel(
runtime,
GetMasterChannelConfig(),
"COM1",
new SerialSettings(),
TimeSpan.FromSeconds(5),
new TestPortStateListener()
);