/****************************************************************************** |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A |* PARTICULAR PURPOSE. |* |* Copyright 1995-2005 Nero AG. All Rights Reserved. |*----------------------------------------------------------------------------- |* NeroSDK / NeroRobo |* |* PROGRAM: CSerial.h |* |* PURPOSE: Interface for different serial ports ******************************************************************************/ /* Compatibility class for serial port access. * Note that 'serial port' refers to all interfaces like USB, COM, LPT receiving data sequentially * This class is pure virtual. */ #ifndef CSERIAL_H #define CSERIAL_H #include /* The following enum defines different port types supported by Nero. * Do not change the order of these constants as their values may be stored * in configuration profiles */ /* NOTE: currently (Nero 6.6) only serial (COM) port is implemented by Nero. */ typedef enum { PORT_SERIAL = 0, PORT_PARALLEL = 1, PORT_USB = 2, PORT_BRAVO = 3 } SerialPortType; #define CSERIALTIMEOUT_NONE 0 #define CSERIALTIMEOUT_INFINITE -1 class CSerial { public: virtual ~CSerial() {}; /* TRUE: everything ok * FALSE: error */ virtual BOOL OpenPort() = 0; /* Returns number of bytes read/written or -1 in case of an error. * Will return 0 if no bytes could be read until the timeout was reached. * Input: * buffer: buffer being read into/ written from * iBytes: number of bytes to read/write * timeout: maximum time the operation should take in ms */ virtual int ReadData(char *buffer, int iBytes, int timeout = CSERIALTIMEOUT_NONE) = 0; virtual int WriteData(const char *buffer, int iBytes, int timeout=CSERIALTIMEOUT_NONE) = 0; /* Flush buffers. Warning! All characters in the buffer will be lost * forever. However, this is necessary to get the lines into a defined * state before sending e.g. a command */ virtual void FlushInput() = 0; virtual void FlushOutput() = 0; /* TRUE: everything ok * FALSE: error */ virtual BOOL ClosePort() = 0; /* Return type of serial port */ virtual SerialPortType GetPortType() = 0; /* Return the port number of this port on the current system */ virtual int GetPortNum() = 0; /* Create a serial connection of specified type. * The port number starts counting from 1 (e.g. COM1,COM2,... LPT1,LPT2,...) */ static CSerial *CreateInterface(SerialPortType type, int iPortNum, const char *cpPrinterName = NULL); /* Those methods will create specific types of serial connections. * They're invoked by the method above. * Note that in contrast to above method, this method will always return * a new serial port object and not a sharing proxy */ static CSerial *CreateCOMPortInterface(int iPortNum,int iBaudRate); /** Dummy implementation for USB. Much to do!!! Not implemented yet. */ static CSerial *CreateUSBPortInterface(int iPortNum,int iBaudRate); static CSerial *CreateBravoInterface(const char *cpPrinterName); }; #endif // CSERIAL_H