Mitsubishi Electric FX3U-ENET-ADP User Manual page 148

Table of Contents

Advertisement

FX
-ENET-ADP User's Manual
3U
'Read D0 to D4 (5 points) with the A-compatible 1E frame command.
TxCommand = "01ff000a4420000000000500"
Buffer = System.Text.Encoding.Default.GetBytes(TxCommand.ToCharArray)
'Sending a read command
Client.GetStream().Write(Buffer, 0, Buffer.Length)
'Waiting for a response from an Ethernet adapter
While Not Client.GetStream().DataAvailable()
Application.DoEvents()
End While
If Client.GetStream().DataAvailable() Then
Client.GetStream().Read(InBuff, 0, InBuff.Length)
RxResponse = System.Text.Encoding.Default.GetString(InBuff)
SubHeader = Mid$(RxResponse, 3, 2)
If SubHeader = "00" Then 'Normal response
ElseIf SubHeader = "5B" Then ' In an abnormal response, an abnormal code is added.
Else
End If
lstOutput.SelectedIndex = lstOutput.Items.Count - 1
End If
' Line disconnection processing
Client.GetStream().Close()
Client.Close()
End Sub
End Class
142
Temp = "" 'Initialization of an output character string
For j = 0 To 4
DregStr$ = Mid(RxResponse, j * 4 + 5, 4)
Dreg(j) = Val("&H" + DregStr$)
Temp = Temp + Format(Dreg(j), "#####0") + " "
Next
lstOutput.Items.Insert(lstOutput.Items.Count, Temp)
Temp = "Terminate Code = " & SubHeader & " Error Code = " & Mid$(RxResponse, 5, 2)
lstOutput.Items.Insert(lstOutput.Items.Count, Temp)
Temp = "Terminate Code = " & SubHeader
lstOutput.Items.Insert(lstOutput.Items.Count, Temp)
Appendix C-2 Program example for communication using MC protocol -2
Appendix C: Program Examples

Advertisement

Table of Contents
loading

Table of Contents