Compare commits

..

No commits in common. "ebaf64b034aca524339d74054882b2bab4d5f23b" and "87af325c5385180b271415e7c76d206806d56b22" have entirely different histories.

9 changed files with 89 additions and 380 deletions

View File

@ -10,7 +10,6 @@ CONFIG += c++17
SOURCES += \
dialogcalibrate.cpp \
src/sources/framehandler.cpp \
main.cpp \
mainwindow.cpp \
src/sources/crc.cpp \
@ -19,7 +18,6 @@ SOURCES += \
HEADERS += \
dialogcalibrate.h \
src/headers/framehandler.h \
mainwindow.h \
src/headers/CH347DLL.H \
src/headers/crc.h \

View File

@ -1,6 +1,5 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTimer>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
@ -9,7 +8,6 @@ MainWindow::MainWindow(QWidget *parent)
ui->setupUi(this);
drvSPI = new DRV_Spi(this);
drvUart = new DRV_Uart(this);
fHandler = new FrameHandler(this);
}
MainWindow::~MainWindow()
@ -108,7 +106,6 @@ void MainWindow::on_pushButton_5_clicked()
ui->lineEdit->setEnabled(false);
ui->pushButton_5->setEnabled(false);
ui->pushButton_7->setEnabled(true);
ui->btnSpiSaveSetting->setEnabled(false);
onLogPrint("Close device success");
}else{
onLogPrint("Close device failed");
@ -137,17 +134,15 @@ void MainWindow::on_pushButton_2_clicked()
// 判断打开串口设备是否成功
if(status == TRUE){
ui->comboSpiMode->setEnabled(true);
ui->comboSpiClock->setEnabled(true);
ui->comboSpiByteOrder->setEnabled(true);
ui->comboSpiDataBits->setEnabled(true);
ui->comboSpiCS1Pol->setEnabled(true);
ui->comboSpiCS2Pol->setEnabled(true);
ui->comboBox_3->setEnabled(true);
ui->comboBox_4->setEnabled(true);
ui->comboBox_5->setEnabled(true);
ui->comboBox_6->setEnabled(true);
ui->comboBox_16->setEnabled(true);
ui->comboBox_17->setEnabled(true);
ui->pushButton_3->setEnabled(true);
ui->pushButton_2->setEnabled(false);
ui->btnSpiSaveSetting->setEnabled(true);
onLogPrint("Open device success");
on_btnSpiSaveSetting_clicked(); // 初始化SPI参数
}else{
onLogPrint("Open device failed");
}
@ -162,12 +157,12 @@ void MainWindow::on_pushButton_3_clicked()
// 判断打开串口设备是否成功
if(status == TRUE){
ui->comboSpiMode->setEnabled(false);
ui->comboSpiClock->setEnabled(false);
ui->comboSpiByteOrder->setEnabled(false);
ui->comboSpiDataBits->setEnabled(false);
ui->comboSpiCS1Pol->setEnabled(false);
ui->comboSpiCS2Pol->setEnabled(false);
ui->comboBox_3->setEnabled(false);
ui->comboBox_4->setEnabled(false);
ui->comboBox_5->setEnabled(false);
ui->comboBox_6->setEnabled(false);
ui->comboBox_16->setEnabled(false);
ui->comboBox_17->setEnabled(false);
ui->pushButton_3->setEnabled(false);
ui->pushButton_2->setEnabled(true);
@ -177,152 +172,3 @@ void MainWindow::on_pushButton_3_clicked()
}
}
void MainWindow::on_pushButton_9_clicked() {
unsigned char REG[4] = { 0 };
unsigned char ucDAC = ui->comboBox_15->currentText().toUInt(NULL, 10);
unsigned char ucChannel = 0;
QString tmp = ui->lineEdit_2->text();
if (tmp.toInt() < 0 || tmp.toInt() > 256) {
onLogPrint("Wrong channel #");
return;
}
switch (tmp.toUInt()) {
case 256:
ucChannel = 0;
ucDAC = ucDAC | 0x80;
REG[1] = REG[1] | 0x02;
break;
default:
ucChannel = tmp.toUInt();
REG[3] = ucChannel;
break;
}
unsigned char ucFun1 = 0;
//EN_TADC
if (ui->checkBox->isChecked()) {
ucFun1 = ucFun1 | 0x01;
REG[1] = REG[1] | 0x80;
}
//FBK_EN
if (ui->checkBox_2->isChecked()) {
ucFun1 = ucFun1 | 0x02;
REG[1] = REG[1] | 0x01;
}
//TEMPTEST_EN
if (ui->checkBox_4->isChecked()) {
ucFun1 = ucFun1 | 0x04;
REG[2] = REG[2] | 0x80;
qDebug() << REG[2];
}
//TEST_EN
if (ui->checkBox_3->isChecked()) {
ucFun1 = ucFun1 | 0x08;
REG[2] = REG[2] | 0x20;
}
//TRIG_TADC
if (ui->checkBox_5->isChecked()) {
ucFun1 = ucFun1 | 0x10;
REG[2] = REG[2] | 0x40;
}
unsigned char ucFun2 = 0;
ucFun2 = ucFun2 | ui->comboBox_12->currentText().toUInt(NULL, 10); //N_CLKDIV18
ucFun2 = ucFun2 | (ui->comboBox_14->currentText().toUInt(NULL, 2) << 4); //ICON8
REG[1] = REG[1] | (ui->comboBox_12->currentText().toUInt(NULL, 10) << 5);
REG[2] = REG[2] | (ui->comboBox_14->currentText().toUInt(NULL, 2));
QString sendRegData;
for (auto i : REG) {
sendRegData += "0x" + QString::number(i, 16) + " ";
}
onLogPrint("Ready to write REG[1] - REG[4] : " + sendRegData);
QByteArray tmp1 = fHandler->genREGWrite(ucDAC, ucChannel, ucFun1, ucFun2);
switch (ui->comboBox->currentIndex()) {
case 0:
if (drvUart->Uart_Write(tmp1)) {
onLogPrint("Send data success");
} else {
onLogPrint("Send data fail");
}
break;
case 1:
onLogPrint("write data is " + tmp1.toHex());
if (drvSPI->spi_Write(tmp1)) {
onLogPrint("Send data success");
} else {
onLogPrint("Send data failed");
}
break;
}
}
void MainWindow::on_pushButton_10_clicked() {
unsigned char ucDAC = ui->comboBox_15->currentText().toUInt(NULL, 10);
QByteArray tmp = fHandler->genREGRead(ucDAC);
switch (ui->comboBox->currentIndex()) {
case 0:
if (drvUart->Uart_Write(tmp)) {
onLogPrint("Send data success");
} else {
onLogPrint("Send data fail");
}
break;
case 1:
onLogPrint("write data is " + tmp.toHex());
if (drvSPI->spi_Write(tmp)) {
onLogPrint("Send data success");
QTimer::singleShot(1000, [this]() {
QByteArray ba;
drvSPI->spi_Read(ba);
ui->textBrowser->append("SPI read: " + ba.toHex());
});
} else {
onLogPrint("Send data fail");
}
break;
}
}
void MainWindow::on_btnSpiSaveSetting_clicked() {
drvSPI->spi_Init(
ui->comboSpiMode->currentIndex(),
ui->comboSpiClock->currentIndex(),
ui->comboSpiByteOrder->currentIndex(),
ui->comboSpiDataBits->currentIndex(),
ui->comboSpiCS1Pol->currentIndex(),
ui->comboSpiCS2Pol->currentIndex()
);
}
void MainWindow::onWriteRegButtonClicked() {
QByteArray tmp = fHandler->genREGWrite(0x01, 0x01, 0x09, 0x81);
ui->textBrowser->append("SPI write: " + tmp.toHex());
drvSPI->spi_Write(tmp);
}
void MainWindow::onReadRegButtonClicked() {
QByteArray tmp = fHandler->genREGRead(0x01);
ui->textBrowser->append("SPI write: " + tmp.toHex());
QTimer::singleShot(2000, [this]() {
QByteArray ba;
drvSPI->spi_Read(ba);
ui->textBrowser->append("SPI read: " + ba.toHex());
});
}
void MainWindow::on_comboBox_currentTextChanged(const QString& text) {
// if (text.toLower() == "spi") {
// connect(ui->pushButton_4, &QPushButton::clicked, this, &MainWindow::onWriteRegButtonClicked);
// connect(ui->pushButton_10, &QPushButton::clicked, this, &MainWindow::onReadRegButtonClicked);
// } else {
// disconnect(ui->pushButton_4, &QPushButton::clicked, this, &MainWindow::onWriteRegButtonClicked);
// disconnect(ui->pushButton_10, &QPushButton::clicked, this, &MainWindow::onReadRegButtonClicked);
// }
}

