MarshallSoft

Xbase RS232 Serial Example


* Send command to RS232 serial device

Function SendCommand(Port, Baud, Command)
Local Kode
Local Buffer * reset (open) the port
Kode = xSioReset(Port, 1024, 1024)
* error ? (negative return codes are errors)
if Kode < 0
  return Kode
endif
xSioBaud(Port, Baud)
* send string
Kode = xSioPuts(Port, @Command, Len(Command))
if Kode < 0
  return Kode
endif
* wait up to 500 mSec for a response
Kode = xSioWaitFor(Port, 500)
if Kode < 0
  return Kode
endif
* allow time for entire response (depends on serial device)
Kode = xSioSleep(250)
* display response
Buffer = SPACE(256)
Kode = xSioGets(Port, @Buffer, 255)
if Kode > 0
  ? Left(Buffer, Kode)
endif
return Kode

MSC Logo

HOME PAGE
MARSHALLSOFT is a trademark of MarshallSoft Computing, Inc.