Source: STXcom.h


Annotated List
Files
Globals
Hierarchy
Index
/*=============================================================================

    Copyright (C) 2001 Silicon Tao Technology Systems
    E-mail:  Support 
    Web:     www.silicontao.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
=============================================================================*/

/*=============================================================================
   File Name:					STXcom.h
	Object Name:				STXcom
   Programmer Name:			Roy Souther
   By Command of:				Silicon Tao Technology Systems
   Day Zero:					02102000, Feburary 10, 2000
   Target Platform:			Linux
   Compiler Used:				GNU g++
   Compiler Settings:      N/A
   Linker Settings:        N/A
   Title of program:			
   Discription:				This object is a wrapper for the serial I/O
      							functionality of the Linux OS. It is intended
                           to simplify the use of serial communication
                           libraries. 
=============================================================================*/

#ifndef STXcom_included
#define STXcom_included

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

/*=============================================================================
	Section Name:				Defines
	Program Name:				STXcom.cc
	Programmer Name:			Roy Souther
=============================================================================*/

#ifndef PORT_CUA0
#define PORT_CUA0     0
#define PORT_CUA1     1
#define PORT_CUA2     2
#define PORT_CUA3     3
#define PORT_TTYS0    4
#define PORT_TTYS1    5
#define PORT_TTYS2    6
#define PORT_TTYS3    7
#endif

#ifndef ODD_PARITY
#define NO_PARITY		0
#define EVEN_PARITY	1
#define ODD_PARITY	2
#endif

#ifndef STOP_BITS_1
#define STOP_BITS_1	0
#define STOP_BITS_2  1
#define STOP_BITS_15 2 // 1.5
#endif

#ifndef WORD_LENGTH_7
#define WORD_LENGTH_7 0
#define WORD_LENGTH_8 1
#endif

#ifndef byte
typedef unsigned char byte;
#endif 

// Error codes
#define ST_ERROR_NO_ERROR				0x00
#define ST_ERROR_INVALID_BAUD_RATE	0x01

// The only time I have needed to prototype a class
// STPortDialog needs to know infomation about STXcom but
// does not declair an instant of if. But when STPortDialog 
// but when looks at STXcom it finds STPortDialog *PortDialog
// and at that point does not yet know about it self. All it 
// needs to know here is that it is a pointer to an object to
// be defined later.
class STPortDialog;

/**
 * Provides a easy way to do serial port communication under Linux.
 *
 * @short Simple serial port DTE <--> DCE communication.
 */   
class STXcom:public QObject 
{
   Q_OBJECT
	public:
      /**
       * 
       */   
      QString ReturnString;

      /**
       * 
       */   
	   QString Port;

      /**
       * 
       */   
	   int ParityBit;

      /**
       * 
       */   
	   int StopBits;

      /**
       * 
       */   
	   int BaudRate;

      /**
       * 
       */   
	   int WordLength;

      /**
       * 
       */   
      char RxDataBuffer;

      /**
       * 
       */   
      bool RxDataIsWaiting;

      /**
       * 
       */   
      STPortDialog *PortDialog;

      /**
       * 
       */   
      bool UserChangedStatusFromDialog;

      /**
       * 
       */   
      int DebugLevel;

	   // Public member functions

      /**
       * 
       */   
      bool SetDebugLevel(int NewDebugLevel);

      /**
       * 
       */   
	   char Getc();

      /**
       * 
       */   
      byte Getb();

      /**
       * 
       */   
      QString Gets();

      /**
       * 
       */   
	   int Putc(char TheChar);

      /**
       * 
       */   
	   int Puts(QString &String);

      /**
       * 
       */   
	   int SetBaud(int NewBaudRate);

      /**
       * 
       */   
	   int SetParity(int ParityValue);

      /**
       * 
       */   
	   int SetStopBits(int NumberOfStopBits);

      /**
       * 
       */   
	   int SetWordLength(int SelectedWordLength);

      /**
       * 
       */   
	   bool Activate();

      /**
       * 
       */   
      int Deactivate();

      /**
       * 
       */   
      bool IsDataWaiting();

      /**
       * 
       */   
      int GetBytes(byte *BytesSoragePointer,int ReadSize);

      /**
       * 
       */   
      int PutBytes(byte *BytesSoragePointer,int WriteSize);       

      /**
       * 
       */   
      int GetNumberOfBytesWaiting();

      /**
       * 
       */   
      QString BaudRateAsText();

      /**
       * 
       */   
      QString ParityAsText();

      /**
       * 
       */   
      QString WordLengthAsText();

      /**
       * 
       */   
      QString StopBitsAsText();

      /**
       * 
       */   
      bool IsDialogVisible();

      /**
       * 
       */   
      void PrepareTheDialog();

      /**
       * 
       */   
      void ShowDialog();

      /**
       * 
       */   
      void HideDialog();

      /**
       * 
       */   
      void LoadSettings();

      /**
       * 
       */   
      void SaveSettings();

      /**
       * The constructor of the serial port object. If the PortNumber 
       * string = "from ini" then the settings will be read from the ini 
       * file.
       */   
	   STXcom(QObject *parent, const char *name, QString &PortNumber);
      STXcom(QObject *parent, const char *name, const char *PortNumber);
      
      /**
       *
       */
      bool IsPortActive();       

      /**
       * 
       */   
      void InitSTXcom(QString &PortNumber);

      /**
       *
       */
      void SetTransmitDelay(int MicroSeconds);
      
      /**
       * 
       */   
	   ~STXcom();      
	private:      
      // Private vars
	   bool PortIsActive;
      int LastTime,TimeOutCount,MaxTimeCount;      
      QTime SystemTimer;      
      int FileDevice;
      int TransmitDelay;
      struct termios OldTerminalIOPointer,NewTerminalIOPointer;

	   // Private member functions
      bool TimeIsUp();
      void StartTimeOutTimer(int TimeOutMax); 
   private slots:
      void ChangeConnectionState(bool NewState);
   signals:
      /**
       * 
       */   
      void DataReadWrite(int IndexCounter);   
};

#endif // STXcom_included

Generated by: root on UtopiaPlanitia.Ept on Mon Dec 10 22:55:12 2001, using kdoc 2.0a53.