View File

@ -6,7 +6,7 @@
#include "src/headers/drv_uart.h"
#include "src/headers/drv_spi.h"
#include "QDateTime"
#include "src/headers/framehandler.h"
@ -49,23 +49,11 @@ private slots:
void on_pushButton_3_clicked();
void on_pushButton_9_clicked();
void on_pushButton_10_clicked();
void on_btnSpiSaveSetting_clicked();
void onWriteRegButtonClicked();
void onReadRegButtonClicked();
void on_comboBox_currentTextChanged(const QString& text);
private:
Ui::MainWindow *ui;
DialogCalibrate *dc;
DRV_Uart *drvUart;
DRV_Spi *drvSPI;
FrameHandler *fHandler;
};
#endif // MAINWINDOW_H

View File

@ -90,7 +90,7 @@
<string>Timeout(ms):</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@ -149,7 +149,7 @@
<string>Data Bits</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@ -159,7 +159,7 @@
<string>Stop Bits</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@ -258,7 +258,7 @@
<string>Baud Rate</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -268,7 +268,7 @@
<string>Parity Bits:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -288,7 +288,7 @@
<string>UART Device List</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -311,18 +311,15 @@
<string>SPI Device List</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboSpiByteOrder">
<widget class="QComboBox" name="comboBox_4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>LSB</string>
@ -336,7 +333,7 @@
</widget>
</item>
<item row="2" column="3">
<widget class="QComboBox" name="comboSpiDataBits">
<widget class="QComboBox" name="comboBox_6">
<property name="enabled">
<bool>false</bool>
</property>
@ -358,15 +355,12 @@
<string>SPI Mode:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="5" rowspan="2">
<widget class="QPushButton" name="btnSpiSaveSetting">
<property name="enabled">
<bool>false</bool>
</property>
<widget class="QPushButton" name="pushButton_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@ -389,13 +383,10 @@
</widget>
</item>
<item row="1" column="3">
<widget class="QComboBox" name="comboSpiClock">
<widget class="QComboBox" name="comboBox_5">
<property name="enabled">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>60MHz</string>
@ -444,7 +435,7 @@
<string>Clock:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@ -454,12 +445,12 @@
<string>LSB/MSB</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboSpiMode">
<widget class="QComboBox" name="comboBox_3">
<property name="enabled">
<bool>false</bool>
</property>
@ -491,12 +482,12 @@
<string>DataBits:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="comboSpiCS1Pol">
<widget class="QComboBox" name="comboBox_16">
<property name="enabled">
<bool>false</bool>
</property>
@ -513,7 +504,7 @@
</widget>
</item>
<item row="2" column="4">
<widget class="QComboBox" name="comboSpiCS2Pol">
<widget class="QComboBox" name="comboBox_17">
<property name="enabled">
<bool>false</bool>
</property>
@ -641,10 +632,10 @@
<item row="0" column="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::MinimumExpanding</enum>
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1100,7 +1091,7 @@
<x>0</x>
<y>0</y>
<width>839</width>
<height>33</height>
<height>21</height>
</rect>
</property>
</widget>

