I think you need to open the port before setting the parameters
try this it will loop and print any data received until you press a key.
Uses "COMM"
Uses "CONSOLE"
Dim hcomm As Long
Dim sBuffer As String
Dim nBytes As Long
Dim errnumbr As Long
'---Get Comms file number and assign
hcomm = COMM_FreeFile
'---Open the port
COMM_Open( "COM1", hcomm )
If Err <> 0 Then
PrintL "Open Comms error: " + Err
Else
'---Set up all comms parameters
COMM_Set( hcomm, %COMM_BAUD, 4800 )
COMM_Set( hcomm, %COMM_BYTE, 8 )
COMM_Set( hcomm, %COMM_NULL, FALSE )
COMM_Set( hcomm, %COMM_PARITY, FALSE )
COMM_Set( hcomm, %COMM_PARITYTYPE, 0 )
COMM_Set( hcomm, %COMM_STOP, 0 )
COMM_Set( hcomm, %COMM_RXBUFFER, 64 )
Do
If COMM_Get( hcomm, %COMM_RXQUE ) <> 0 Then ' Get size of incoming data
NBytes = COMM_Get(hComm, %COMM_RXQUE)
COMM_Recv(hComm, NBytes, sBuffer)
Console_WriteLine(sBuffer)
End If
Loop While Console_WaitKey = "" ' Anykey to quit
End If
'closing comm
COMM_Close( hcomm )
Console_WriteLine("end testing")
Sleep (3000)
Bookmarks