 /*
 * David Muller; Germán Alfaro
 * davehmuller@gmail.com; alfaro.germanevera@gmail.com
 *
 * Thom Maughan: MBARI, tm@mbari.org  from 2/2018
 */

#ifndef PHFETSOS_OPTODE_H_
#define PHFETSOS_OPTODE_H_

#define OPTODE_BAUD     9600


/*
 * optode.c function prototypes:
 */

void optode_init(void);
void optode_open(void);
void optode_close(void);

unsigned char optode_getc(void);
void optode_putc(unsigned char c);
int optode_rxBytesAvail(void);
uint32_t optode_waitRx(uint32_t maxWait_10msTick);

void optode_flushRx(void);
void optode_flushTx(bool bDiscard);
int optode_write(const char *pcBuf, uint32_t ui32Len);

void optode_tx_str(void);
int optode_buf_size(void);
int optode_buf_write(unsigned char inChar);


int optode_stateMachine(int optodeState);
uint32_t optode_qa_test(void);              // for statemachine development and qa procedure
void optode_comm_test(void);                // for 'communicate with instrument' in test menu

void optode_poll(void);
int optode_parseData(void);

// extras - for recording timing for optode simulator (if we ever build one)
void optode_serial_analyzer(void);



struct optodeDriver
{
             int state;
    unsigned int old_tick10ms;      // for timeout
    unsigned int new_tick10ms;
    unsigned int bufIndx;
    //unsigned char buf[OPTODE_BUFFER_SIZE];      // defd in system.h
};


#endif /* SEAPHOX_MFET_OPTODE_H_ */
