Serial Port Complete - Latest Microcontroller projects

(lily) #1
An RS-485 Network

If softwareDriverEnable Then

' Read back what was transmitted to ensure that all of the data
' has gone out.
' Then disable the RS-485 driver.
' The RS-485 transceiver's receiver must be permanently enabled
' in hardware.

dataSent = myComPort.ReadLine()
Rs485DriverEnableControl(False)

End If

' Read and decode the response.

response = myComPort.ReadLine()

If response.StartsWith(":") Then
If response.Substring(1, 1) = node Then

Select Case command

Case "1"
' write_byte command

Console.WriteLine _
("write_byte command acknowledged.")

Case "2"
' read_byte command. Display the received data.

Console.WriteLine("readbyte response data: " +
response.Substring(2, 2))
End Select
End If
End If
End Sub

Free download pdf