#ifndef _SICK_H
#define _SICK_H

#include "serial.h"

#define SICK_PARAMS_LENGTH 34

typedef struct
{
  int serialfd;
  unsigned char params[SICK_PARAMS_LENGTH];

  int resolution; // hundredths of a degree
  int fieldofview; // degrees

} sick_t;

int sick_connect(sick_t *s, char *port);
sick_t *sick_create();
int sick_readTelegram(sick_t *s,unsigned char *buf, int mstimeout);

void sick_displayTelegram(unsigned char *b);
int sick_writeTelegram(sick_t *s, unsigned char cmd, const void *buf, 
		      unsigned int buflen);

int sick_setBaud(sick_t *s, int baud);

int sick_autonegotiateBaud(sick_t *s);

int sick_requestScan(sick_t *s, int *data, int *nsamples);
int sick_requestStatus(sick_t *s);

int sick_doTransaction(sick_t *s, unsigned char addr, 
		       const unsigned char *outbuf, int outbuflen,
		       unsigned char incmd, unsigned char *inbuf);

int sick_doTransactionEx(sick_t *s, unsigned char addr, 
		       const unsigned char *outbuf, int outbuflen,
		       unsigned char incmd, unsigned char *inbuf,
		       int mstimeout);

int sick_continuousEnable(sick_t *s, int enable);
int sick_continuousData(sick_t *s, int *data, int *nsamples);
int sick_scanDataSize(sick_t *s);

int sick_requestType(sick_t *s, char *type, int maxlen);
int sick_switchVariant(sick_t *s, int angle, int resolution);

#endif
