输入 |
类型 |
注释 |
---|---|---|
|
|
|
|
|
输出 |
类型 |
注释 |
---|---|---|
|
|
此功能返回:
|
VAR
MySerialConf: SERIAL_CONF
result: WORD;
END_VAR
(*Get current configuration of serial line 1*)
GetSerialConf(1, ADR(MySerialConf));
(*Change to modbus RTU slave address 9*)
MySerialConf.Protocol := 0; (*Modbus RTU/Machine Expert protocol (in this case CodesysCompliant selects the protocol)*)
MySerialConf.CodesysCompliant := 0; (*Modbus RTU*)
MySerialConf.address := 9; (*Set modbus address to 9*)
(*Reconfigure the serial line 1*)
result := SetSerialConf(1, ADR(MySerialConf));