Qt中使用

LIB库路径,include 头文件,运行的时候记得吧dll库带上,这基本就完成了。

准备工作:

Qt可以是傻瓜式的安装就行,GE的驱动里面有exe,直接点击安装即可,完了记得到安装路径把“.h”“.liib”和“.dll”文件拷贝出来

接下来在Qt里面做好基本工作

主要就是修改pro文件,在pro中添加头文件路径和lib库路径。

INCLUDEPATH += C:\Users\WorkStation\Desktop\GE5565\GECore\Inc

LIBS += -LC:\Users\WorkStation\Desktop\GE5565\GECore\Lib -lrfm2gdll_stdc_32

在调用文件中include头文件

#include "rfm2g_windows.h"

#include "rfm2g_api.h"

剩下的就是基本的open read write close 了。

//open

void MainWindow::onpushbuttonopen()

{

RFM2G_STATUS result;

QString strpath = "\\\\.\\rfm2g";

strpath += ui->lineEdit_num->text();

QByteArray ba = strpath.toLatin1();

char *device = ba.data();

result = RFM2gOpen( device, &m_Handle);

if(result != RFM2G_SUCCESS)

{

qDebug() << device;

return;

}

m_timer->start(100);

}

//read

void MainWindow::onTimerOut()

{

RFM2G_STATUS result;

char buff[BUFFERSIZE];

result = RFM2gRead(m_Handle,OFFSET,buff,BUFFERSIZE);

QString strtext(buff);

if(strtext != m_strLast)

{

ui->textEdit_read->setText(strtext);

m_strLast = strtext;

}

}

//close

MainWindow::~MainWindow()

{

delete ui;

if(m_Handle)

{

RFM2gClose(&m_Handle);

}

}

最后就是DOME的连接测试了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值