View File

@ -57,8 +57,7 @@ public:
bool spi_openDevice(ULONG SpiI2cGpioDevIndex); // 打开设备
bool spi_closeDevice(); // 关闭设备
bool spi_Write(QByteArray &sendData); // SPI写数据
bool spi_Read(QByteArray &revData); // SPI读数据
bool spi_Init(int mode, int clock, int byteOrder, int CS1Pol, int CS2Pol, int dataBits);
BOOL spi_Read(QByteArray &revData); // SPI读数据
/*************变量定义*************/
mDRV_Spi_Infors m_DRV_Spi_Infors; //Spi驱动相关信息
@ -70,6 +69,7 @@ signals:
private:
// 私有成员变量
// double m_currentValues[]; // 当前各通道输出值(假设有多个通道)
// 私有方法
};

View File

@ -1,25 +0,0 @@
#ifndef FRAMEHANDLER_H
#define FRAMEHANDLER_H
#include <QObject>
#include "QByteArray"
#include "qdebug.h"
class FrameHandler : public QObject
{
Q_OBJECT
public:
explicit FrameHandler(QObject *parent = nullptr);
QByteArray genREGWrite(unsigned char ucDAC,unsigned char ucChannel,unsigned char ucFun1,unsigned char ucFun2);
QByteArray genREGRead(unsigned char ucDAC);
QByteArray genCrc16(const QByteArray& data);
QByteArray genSum(const QByteArray& data);
static void genCrc16table(quint16 table[256], quint16 poly);
signals:
private:
unsigned char nFrameCount;
};
#endif // FRAMEHANDLER_H

