#ifndef OF_SERIAL_H
#define OF_SERIAL_H


#include "ofConstants.h"


// this serial code contains small portions of the following code-examples:
// ---------------------------------------------------
// http://todbot.com/arduino/host/arduino-serial/arduino-serial.c
// web.mac.com/miked13/iWeb/Arduino/Serial%20Write_files/main.cpp
// www.racer.nl/docs/libraries/qlib/qserial.htm
// ---------------------------------------------------

// notes:
// ----------------------------
// when callign ofSerialSetup("....") you need to pass in
// the name of the com port the device is attached to
// for example, on a mac, it might look like:
//
// 		ofSerialSetup("/dev/tty.usbserial-3B1", 9600)
//
// and on a pc, it might look like:
//
// 		ofSerialSetup("COM4", 9600)
//
// if you are using an arduino board, for example,
// you should check what ports you device is on in the
// arduino program

// to do:
// ----------------------------
// a) 	support multiple serial connections/ports
// 		(currently supports only one)
// b) 	support blocking / non-blocking
// c) 	support numChars available type functions


// ----------------------------
// (also useful, might be this serial example - worth checking out:
// http://web.mit.edu/kvogt/Public/osrc/src/
// if has evolved ways of dealing with blocking
// and non-blocking instances)
// ----------------------------




#if TARGET_OS_MAC
	#include <termios.h>
	#include <sys/ioctl.h>
	#include <getopt.h>
#else
	#include <Winbase.h>
	#include <tchar.h>
#endif


#include <stdio.h>    /* Standard input/output definitions */
#include <stdlib.h>
#include <string.h>   /* String function definitions */
#include <fcntl.h>    /* File control definitions */
#include <errno.h>    /* Error number definitions */
#include <ctype.h>


void ofSerialSetup (char * portName, int baud);
int ofSerialWrite (char * str);
int ofSerialRead (char * buffer, int length);


#endif
