GXTerminal component sends received data through this method.
/// <summary>
/// Show received data.
/// </summary>
/// <param name="sender"></param>
/// <param name="Data"></param>
/// <param name="SenderInfo"></param>
private void gxTerminal1_OnReceived(object sender, byte[] Data, string SenderInfo)
{
try
{
//We receive byte array from GXSerial and this must be changed to chars.
if (HexCB.Checked)
{
ReceivedText.Text += BitConverter.ToString(Data);
}
else
{
//Get received data as string.
ReceivedText.Text += System.Text.Encoding.ASCII.GetString(Data);
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
''' <summary>
''' Show received data.
''' </summary>
Private Sub GxTerminal1_OnReceived(ByVal sender As System.Object, ByVal Data() As System.Byte, ByVal SenderInfo As System.String) Handles GxTerminal1.OnReceived
Try
Dim Value As Byte()
Value = Data
'We receive byte array from GXSerial and this must be changed to chars.
If (HexCB.Checked) Then
ReceivedText.Text += BitConverter.ToString(Value)
Else
'Get received data as string.
ReceivedText.Text += System.Text.Encoding.ASCII.GetString(Value)
End If
Catch Ex As Exception
MessageBox.Show(Ex.Message)
End Try
End Sub
'New data from GXTerminal is received
Private Sub GXTerminal1_OnReceived(ByVal sender As Object, var As Variant, ByVal SenderInfo As String)
On Error GoTo GXErr
'We receive byte array from GXTerminal and this must be changed to chars.
Dim ch As String
Dim a As Long
For a = 0 To UBound(var)
'Convert byte to chr
ch = Chr(var(a))
ReceivedText.Text = ReceivedText.Text + ch
Next
Exit Sub
GXErr:
MsgBox Err.Description
End Sub
Assembly: Gurux.Terminal (Module: Gurux.Terminal) Version: 5.0.0.1