Forum Discussion

sanjay0288's avatar
sanjay0288
Frequent Contributor
12 years ago

Help needed in writing data to a com port

Hi,

 I am using the following code to write data to  the com port (have an external device which performs certain operation based on the data received)





Sub Test

  Dim Port, i, s



  Set Port = dotNET.System_IO_Ports.SerialPort.zctor_4("COM1", 9600)

  Port.Open



  ' Writing data to the port

  Port.Write "123 " & Chr(13)

  ' Waiting for response

  aqUtils.Delay 1000

  ' Processing response

  If Port.BytesToRead <> 0 Then

    s = Port.ReadExisting

    Log.Message s

  Else

    Log.Warning "No data"

  End If



  Port.Close

End Sub



But when i read the data it is showing as no data. Can you please help me on this