Chapter 13
private void Rs485DriverEnableControl(bool driverDisable)
{
if (driverDisable)
{
myComPort.RtsEnable = false;
}
else
{
myComPort.RtsEnable = true;
}
}
!
The Send_Command routine accepts command parameters, sends a command,
and displays a received response.
Private driverDisable As Boolean
' Uncomment one of these lines to indicate the method of controlling the RS-485
' driver-enable line.
Private softwareDriverEnable As Boolean = False ' software control
'Private softwareDriverEnable As Boolean = True ' hardware control
Private Sub Send_Command(ByVal node As String, ByVal command As String, _
ByVal address As String, ByVal data As String)
Dim dataSent As String
Dim response As String
' Define LF as the NewLine character for serial data.
myComPort.NewLine = System.Convert.ToString((char)10)
If softwareDriverEnable Then
Rs485DriverEnableControl(True)
End If
' Write a command to the serial port.
myComPort.WriteLine(":" + node + command + address + data)