• 10260阅读
  • 9回复

【提问】qtextserialport使用出错 [复制链接]

上一主题 下一主题
离线hrlixiang
 
只看楼主 倒序阅读 楼主  发表于: 2006-01-10
我的文件里   #include "win_qextserialport.h"
make编译时出错:
    qextserialbase.h:174: error: 'Offset' does not name a type
    ....

请问这是为什么,我刚接触qt, 多谢指点。
[ 此贴被XChinux在2006-01-11 01:18重新编辑 ]
离线hrlixiang
只看该作者 1楼 发表于: 2006-01-11
高手帮忙啊。
离线hrlixiang
只看该作者 2楼 发表于: 2006-01-12
我 用的是qextserialport0.9.0, 在windows下编译的
离线hrlixiang
只看该作者 3楼 发表于: 2006-01-13
这的人气这么不旺,失望。。。
离线XChinux

只看该作者 4楼 发表于: 2006-01-13
下面是引用hrlixiang于2006-01-10 16:27发表的【提问】qtextserialport使用出错:
我的文件里   #include "win_qextserialport.h"
make编译时出错:
    qextserialbase.h:174: error: 'Offset' does not name a type
    ....
.......


Offset不是一个类型,这是你使用方法的问题。
把你源代码贴出来看看。
这不能怪别人不替你解答问题,是你帖子的信息量不足,无法为你解答,还得靠你自己去解决。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线alexzhao
只看该作者 5楼 发表于: 2006-01-13
我用的没有问题用的是posix的
离线hrlixiang
只看该作者 6楼 发表于: 2006-01-16
多谢回复, 我是在windows下用,是下载的qtextserialport,没有改动,
在include 它后,编译出的问题。

下面是qextserialbase.h:

#ifndef _QEXTSERIALBASE_H_
#define _QEXTSERIALBASE_H_

#include <qobject.h>
#include <qiodevice.h>
#include <qfile.h>

#ifdef QT_THREAD_SUPPORT
#include <qthread.h>
#endif

/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
#ifdef _TTY_NOWARN_
#define _TTY_NOWARN_PORT_
#endif

/*QT3 changed some return types in QIODevice - these typedefs will retain compatibility with
earlier versions*/
#ifdef QTVER_PRE_30
typedef uint Offset;
typedef int Q_LONG;
#else

/*Some compilers (VC++) don't inherit this typedef from QIODevice.h - copied here*/
#ifdef _MSC_VER
#ifdef QT_LARGE_FILE_SUPPORT
  typedef off_t Offset;
#else
  typedef Q_ULONG Offset;
#endif //_MSC_VER
#endif //QT_LARGE_FILE_SUPPORT
#endif //QTVER_PRE_30

/*macros for thread support*/
#ifdef QT_THREAD_SUPPORT
#define LOCK_MUTEX() mutex->lock()
#define UNLOCK_MUTEX() mutex->unlock()
#else
#define LOCK_MUTEX()
#define UNLOCK_MUTEX()
#endif

/*macros for warning messages*/
#ifdef _TTY_NOWARN_PORT_
#define TTY_PORTABILITY_WARNING(s)
#else
#define TTY_PORTABILITY_WARNING(s) qWarning(s)
#endif
#ifdef _TTY_NOWARN_
#define TTY_WARNING(s)
#else
#define TTY_WARNING(s) qWarning(s)
#endif


/*simple MIN macro - evaluates to the smaller of the 2 members*/
#define MIN(a,b) (((a)<(b))?(a):(b))

/*limit of length of port name, not including NULL terminator*/
#define PORT_NAME_SIZE_LIMIT 80

/*line status constants*/
#define LS_CTS 0x01
#define LS_DSR 0x02
#define LS_DCD 0x04
#define LS_RI   0x08
#define LS_RTS 0x10
#define LS_DTR 0x20
#define LS_ST   0x40
#define LS_SR   0x80

/*error constants*/
#define E_NO_ERROR             0
#define E_INVALID_FD           1
#define E_NO_MEMORY             2
#define E_CAUGHT_NON_BLOCKED_SIGNAL 3
#define E_PORT_TIMEOUT           4
#define E_INVALID_DEVICE         5
#define E_BREAK_CONDITION         6
#define E_FRAMING_ERROR         7
#define E_IO_ERROR             8
#define E_BUFFER_OVERRUN         9
#define E_RECEIVE_OVERFLOW       10
#define E_RECEIVE_PARITY_ERROR     11
#define E_TRANSMIT_OVERFLOW       12
#define E_READ_FAILED           13
#define E_WRITE_FAILED         14