View File

@ -4,4 +4,39 @@
// void generate_crc16_reverse_table(quint16 *table);
// QByteArray crc16Reverse(const QByteArray& data);
static void generate_crc16_reverse_table(quint16 table[256], quint16 poly = 0x8408)
{
for (int i = 0; i < 256; ++i) {
quint16 crc = static_cast<quint16>(i);
for (int j = 0; j < 8; ++j) {
if (crc & 0x0001)
crc = (crc >> 1) ^ poly;
else
crc >>= 1;
}
table[i] = crc;
}
}
// 计算反射型CRC16-CCITT
QByteArray crc16Reverse(const QByteArray& data)
{
static quint16 table[256];
static bool tableInited = false;
if (!tableInited) {
generate_crc16_reverse_table(table);
tableInited = true;
}
quint16 crc = 0x6363;
for (auto b : data)
crc = (crc >> 8) ^ table[(crc ^ static_cast<quint8>(b)) & 0xFF];
QByteArray result;
// 经过和python程序对比说明CRC16的两个byte位置需调换
// result.append(static_cast<char>((crc >> 8) & 0xFF));
// result.append(static_cast<char>(crc & 0xFF));
result.append(static_cast<char>(crc & 0xFF));
result.append(static_cast<char>((crc >> 8) & 0xFF));
return result;
}

View File

@ -79,6 +79,7 @@ bool DRV_Spi::spi_openDevice(ULONG SpiI2cGpioDevIndex)
// 设置当前打开设备的索引号
this->m_DRV_Spi_Infors.opendDevIndex = SpiI2cGpioDevIndex;
return true;
// CH347InitSpi();
}
//关闭设备
@ -106,67 +107,35 @@ bool DRV_Spi::spi_Write(QByteArray &sendData)
// 获取数据包的长度
ULONG OutLen = sendData.length();
// 将QByteArray转化为UCHAR
UCHAR *OutBuf = reinterpret_cast<unsigned char*>(sendData.data());
const UCHAR *OutBuf = reinterpret_cast<const unsigned char*>(sendData.constData());
BOOL RetVal = FALSE;
// 调用底层串口发送函数发送数据
//RetVal = CH347SPI_Write(this->m_DRV_Spi_Infors.opendDevIndex, SPI_WRITE_CS, OutLen, SPI_WRITE_BLOCK_SIZE, (UCHAR *)OutBuf);
RetVal = CH347SPI_WriteRead(this->m_DRV_Spi_Infors.opendDevIndex, 0x80, sendData.count(), OutBuf);
RetVal = CH347SPI_Write(this->m_DRV_Spi_Infors.opendDevIndex, SPI_WRITE_CS, OutLen, SPI_WRITE_BLOCK_SIZE, (UCHAR *)OutBuf);
// 日志窗口输出调试信息
DbgPrint("Spi_Write %dBytes %s.", OutLen,RetVal?"succ":"failure");
DbgPrint("frame:%d,Spi_Write %dBytes %s.",sendData.at(14), OutLen,RetVal?"succ":"failure");
return RetVal ? true : false;
return RetVal;
}
bool DRV_Spi::spi_Read(QByteArray &revData)
BOOL DRV_Spi::spi_Read(QByteArray &revData)
{
ULONG InLen = 7;
// ULONG OutLen = 0;
// UCHAR InBuf[512] = {0x00};
revData.clear();
revData.append(InLen, 0x00);
ULONG InLen = 512; // 设置读取的长度,读取完后会将该值赋值为真实的长度
ULONG OutLen = 0; // 设置读取的长度,读取完后会将该值赋值为真实的长度
UCHAR InBuf[512] = {0x00};
BOOL RetVal = FALSE;
// 读取串口数据
//RetVal = CH347SPI_Read(this->m_DRV_Spi_Infors.opendDevIndex, SPI_READ_CS, OutLen, &InLen, InBuf);
RetVal = CH347SPI_WriteRead(this->m_DRV_Spi_Infors.opendDevIndex, 0x80, InLen, revData.data());
RetVal = CH347SPI_Read(this->m_DRV_Spi_Infors.opendDevIndex, SPI_READ_CS, OutLen, &InLen, InBuf);
DbgPrint("CH347Spi_Read %dB %s.", InLen, RetVal ? "succ" : "failure");
DbgPrint("CH347Spi_Read %dB %s.",InLen,RetVal?"succ":"failure");
// if(RetVal)
// {
// //将数据存入revData变量中返回给调用的函数
// revData = QByteArray::fromRawData(static_cast<char*>(InBuf), InLen);
// }
return RetVal ? true : false;
}
bool DRV_Spi::spi_Init(int mode, int clock, int byteOrder, int CS1Pol, int CS2Pol, int dataBits) {
mSpiCfgS spiCon;
BOOL rv = FALSE;
rv = CH347SPI_GetCfg(m_DRV_Spi_Infors.opendDevIndex, &spiCon);
DbgPrint("CH347SPI_GetCfg %s.", rv ? "succ" : "failure");
if (rv == FALSE)
return false;
spiCon.iMode = mode;
spiCon.iClock = clock;
spiCon.iByteOrder = byteOrder;
spiCon.iSpiOutDefaultData = 0xFF;
spiCon.iChipSelect = 0x80;
spiCon.CS1Polarity = CS1Pol;
spiCon.CS2Polarity = CS2Pol;
spiCon.iIsAutoDeativeCS = 0;
spiCon.iActiveDelay = 0;
spiCon.iDelayDeactive = 0;
rv = CH347SPI_Init(m_DRV_Spi_Infors.opendDevIndex, &spiCon);
DbgPrint("CH347SPI_Init %s.", rv ? "succ" : "failure");
if (rv == FALSE)
return false;
rv = CH347SPI_SetDataBits(m_DRV_Spi_Infors.opendDevIndex, dataBits);
DbgPrint("CH347SPI_SetDataBits %s.", rv ? "succ" : "failure");
if (rv == FALSE)
return false;
return true;
if(RetVal)
{
//将数据存入revData变量中返回给调用的函数
revData = QByteArray::fromRawData(reinterpret_cast<const char*>(InBuf), InLen);
}
return RetVal;
}

