#include <windows.h> 
// send command string & wait for response
 
int SendCommand(int Port, int Baud, char *Command, char *Buffer, int BufLen)
// C/C++ RS232 Serial Example 
#include <stdio.h>
#include <string.>
#include "wsc.h"
{int Code;
  // reset (open) port (with 1024 TX & RX buffers)
  Code = SioReset(Port, 1024, 1024);
  // error ? (negative return codes are errors)
  if(Code<0) return Code;
  // set baud rate
  Code = SioBaud(Port, Baud);
  if(Code<0) return Code;
  // send string
  Code = SioPuts(Port, Command, strlen(Command));
  if(Code<0) return Code;
  // wait up to 250 mSec for a response
  if(SioWaitFor(Port, 250)<0) return Code;
  // allow time for entire response (depends on serial device)
  Sleep(1);
  // return data
  return SioGets(Port, Buffer, BufLen);
}
HOME PAGE
MARSHALLSOFT is a trademark of MarshallSoft Computing, Inc.