/*enums for port settings*/
typedef enum _NamingConvention {
  WIN_NAMES,
  IRIX_NAMES,
  HPUX_NAMES,
  SUN_NAMES,
  LINUX_NAMES,
  DIGITAL_NAMES
} NamingConvention;

typedef enum _FlowType {
  FLOW_OFF,
  FLOW_HARDWARE,
  FLOW_XONXOFF
} FlowType;

typedef enum _ParityType {
  PAR_NONE,
  PAR_ODD,
  PAR_EVEN,
  PAR_MARK,           //WINDOWS ONLY
  PAR_SPACE
} ParityType;

typedef enum _DataBitsType {
  DATA_5,
  DATA_6,
  DATA_7,
  DATA_8
} DataBitsType;

typedef enum _StopBitsType {
  STOP_1,
  STOP_1_5,           //WINDOWS ONLY
  STOP_2
} StopBitsType;

typedef enum _BaudRateType {
  BAUD50,           //POSIX ONLY
  BAUD75,           //POSIX ONLY
  BAUD110,
  BAUD134,           //POSIX ONLY
  BAUD150,           //POSIX ONLY
  BAUD200,           //POSIX ONLY
  BAUD300,
  BAUD600,
  BAUD1200,
  BAUD1800,         //POSIX ONLY
  BAUD2400,
  BAUD4800,
  BAUD9600,
  BAUD14400,         //WINDOWS ONLY
  BAUD19200,
  BAUD38400,
  BAUD56000,         //WINDOWS ONLY
  BAUD57600,
  BAUD76800,         //POSIX ONLY
  BAUD115200,
  BAUD128000,         //WINDOWS ONLY
  BAUD256000         //WINDOWS ONLY
} BaudRateType;

/*structure to contain port settings*/
typedef struct _PortSettings {
  FlowType FlowControl;
  ParityType Parity;
  DataBitsType DataBits;
  StopBitsType StopBits;
  BaudRateType BaudRate;
  unsigned long Timeout_Sec;
  unsigned long Timeout_Millisec;
} PortSettings;

class QextSerialBase:public QIODevice {
public:
  QextSerialBase();
  QextSerialBase(const char* name);
  virtual ~QextSerialBase();
  virtual void construct(void);
  virtual const char* name() const;
  virtual void setName(const char* name);
  virtual bool open(int mode=0)=0;
  virtual bool open(const char* name);
  virtual void close()=0;
  virtual void flush()=0;
  virtual Offset size() const=0;
  virtual int readLine(char *data, uint maxlen);
  virtual int getch()=0;
  virtual int putch(int)=0;
  virtual int ungetch(int);
  virtual bool atEnd() const;
  virtual void setFlowControl(FlowType)=0;
  virtual FlowType flowControl() const;
  virtual void setParity(ParityType)=0;
  virtual ParityType parity() const;
  virtual void setDataBits(DataBitsType)=0;
  virtual DataBitsType dataBits() const;
  virtual void setStopBits(StopBitsType)=0;
  virtual StopBitsType stopBits() const;
  virtual void setBaudRate(BaudRateType)=0;
  virtual BaudRateType baudRate() const;
  virtual bool isOpen() const;
  virtual unsigned long lastError() const;
  virtual void setDtr(bool set=true)=0;
  virtual void setRts(bool set=true)=0;
  virtual unsigned long lineStatus(void)=0;
  virtual int bytesWaiting()=0;
  virtual void translateError(unsigned long)=0;
  virtual void setTimeout(unsigned long, unsigned long)=0;
  virtual bool isOpen(void);

#ifdef QTVER_PRE_30
  virtual Q_LONG readBlock(char *data, uint maxlen)=0;
  virtual Q_LONG writeBlock(const char *data, uint len)=0;
#else
  virtual Q_LONG readBlock(char *data, unsigned long maxlen)=0;
  virtual Q_LONG writeBlock(const char *data, unsigned long len)=0;
#endif

protected:
  bool portOpen;
  unsigned long lastErr;
  char portName[PORT_NAME_SIZE_LIMIT+1];
  PortSettings Settings;

#ifdef QT_THREAD_SUPPORT
  static unsigned long refCount;
  static QMutex* mutex;
#endif
};

#endif
离线lord_jt
只看该作者 7楼 发表于: 2006-01-16
你是用qt4嗎?
qtextserialport是base on qt3寫的,
.pro要加qt3support
离线hrlixiang
只看该作者 8楼 发表于: 2006-01-16
我用的是4。0。1,不知道该怎么改啊。请指点
离线XChinux

只看该作者 9楼 发表于: 2006-01-16
下面是引用hrlixiang于2006-01-16 13:45发表的:
我用的是4。0。1,不知道该怎么改啊。请指点


和7楼说的一样。
使用Qt3Support
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个