#ifndef _MICROINTERFACE_H
#define _MICROINTERFACE_H

#ifdef UNIX
# include "VxStubs.h"
#else
# include <mbari/types.h>
#endif

extern "C" 
{
#ifdef UNIX
#else
# include "vxWorks.h"
# include "msgQLib.h"
# include "semLib.h"
# include "taskLib.h"
# include "lstLib.h"
# include "sio32.h"
# include "sio32Server.h"
# include "sio32Client.h"
# include "microCmd.h"
#endif
};

/*
MicroInterface handles communication between application and
micro.
*/
class MicroInterface
{
  public:
  MicroInterface(const char *name,
		 Nat16 serialChanNo);
  
  ~MicroInterface();
  
  int sendCmd(
	      Void *reply,        // o: buffer to hold reply
	      Int32 replyLen,     // i: bytes in reply buffer
	      Int32 nWords,        // i: command words
	      ...);

  int sendWord(
	       Reg Char* buffer, Word data
	       );

  Word getWord(
	       Void *value, Int32 nWord
	       );

  int getWords(
	       Word *buffer,
	       Int32 nWords, ...);
  
  int readSRQ(
	      Byte *packet,       // o: buffer to hold packet
	      Int16 maxBytes,     // i: bytes in packet buffer
	      Int32 timeout       // i: timeout
	      );
  

  // Send reset command to micro
  int reset();

  Nat16 serialChanNo()
  {
    return _serialChanNo;
  }

  sio32Chan *serialChan()
  {
    return &_sio32Chan;
  }

  const char *chanName()
  {
    return _chanName;
  }
  
  protected:
  Nat16 _serialChanNo;
  sio32Chan _sio32Chan;
  char *_chanName;
};



#endif
