Documentation
FieldTalk Modbus Master Library for .NET
MbusSerialClientBaseopenProtocol Method (String, Int32, Int32, Int32, Int32) |
Opens a serial Modbus protocol and the associated serial port
with the port parameters configured via properties
Namespace: FieldTalk.Modbus.Master
Assembly: FieldTalk.Modbus.Master (in FieldTalk.Modbus.Master.dll) Version: 2.15.2-eval+3d8362b4bb861c05760d48b11d303e954bb8597c
public int openProtocol( string portName, int baudRate, int dataBits, int stopBits, int parity )
Parameters
- portName
- Type: SystemString
Serial port identifier (eg "COM1") - baudRate
- Type: SystemInt32
The port baud rate in bps (1200 - 115200, higher on some platforms) - dataBits
- Type: SystemInt32
SER_DATABITS_7: 7 data bits (ASCII protocol only), SER_DATABITS_8: 8 data bits - stopBits
- Type: SystemInt32
SER_STOPBITS_1: 1 stop bit, SER_STOPBITS_2: 2 stop bits - parity
- Type: SystemInt32
SER_PARITY_NONE: no parity, SER_PARITY_ODD: odd parity, SER_PARITY_EVEN: even parity
Return Value
Type: Int32BusProtocolErrors.FTALK_SUCCESS on success or error code. See BusProtocolErrors for possible error codes.
This function opens the serial port with a specific port settings.
After a port has been opened, data and control functions can be used.
| The Modbus standard requires two stop bits if no parity is chosen. This library is not enforcing this but it is a recommended configuration. |