View File

@ -1,93 +0,0 @@
#include "framehandler.h"
FrameHandler::FrameHandler(QObject *parent)
: QObject{parent}
{
nFrameCount=0;
}
void FrameHandler::genCrc16table(quint16 table[256], quint16 poly = 0x8408)
{
for (int i = 0; i < 256; ++i) {
quint16 crc = static_cast<quint16>(i);
for (int j = 0; j < 8; ++j) {
if (crc & 0x0001)
crc = (crc >> 1) ^ poly;
else
crc >>= 1;
}
table[i] = crc;
}
}
// 计算反射型CRC16-CCITT
QByteArray FrameHandler::genCrc16(const QByteArray& data)
{
static quint16 table[256];
static bool tableInited = false;
if (!tableInited) {
FrameHandler::genCrc16table(table);
tableInited = true;
}
quint16 crc = 0x6363;
for (auto b : data)
crc = (crc >> 8) ^ table[(crc ^ static_cast<quint8>(b)) & 0xFF];
QByteArray result;
// 经过和python程序对比说明CRC16的两个byte位置需调换
// result.append(static_cast<char>((crc >> 8) & 0xFF));
// result.append(static_cast<char>(crc & 0xFF));
result.append(static_cast<char>(crc & 0xFF));
result.append(static_cast<char>((crc >> 8) & 0xFF));
return result;
}
QByteArray FrameHandler::genSum(const QByteArray &data)
{
quint8 sum = 0;
for (int i = 0; i < data.length(); ++i) {
sum += static_cast<quint8>(data.at(i)); // 自动处理溢出
}
QByteArray tmp;
tmp.append(sum);
return tmp;
}
QByteArray FrameHandler::genREGWrite(unsigned char ucDAC, unsigned char ucChannel, unsigned char ucFun1, unsigned char ucFun2)
{
QByteArray cmd1(16,0);
cmd1[0]=0x9F;
cmd1[1]=0xE4;
cmd1[2]=0x04;
cmd1[3]=ucDAC;
cmd1[4]=ucChannel;
cmd1[5]=ucFun1;
cmd1[6]=ucFun2;
cmd1[14]=nFrameCount;
QByteArray sumResult = genSum(cmd1);
cmd1[15] = static_cast<char>(sumResult.at(0));
nFrameCount++;
return cmd1;
}
QByteArray FrameHandler::genREGRead(unsigned char ucDAC)
{
QByteArray cmd1(16,0);
cmd1[0]=0x9F;
cmd1[1]=0xE4;
cmd1[2]=0x05;
cmd1[3]=ucDAC;
cmd1[14]=nFrameCount;
QByteArray sumResult = genSum(cmd1);
cmd1[15] = static_cast<char>(sumResult.at(0));
nFrameCount++;
return cmd1;
}