/************************************************************************/
/* Copyright 2009-2012 MBARI						*/
/************************************************************************/
/* Summary  : Definitions for interfacing to libSensorNode		*/
/* Filename : sensorNode.h						*/
/* Author   : Robert Herlien (rah)					*/
/* Project  : xFOCE							*/
/* Revision: 1.0							*/
/* Created  : 04/22/2013						*/
/*									    */
/* MBARI provides this documentation and code "as is", with no warranty,    */
/* express or implied, of its quality or consistency. It is provided without*/
/* support and without obligation on the part of the Monterey Bay Aquarium  */
/* Research Institute to assist in its use, correction, modification, or    */
/* enhancement. This information should not be published or distributed to  */
/* third parties without specific written permission from MBARI.            */
/*									    */
/************************************************************************/
/* Modification History:						*/
/* 22apr2013, rah							*/
/************************************************************************/

#ifndef INCsensorNodeh
#define INCsensorNodeh	1

#include <mbariTypes.h>


/****************************************/
/* Typedefs and definitions		*/
/****************************************/

#define SENSOR_NODES	16		/* Max SensorNodes supported	*/
#define SN_SER_PORTS	3		/* Number ser ports on SensorNode*/
#define SN_PWR_PORTS	4		/* Num pwr ports on SensorNode  */
#define SN_AD_CHANS	8		/* Num A/D channels on SensorNode*/

#ifndef SNLIB
typedef void	*SensorNodeHandle;
typedef void	*RemSerHandle;
#endif


/****************************************/
/* Function Declarations		*/
/****************************************/

/* Library-wide functions	*/
Void		initSensorNodeLib(Void);
Void		snSetDebug(MBool onoff);
SensorNodeHandle openSensorNode(char *dev, int baud, int slaveID);
Errno		closeSensorNode(SensorNodeHandle snh);

/* Remote Serial Functions	*/
RemSerHandle	snOpenSerial(SensorNodeHandle snh, Nat16 port);
Errno		snSerInit(RemSerHandle rsh, int baud, char parity, int stop);
Errno		snCloseSerial(RemSerHandle rsh);

Nat32		snSerRead(RemSerHandle rsh, char *buffer, Nat32 len);
Nat32		snSerWrite(RemSerHandle rsh, const char *buffer, Nat32 len);
Errno		snSerDrain(RemSerHandle rsh, Nat32 tmout);
Errno		snSerIFlush(RemSerHandle rsh);
Errno		snSerOFlush(RemSerHandle rsh);
Int16		snSerRxCount(RemSerHandle rsh);
Errno		snSerBreak(RemSerHandle rsh, Nat16 breakTime);
Errno		snSerSetTxEnbl(RemSerHandle rsh, MBool enbl);

/* Remote Power Functions	*/
Errno		snPower(SensorNodeHandle snh, Nat16 port, MBool onoff);
Int16		snPowerIsOn(SensorNodeHandle snh, Nat16 port);

/* Remote A/D Functions		*/
Errno		snAnalog(SensorNodeHandle snh, Nat16 chan, Nat16 *val);
Errno		snSetAnalogParms(SensorNodeHandle snh, Nat16 chan, Nat16 navg, Nat16 avgMs);
Errno		snGetAnalogParms(SensorNodeHandle snh, Nat16 chan, Nat16 *navg, Nat16 *avgMs);
Errno		snAnalogUse16bit(SensorNodeHandle snh, MBool use16bit);

#endif	/* INCsensorNodeh */
