Function SendCommand(ByVal Port As Integer, ByVal Baud As Integer, ByVal Command As String, ByVal Buffer As String, ByVal BufLen As Integer) As Integer
Dim Code As Integer
'reset the port (1024 byte RX buffer & 256 byte TX buffer)
Code = SioReset(ComPort, 1024, 1024)
' error ? (negative return codes are errors)
If Code < 0 Then
SendCommand = Code
Exit Function
End If
' set baud rate
Code = SioBaud(ComPort, Baud)
' send string
Code = SioPuts(Port, Command, Len(Command))
' error ? (negative return codes are errors)
If Code < 0 Then
SendCommand = Code
Exit Function
End If
' wait up to 250 mSec for a response
Code = SioWaitFor(Port, 250)
If Code < 0 Then
SendCommand = Code
Exit Function
End If
' allow time for entire response (depends on serial device)
Code = SioSleep(1)
' return data
SendCommand = SioGets(Port, Buffer, BufLen)
End Sub
HOME PAGE
MARSHALLSOFT is a trademark of MarshallSoft Computing, Inc.