GXDN: Gurux Developer Network
Send Method (data, type, receiver)
NamespacesGurux.DialUpGXDialUpSend(Object, VariantType, String)
Sends data asynchronously.
No reply from the receiver, whether or not the operation was successful, is expected.
Parameters
data (Object)
Data to send to the device.
type (VariantType)
The type that data is converted to before sending.
receiver (String)
IP address of the receiver (optional).
Remarks
Reply data is received through OnReceived event.
Examples
CopyVBScript
                'Send ASCII (text) string to the device.
dim dataToSend as string
dataToSend = "Test"
GXDialUp1.Send dataToSend, 0, ""

'Send Hex string to the device.
dim dataToSend as string
dataToSend = "0x01 0x02 03 04"
GXDialUp1.Send dataToSend, GX_VT_HEX_STR, ""

'Send byte to the device.
dim dataToSend
dataToSend = "55"
GXDialUp1.Send dataToSend, GX_VT_BYTE, ""

'Send byte array to the device.
dim dataToSend(3)
dataToSend(0) = 0
dataToSend(1) = 1
dataToSend(2) = 2
GXDialUp1.Send dataToSend, 0, ""
Examples
CopyC#
                /// <summary>
/// Send data.
/// </summary>
/// <param name="eventSender"></param>
/// <param name="eventArgs"></param>
private void SendBtn_Click(System.Object eventSender, System.EventArgs eventArgs)
{
    try
    {
        ReceivedText.Text = "";
        Gurux.Common.VariantType SendType;
        object reply;
        reply = null;
        //Is data send as hex or string.
        if (HexCB.Checked)
        {
            SendType = Gurux.Common.VariantType.HexString;
        }
        else
        {
            SendType = Gurux.Common.VariantType.String;
        }
        if (SyncBtn.Checked)
        {
            //Send sync data and wait reply for 1 second.
            if (gxDialUp1.SendSync(SendText.Text, SendType, Receiver.Text, 0, -1, 1000, true, Gurux.Common.VariantType.HexString, out reply))
            {
                ReceivedText.Text = Convert.ToString(reply);
            }
            else
            {
                ReceivedText.Text = "Reply not received.";
            }
        }
        else
        {
            gxDialUp1.Send(SendText.Text, SendType, Receiver.Text);
        }
    }
    catch (Exception Ex)
    {
        //disable timer is exists
        if (IntervalTimer.Enabled)
        {
            IntervalBtn_Click(null, null);
        }
        MessageBox.Show(Ex.Message);
    }
}
CopyVB.NET
                ''' <summary>
''' Send data.
''' </summary>
Private Sub SendBtn_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles SendBtn.Click
    Try
        ReceivedText.Text = ""
        Dim SendType, reply As Object
        reply = Nothing
        'Is data send as hex or string.
        If HexCB.CheckState = 1 Then
            SendType = Gurux.Common.VariantType.HexString
        Else
            SendType = Gurux.Common.VariantType.String
        End If
        If SyncBtn.CheckState Then
            'Send sync data and wait reply for 1 second.
            If GxDialUp1.SendSync(SendText.Text, SendType, Receiver.Text, 0, -1, 1000, True, Gurux.Common.VariantType.HexString, reply) Then
                ReceivedText.Text = reply
            Else
                ReceivedText.Text = "Reply not received."
            End If
        Else
            GxDialUp1.Send(SendText.Text, SendType, Receiver.Text)
        End If
        Exit Sub
    Catch Ex As Exception
        'disable timer is exists
        If IntervalTimer.Enabled Then
            IntervalBtn_Click(IntervalBtn, New System.EventArgs())
        End If
        MessageBox.Show(Ex.Message)
    End Try
End Sub
CopyVBScript
                'Send data
Private Sub SendBtn_Click()
On Error GoTo GXErr
    ReceivedText.Text = ""
    Dim SendType, reply
    'Is data send as hex or string.
    If HexCB.Value = 1 Then
        SendType = GX_VT_HEX_STR
    Else
        SendType = GX_VT_STR
    End If
    If SyncBtn.Value Then
        'Send sync data and wait reply for 1 second.
        If GXDialUp1.SendSync(SendText.Text, SendType, Receiver.Text, 0, -1, 1000, True, GX_VT_HEX_STR, reply) Then
            ReceivedText.Text = reply
        Else
            ReceivedText.Text = "Reply not received."
        End If
    Else
        GXDialUp1.Send SendText.Text, SendType, Receiver.Text
    End If
    Exit Sub
GXErr:
    'disable timer is exists
    If IntervalTimer.Enabled Then
        IntervalBtn_Click
    End If
    MsgBox Err.Description
End Sub
See Also

Assembly: Gurux.DialUp (Module: Gurux.DialUp) Version: 5.0.0.1