/* com.h
 * Definizioni delle routine della seriale
 */
#ifndef _com_h
#define _com_h

#ifdef __WXMSW__
#include <windows.h>
#endif

#include "printer.h"

#define STDTIMEOUT  25000   /* 25 mS */
#define LONGTIMEOUT 1000000 /* 1 S */

class Com {
#ifdef __WXMSW__
 	HANDLE com;        // handle della seriale

	int comPut (const unsigned char c);
#else
 	int com;        // handle della seriale

	static struct termios saved_attributes;	// Console mode at entry

	static void reset_input_mode (void);	// Reset console mode on ^C
	void set_input_mode (void);
#endif
	void txErr (void);
protected:
	Printer *prt;
public:
	Com (Printer *p);
	void flushInput (void);
	void schPutc (const unsigned char c);
	int schGetc (int timeout);
	void term (void);
	void setupCom (const char *comname);
	void closeCom ();
	int isConnected ();
	void dtrOn ();          // Set pin 4, DTR
	void dtrOff ();         // Clear pin 4, DTR
	void rtsOn ();          // Set pin 7, RTS)
	void rtsOff ();         // Set pin 7, RTS)
	void mysleep (int delay);
};

#endif

