/****************************************************************************/
/* Copyright 1991 - 2016 MBARI												*/
/****************************************************************************/
/* Summary	: User command definitions for OASIS5 mooring controller		*/
/* Filename : usrcmds.h														*/
/* Author	: Robert Herlien (rah)											*/
/* Project	: OASIS5 Mooring												*/
/* $Revision: 1.0 $															*/
/* Created	: 07/18/2016 rah												*/
/*																			*/
/* 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:													*/
/* 03feb2003 rah - OASIS3 version created from OASIS usrcmds.h				*/
/* 18jul2016 rah - OASIS5 version created from OASIS3 version				*/
/****************************************************************************/

#ifndef INCusrcmdsh
#define INCusrcmdsh		1

#include <mbariTypes.h>
#include <oasis.h>
#include <sem.h>
#include <FreeRTOS.h>				/* FreeRTOS definitions				*/
#include <task.h>					/* FreeRTOS/include task.h			*/

#define NPARMS	4				/* Max number of parms for user function*/

typedef CmdRtn	(*CmdFunc)(ParmMask_t, Parm_t, Parm_t, Parm_t, Parm_t, char *);


typedef struct					/****************************************/
{								/* Structure for function table			*/
	char	*fe_cs;				/* Command string						*/
	char	*fe_info;			/* Information for help screen			*/
	CmdFunc fe_cmd;				/* Pointer to function to impl. command */
	Nat16 fe_parmtype[NPARMS];	/* Parameter types						*/
} FuncEntry;					/****************************************/
								/* Parameter types						*/
#define NOPARM	0				/* No corresponding parameter			*/
#define STRING	1				/* String, until next delimiter			*/
#define ALL		2				/* Parameter is rest command string		*/
#define DEC		3				/* Number, default radix is decimal		*/
#define HEX		4				/* Number, default radix is hexadecimal */
								/****************************************/

typedef enum					/****************************************/
{								/* Protocol to use for telemetry		*/
	TELEM_UUENCODE = 0,			/* Send in UUencode format				*/
	TELEM_ASCII,				/* Send ASCII							*/
	TELEM_BINARY				/* Send binary data						*/
} TelemType;					/****************************************/

#define MAX_RECS		30

typedef struct func_node FuncNode; /* One node in function linked list	*/

struct func_node					/************************************/
{									/* Structure for function table		*/
	FuncNode	*func_next;			/* For linked list					*/
	FuncNode	*func_prev;			/* For linked list					*/
	char		*fn_cs;				/* Command string					*/
	char		*fn_info;			/* Information for help screen		*/
	CmdFunc		fn_cmd;				/* Ptr to function to impl. command */
	Nat16		fn_parmtype[NPARMS]; /* Parameter types					*/
};									/************************************/

#define FN_NULL ((FuncNode *)0)


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

CmdRtn	analog(ParmMask_t pmask, Parm_t stChan, Parm_t nChans);
CmdRtn	quit(Void);
CmdRtn	reset(ParmMask_t pmask, char *s, char *unused1, char *unused2,
			  char *unused3, char *cmdline);
CmdRtn	usr_power(ParmMask_t, Parm_t);
Errno	usrSemWait(SemID sem);
CmdRtn	connect(ParmMask_t, char *, Parm_t, Parm_t, Parm_t, Byte *);
CmdRtn	usr_time(ParmMask_t pmask, char *s);
CmdRtn	tnc_cmd(ParmMask_t, char *, Parm_t, Parm_t, Parm_t, Byte *);
CmdRtn	display(ParmMask_t, Parm_t, Parm_t);
CmdRtn	set(ParmMask_t, Byte *);
CmdRtn	getlog(ParmMask_t pmask, Parm_t, Parm_t);
CmdRtn	getylog(ParmMask_t pmask, Parm_t, Parm_t);
CmdRtn	dump(ParmMask_t, Parm_t, Parm_t);
CmdRtn	checkLog(ParmMask_t pmask, Parm_t blk, Parm_t nblks);
CmdRtn	getdata(ParmMask_t pmask, Parm_t maxRecs);
CmdRtn	getydata(ParmMask_t pmask, Parm_t maxRecs);
CmdRtn	getlognmbrs(Void);
Void	initUsrLog(LogRecNum firstRcd);
CmdRtn	aux(ParmMask_t, char *, Parm_t, Parm_t);
CmdRtn	init(ParmMask_t, char *, Parm_t, Parm_t);
CmdRtn	sync(ParmMask_t, char *, Parm_t, Parm_t);
MBool	getparm(Nat32 *result, Nat32 radix, Byte *buffer);
CmdRtn	drvparms(ParmMask_t, char *, Parm_t, Parm_t, Parm_t, Byte *);
CmdRtn	drvadd(ParmMask_t, char *, char *, Parm_t, Parm_t, Byte *);
CmdRtn	drvdel(ParmMask_t, char *);
CmdRtn	sample(ParmMask_t, char *);
CmdRtn	lsample(ParmMask_t, char *);
CmdRtn	usrKill(ParmMask_t, char *);
CmdRtn	checkStack(Void);
CmdRtn	version(ParmMask_t pmask, char *arg);
CmdRtn	usrWakeBits(ParmMask_t pmask, Parm_t bits);
CmdRtn	usrGetnum(ParmMask_t pmask, Parm_t radix, char *s);
CmdRtn	usrSysLog(ParmMask_t pmask, char *msg);

#ifdef TNC
CmdRtn	radiomsg(ParmMask_t, char *);
#endif

#endif /* INCusrcmdsh */
