Compare commits
1 Commits
Release
...
CoreBranch
Author | SHA1 | Date | |
---|---|---|---|
e44648eca2 |
BIN
CetHub.exe
BIN
CetHub.exe
Binary file not shown.
32
CetHub/CetHub.pro
Normal file
32
CetHub/CetHub.pro
Normal file
@ -0,0 +1,32 @@
|
||||
QT += core gui network
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
hubmainwidget.cpp
|
||||
|
||||
HEADERS += \
|
||||
downloadmanager.h \
|
||||
hubmainwidget.h
|
||||
|
||||
FORMS += \
|
||||
hubmainwidget.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
198
CetHub/downloadmanager.h
Normal file
198
CetHub/downloadmanager.h
Normal file
@ -0,0 +1,198 @@
|
||||
#ifndef DOWNLOADMANAGER_H
|
||||
#define DOWNLOADMANAGER_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QFile>
|
||||
#include <QProgressDialog>
|
||||
#include <QPushButton>
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
|
||||
class Downloader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Downloader(QObject *parent = nullptr) : QObject(parent), m_manager(new QNetworkAccessManager(this)) {}
|
||||
|
||||
// void downloadFile(const QUrl &url, const QString &destinationFilePath)
|
||||
// {
|
||||
// m_destinationFilePath = destinationFilePath;
|
||||
|
||||
// QNetworkRequest request(url);
|
||||
|
||||
// // Устанавливаем время ожидания тайм-аута передачи сети
|
||||
// request.setTransferTimeout(5000); // 5000 миллисекунд (5 секунд)
|
||||
// m_reply = m_manager->get(request);
|
||||
|
||||
// connect(m_reply, &QNetworkReply::downloadProgress, this, &Downloader::onDownloadProgress);
|
||||
// connect(m_reply, &QNetworkReply::finished, this, &Downloader::onDownloadFinished);
|
||||
|
||||
// // Обрабатываем ошибки сети
|
||||
// connect(m_reply, &QNetworkReply::error, this, &Downloader::onErrorOccurred);
|
||||
|
||||
//// connect(m_reply, &QNetworkReply::error, this, &Downloader::onDownloadError);//QNetworkReply::errorOccurred(QNetworkReply::NetworkError)
|
||||
|
||||
// //connect(m_reply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error), this, &Downloader::onError);
|
||||
|
||||
// }
|
||||
|
||||
signals:
|
||||
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||
void downloadFinished(bool success);
|
||||
void downloadError(const QString &errorString);
|
||||
|
||||
private slots:
|
||||
void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
{
|
||||
emit downloadProgress(bytesReceived, bytesTotal);
|
||||
}
|
||||
|
||||
void onDownloadFinished()
|
||||
{
|
||||
if (m_reply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
qDebug() << "finish download";
|
||||
// Проверяем статус HTTP ответа
|
||||
if (m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 404)
|
||||
{
|
||||
emit downloadError("File not found.");
|
||||
emit downloadFinished(false);
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(m_destinationFilePath);
|
||||
if (file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
file.write(m_reply->readAll());
|
||||
file.close();
|
||||
emit downloadFinished(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit downloadError("Failed to open destination file for writing.");
|
||||
emit downloadFinished(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "finish download and error";
|
||||
emit downloadError(m_reply->errorString());
|
||||
emit downloadFinished(false);
|
||||
}
|
||||
|
||||
m_reply->deleteLater();
|
||||
}
|
||||
|
||||
void onErrorOccurred(QNetworkReply::NetworkError code)
|
||||
{
|
||||
qDebug() << "Error occurred:" << m_reply->errorString();
|
||||
qDebug() << "Network error occurred:" << code;
|
||||
emit downloadError(m_reply->errorString());
|
||||
emit downloadFinished(false);
|
||||
}
|
||||
|
||||
// void onDownloadError(QNetworkReply::NetworkError code)
|
||||
// {
|
||||
// qDebug() << "Network error occurred:" << code;
|
||||
// emit downloadError(m_reply->errorString());
|
||||
// emit downloadFinished(false);
|
||||
// }
|
||||
private:
|
||||
QNetworkAccessManager *m_manager;
|
||||
QNetworkReply *m_reply;
|
||||
QString m_destinationFilePath;
|
||||
|
||||
public:
|
||||
void downloadFile(const QUrl &url, const QString &destinationFilePath)
|
||||
{
|
||||
m_destinationFilePath = destinationFilePath;
|
||||
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Устанавливаем время ожидания тайм-аута передачи сети
|
||||
//request.setTransferTimeout(5000); // 5000 миллисекунд (5 секунд)
|
||||
m_reply = m_manager->get(request);
|
||||
|
||||
connect(m_reply, &QNetworkReply::downloadProgress, this, &Downloader::onDownloadProgress);
|
||||
connect(m_reply, &QNetworkReply::finished, this, &Downloader::onDownloadFinished);
|
||||
|
||||
// Обрабатываем ошибки сети
|
||||
connect(m_reply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error), this, &Downloader::onErrorOccurred);
|
||||
|
||||
// connect(m_reply, &QNetworkReply::error, this, &Downloader::onDownloadError);//QNetworkReply::errorOccurred(QNetworkReply::NetworkError)
|
||||
|
||||
//connect(m_reply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error), this, &Downloader::onError);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//enum UpdateErrorCode {
|
||||
// UpdateNoError = 0,
|
||||
// DownloadError = 1,
|
||||
// RenameError = 2,
|
||||
// DownloadCancelled = 3
|
||||
//};
|
||||
|
||||
//class DownloadManager : public QObject {
|
||||
// Q_OBJECT
|
||||
//public:
|
||||
// DownloadManager(QObject *parent = nullptr) : QObject(parent) {
|
||||
// connect(&manager, &QNetworkAccessManager::finished, this, &DownloadManager::onDownloadFinished);
|
||||
// }
|
||||
|
||||
// void downloadFile(const QUrl &url, const QString &outputFileName) {
|
||||
// QNetworkRequest request(url);
|
||||
// currentDownload = manager.get(request);
|
||||
// outputFile.setFileName(outputFileName);
|
||||
// if (!outputFile.open(QIODevice::WriteOnly)) {
|
||||
// emit downloadError(DownloadError);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// connect(currentDownload, &QNetworkReply::downloadProgress, this, &DownloadManager::onDownloadProgress);
|
||||
// connect(currentDownload, &QNetworkReply::readyRead, this, [this]() {
|
||||
// outputFile.write(currentDownload->readAll());
|
||||
// });
|
||||
// }
|
||||
|
||||
// void cancelDownload() {
|
||||
// if (currentDownload) {
|
||||
// currentDownload->abort();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//signals:
|
||||
// void downloadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||
// void downloadError(int errorCode);
|
||||
// void downloadFinished();
|
||||
|
||||
//private slots:
|
||||
// void onDownloadFinished(QNetworkReply *reply) {
|
||||
// if (reply->error()) {
|
||||
// emit downloadError(DownloadError);
|
||||
// } else {
|
||||
// outputFile.close();
|
||||
// emit downloadFinished();
|
||||
// }
|
||||
// }
|
||||
|
||||
// void onDownloadProgress(qint64 bytesRead, qint64 totalBytes) {
|
||||
// emit downloadProgress(bytesRead, totalBytes);
|
||||
// }
|
||||
|
||||
//private:
|
||||
// QNetworkAccessManager manager;
|
||||
// QNetworkReply *currentDownload = nullptr;
|
||||
// QFile outputFile;
|
||||
//};
|
||||
|
||||
|
||||
#endif // DOWNLOADMANAGER_H
|
301
CetHub/hubmainwidget.cpp
Normal file
301
CetHub/hubmainwidget.cpp
Normal file
@ -0,0 +1,301 @@
|
||||
#include "hubmainwidget.h"
|
||||
#include "ui_hubmainwidget.h"
|
||||
#include "QtNetwork/QNetworkReply"
|
||||
|
||||
HubMainWidget::HubMainWidget(QWidget *parent, QApplication *app)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::HubMainWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
parentApp = app;
|
||||
connect(&sysTimer, &QTimer::timeout, this, [this]()
|
||||
{
|
||||
ui->dateTimeEdit->setTime(QTime::currentTime());
|
||||
ui->dateTimeEdit->setDate(QDate::currentDate());
|
||||
});
|
||||
sysTimer.start(1000);
|
||||
|
||||
setupTableHeaders();
|
||||
|
||||
getModules();
|
||||
}
|
||||
|
||||
bool HubMainWidget::getModules()
|
||||
{
|
||||
QStringList appDep;
|
||||
appInfo UnionCom;
|
||||
UnionCom.appName = "Терминал CAN, RS, Modbus";
|
||||
UnionCom.fileName = "UnionCom";
|
||||
UnionCom.fileDir = QDir::currentPath() + "/UnionCom/";
|
||||
UnionCom.sourceAdr = "https://git.arktika.cyou/Tenocha/UnionComDLL";
|
||||
UnionCom.downloadAdr = "https://git.arktika.cyou/Tenocha/UnionComDLL/archive/Release.zip";
|
||||
connectModule(UnionCom);
|
||||
|
||||
appInfo M3KTE_TERM;
|
||||
M3KTE_TERM.appName = "МЗКТЕ Терминал";
|
||||
M3KTE_TERM.fileName = "M3KTE_TERM";
|
||||
M3KTE_TERM.fileDir = QDir::currentPath() + "/M3KTE_TERM/";
|
||||
M3KTE_TERM.sourceAdr = "https://git.arktika.cyou/Tenocha/M3KTE_TERM";
|
||||
M3KTE_TERM.downloadAdr = "https://git.arktika.cyou/Tenocha/M3KTE_TERM/releases/download/Pre-release/M3KTETERM.rar";
|
||||
connectModule(M3KTE_TERM);
|
||||
|
||||
appInfo LineRingerLib;
|
||||
LineRingerLib.appName = "Поиск modbus устройств";
|
||||
LineRingerLib.fileName = "LineRinger";
|
||||
LineRingerLib.fileDir = QDir::currentPath() + "/LineRinge/";
|
||||
LineRingerLib.sourceAdr = "https://git.arktika.cyou/Tenocha/LineRingerDLL";
|
||||
LineRingerLib.downloadAdr = "https://git.arktika.cyou/Tenocha/LineRingerDLL/archive/Release.zip";
|
||||
connectModule(LineRingerLib);
|
||||
|
||||
appInfo CanGaroo;
|
||||
CanGaroo.appName = "CanGaroo";
|
||||
CanGaroo.fileName = "cangaroo";
|
||||
CanGaroo.fileDir = QDir::currentPath() + "/CanGaroo/";
|
||||
CanGaroo.sourceAdr = "https://git.arktika.cyou/Tenocha/LineRingerDLL";
|
||||
CanGaroo.downloadAdr = "https://git.arktika.cyou/Tenocha/LineRingerDLL/archive/Release.zip";
|
||||
connectModule(CanGaroo);
|
||||
|
||||
//LogsViewS
|
||||
appInfo LogsViewS;
|
||||
LogsViewS.appName = "LogsViewS";
|
||||
LogsViewS.fileName = "LogsViewS";
|
||||
LogsViewS.fileDir = QDir::currentPath() + "/LogsViewS/";
|
||||
LogsViewS.sourceAdr = "http://git.arktika.cyou/Tenocha/LineRingerDLL";
|
||||
LogsViewS.downloadAdr = "http://git.arktika.cyou/all_public/LogViewNovel/raw/branch/master/LogsView_64/LogsViewS_64.exe";
|
||||
connectModule(LogsViewS);
|
||||
|
||||
ui->appTable->resizeColumnsToContents();
|
||||
setupTableHeaders();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HubMainWidget::setupTableHeaders()
|
||||
{
|
||||
// Устанавливаем заголовки для каждой колонки
|
||||
QStringList headers;
|
||||
headers << "Наличие файла" // колонка 0
|
||||
<< "Название программы" // колонка 1
|
||||
<< "Название файла" // колонка 2
|
||||
<< "Источник"; // колонка 3
|
||||
ui->appTable->setHorizontalHeaderLabels(headers);
|
||||
}
|
||||
|
||||
void HubMainWidget::connectModule(appInfo &info)
|
||||
{
|
||||
// 1. Проверка наличия файла .exe в директории
|
||||
QString dirPath = info.fileDir; // предполагается, что это уже полный путь
|
||||
QString filePath = dirPath + "/" + info.fileName;
|
||||
|
||||
// Проверяем наличие файла с расширением .exe
|
||||
QString exeFilePath = filePath + ".exe";
|
||||
|
||||
info.isFileExists = QFile::exists(exeFilePath);
|
||||
|
||||
// 2. Создаём новую строку таблицы
|
||||
int row = ui->appTable->rowCount();
|
||||
ui->appTable->insertRow(row);
|
||||
|
||||
// 3. Создаём виджеты и заполняем ячейки таблицы
|
||||
|
||||
// 1) Наличие файла (QCheckBox)
|
||||
QCheckBox *fileCheckBox = new QCheckBox();
|
||||
fileCheckBox->setChecked(info.isFileExists);
|
||||
QWidget *fileCellWidget = new QWidget();
|
||||
QHBoxLayout *fileLayout = new QHBoxLayout(fileCellWidget);
|
||||
fileLayout->addWidget(fileCheckBox);
|
||||
fileLayout->setAlignment(Qt::AlignCenter);
|
||||
fileLayout->setContentsMargins(0,0,0,0);
|
||||
fileCellWidget->setLayout(fileLayout);
|
||||
ui->appTable->setCellWidget(row, 0, fileCellWidget);
|
||||
|
||||
// 2) Название программы (QString)
|
||||
QTableWidgetItem *nameItem = new QTableWidgetItem(info.appName);
|
||||
ui->appTable->setItem(row, 1, nameItem);
|
||||
|
||||
// 3) Название файла (QString)
|
||||
QTableWidgetItem *fileNameItem = new QTableWidgetItem(info.fileName);
|
||||
ui->appTable->setItem(row, 2, fileNameItem);
|
||||
|
||||
// 4) Источник файла (QString из sourceAdr)
|
||||
QLabel *sourceLabel = new QLabel();
|
||||
QString linkText = QString("<a href=\"%1\">Source</a>").arg(info.sourceAdr.toString());
|
||||
sourceLabel->setText(linkText);
|
||||
sourceLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
sourceLabel->setOpenExternalLinks(true);
|
||||
|
||||
ui->appTable->setCellWidget(row, 3, sourceLabel);
|
||||
|
||||
// 4. Добавляем структуру в QVector
|
||||
connectedModules.append(info);
|
||||
|
||||
// 5. Добавляем название программы
|
||||
ui->appBox->addItem(info.appName);
|
||||
}
|
||||
|
||||
HubMainWidget::~HubMainWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void HubMainWidget::on_openOrDownloadButton_clicked()
|
||||
{
|
||||
int index = ui->appBox->currentIndex();
|
||||
|
||||
if (index < 0 || index >= connectedModules.size())
|
||||
return; // Защита
|
||||
|
||||
auto &module = connectedModules.at(index);
|
||||
QString filePath = module.fileDir + "/" + module.fileName + ".exe";
|
||||
|
||||
if (QFile::exists(filePath))
|
||||
{
|
||||
// // Файл есть, запускаем
|
||||
QProcess process;
|
||||
process.setWorkingDirectory(module.fileDir);
|
||||
process.setProgram(filePath);
|
||||
process.startDetached();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Получаем путь к директории
|
||||
QDir dir(module.fileDir);
|
||||
|
||||
// Проверяем, существует ли директория
|
||||
if (!dir.exists()) {
|
||||
// Создаём директорию (включая все недостающие промежуточные папки)
|
||||
if (!dir.mkpath(".")) {
|
||||
QMessageBox::warning(this, "Ошибка", "Не удалось создать директорию: " + module.fileDir);
|
||||
return; // Выходим из функции, т.к. сохранить файл невозможно
|
||||
}
|
||||
}
|
||||
|
||||
// Путь для сохранения файла (включая имя файла и расширение)
|
||||
QString saveFilePath = filePath;
|
||||
|
||||
// Создаем объект Downloader
|
||||
Downloader downloader;
|
||||
|
||||
// Создаем диалог прогресса
|
||||
QProgressDialog progressDialog;
|
||||
progressDialog.setWindowTitle("Downloading");
|
||||
progressDialog.setLabelText("Downloading file:\n" + module.downloadAdr.toString() + "...");
|
||||
progressDialog.setCancelButton(new QPushButton("Cancel"));
|
||||
progressDialog.setMinimumDuration(200);
|
||||
|
||||
// Связываем прогресс скачивания с диалогом
|
||||
QObject::connect(&downloader, &Downloader::downloadProgress, [&](qint64 bytesReceived, qint64 bytesTotal) {
|
||||
progressDialog.setMaximum(bytesTotal);
|
||||
progressDialog.setValue(bytesReceived);
|
||||
});
|
||||
|
||||
// Обработка завершения скачивания
|
||||
QObject::connect(&downloader, &Downloader::downloadFinished, [&](bool success) {
|
||||
if (success) {
|
||||
QMessageBox::information(nullptr, "Загрузка завершена", "Файл успешно скачан:\n" + saveFilePath);
|
||||
QWidget *statusWidget = ui->appTable->cellWidget(index, 0);
|
||||
if (statusWidget) {
|
||||
QCheckBox *statusCheckBox = statusWidget->findChild<QCheckBox *>();
|
||||
if (statusCheckBox) {
|
||||
statusCheckBox->setChecked(true); // файл есть
|
||||
}
|
||||
on_appBox_currentIndexChanged(ui->appBox->currentIndex());
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(nullptr, "Ошибка", "Ошибка при скачивании файла");
|
||||
QFile::remove(saveFilePath); // удаляем поврежденный или неполный файл
|
||||
if (dir.exists()) {
|
||||
if (!dir.removeRecursively()) {
|
||||
QMessageBox::warning(this, "Ошибка", "Не удалось удалить созданную директорию: " + module.fileDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
progressDialog.setValue(progressDialog.maximum());
|
||||
progressDialog.close();
|
||||
});
|
||||
|
||||
// Запускаем скачивание
|
||||
qDebug() << "Start download:" << module.downloadAdr.toString() << " to " << saveFilePath;
|
||||
downloader.downloadFile(module.downloadAdr, saveFilePath);
|
||||
|
||||
// Показываем диалог прогресса
|
||||
progressDialog.exec();
|
||||
|
||||
|
||||
// // Файл отсутствует, скачиваем
|
||||
// QUrl downloadUrl(module.downloadAdr);
|
||||
// QNetworkRequest request(downloadUrl);
|
||||
// QNetworkReply *reply = networkManager->get(request);
|
||||
|
||||
// // Ожидаем завершения скачивания
|
||||
// QEventLoop loop;
|
||||
// connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||
// loop.exec();
|
||||
|
||||
// if (reply->error() == QNetworkReply::NoError)
|
||||
// {
|
||||
// QByteArray data = reply->readAll();
|
||||
|
||||
// // Получаем путь к директории
|
||||
// QDir dir(module.fileDir);
|
||||
|
||||
// // Проверяем, существует ли директория
|
||||
// if (!dir.exists()) {
|
||||
// // Создаём директорию (включая все недостающие промежуточные папки)
|
||||
// if (!dir.mkpath(".")) {
|
||||
// QMessageBox::warning(this, "Ошибка", "Не удалось создать директорию: " + module.fileDir);
|
||||
// return; // Выходим из функции, т.к. сохранить файл невозможно
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Записываем файл
|
||||
// QFile file(filePath);
|
||||
// if (file.open(QIODevice::WriteOnly))
|
||||
// {
|
||||
// file.write(data);
|
||||
// file.close();
|
||||
// QMessageBox::information(this, "Загрузка завершена", "Файл успешно скачан.");
|
||||
// // После скачивания можно запустить файл
|
||||
// //QProcess::startDetached(filePath);
|
||||
// // Обновляем статус наличия файла (чекбокс)
|
||||
// QWidget *statusWidget = ui->appTable->cellWidget(index, 0);
|
||||
// if (statusWidget) {
|
||||
// QCheckBox *statusCheckBox = statusWidget->findChild<QCheckBox *>();
|
||||
// if (statusCheckBox) {
|
||||
// statusCheckBox->setChecked(true); // файл есть
|
||||
// }
|
||||
// }
|
||||
// connectedModules[index].isFileExists = true;
|
||||
// on_appBox_currentIndexChanged(ui->appBox->currentIndex());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// QMessageBox::warning(this, "Ошибка", "Не удалось сохранить файл.");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// QMessageBox::warning(this, "Ошибка загрузки", reply->errorString());
|
||||
// }
|
||||
|
||||
// reply->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void HubMainWidget::on_appBox_currentIndexChanged(int index)
|
||||
{
|
||||
if (index < 0 || index >= connectedModules.size())
|
||||
return; // Защита от выхода за границы
|
||||
|
||||
const appInfo &info = connectedModules.at(index);
|
||||
|
||||
if (info.isFileExists)
|
||||
{
|
||||
ui->openOrDownloadButton->setText("Открыть");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->openOrDownloadButton->setText("Скачать");
|
||||
}
|
||||
}
|
70
CetHub/hubmainwidget.h
Normal file
70
CetHub/hubmainwidget.h
Normal file
@ -0,0 +1,70 @@
|
||||
#ifndef HUBMAINWIDGET_H
|
||||
#define HUBMAINWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QCheckBox>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QEventLoop>
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <QUrl>
|
||||
#include <QLabel>
|
||||
|
||||
#include <QProgressDialog>
|
||||
|
||||
#include "windows.h"
|
||||
#include "downloadmanager.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class HubMainWidget; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class HubMainWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HubMainWidget(QWidget *parent = nullptr, QApplication *app = nullptr);
|
||||
~HubMainWidget();
|
||||
|
||||
private slots:
|
||||
void on_openOrDownloadButton_clicked();
|
||||
|
||||
void on_appBox_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
QTimer sysTimer;
|
||||
QApplication *parentApp;
|
||||
QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
|
||||
|
||||
struct appInfo
|
||||
{
|
||||
QString appName = "appName";
|
||||
QString fileName = "fileName";
|
||||
bool isFileExists = false;
|
||||
QString fileDir = "fileDir";
|
||||
QUrl sourceAdr;
|
||||
QUrl downloadAdr;
|
||||
};
|
||||
|
||||
QVector<appInfo>connectedModules;
|
||||
|
||||
bool getModules();
|
||||
void connectModule(appInfo &info);
|
||||
void setupTableHeaders();
|
||||
|
||||
Ui::HubMainWidget *ui;
|
||||
};
|
||||
#endif // HUBMAINWIDGET_H
|
115
CetHub/hubmainwidget.ui
Normal file
115
CetHub/hubmainwidget.ui
Normal file
@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HubMainWidget</class>
|
||||
<widget class="QWidget" name="HubMainWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>399</width>
|
||||
<height>327</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>HubMainWidget</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QComboBox" name="appBox"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="openOrDownloadButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDateTimeEdit" name="dateTimeEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="appTable">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
12
CetHub/main.cpp
Normal file
12
CetHub/main.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "hubmainwidget.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
a.addLibraryPath(QDir::currentPath());
|
||||
HubMainWidget *w = new HubMainWidget(nullptr, &a);
|
||||
w->show();
|
||||
return a.exec();
|
||||
}
|
21
Debug/.qmake.stash
Normal file
21
Debug/.qmake.stash
Normal file
@ -0,0 +1,21 @@
|
||||
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
|
||||
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7
|
||||
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3
|
||||
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
|
||||
QMAKE_CXX.COMPILER_MACROS = \
|
||||
QT_COMPILER_STDCXX \
|
||||
QMAKE_GCC_MAJOR_VERSION \
|
||||
QMAKE_GCC_MINOR_VERSION \
|
||||
QMAKE_GCC_PATCH_VERSION
|
||||
QMAKE_CXX.INCDIRS = \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++ \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/x86_64-w64-mingw32 \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/backward \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/x86_64-w64-mingw32/include
|
||||
QMAKE_CXX.LIBDIRS = \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0 \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/x86_64-w64-mingw32/lib \
|
||||
C:/Qt/Qt5.14.2/Tools/mingw730_64/lib
|
BIN
Debug/debug/CetHub.exe
Normal file
BIN
Debug/debug/CetHub.exe
Normal file
Binary file not shown.
510
Debug/debug/slcan.h
Normal file
510
Debug/debug/slcan.h
Normal file
@ -0,0 +1,510 @@
|
||||
#ifndef __SLCAN_H__
|
||||
#define __SLCAN_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define STDCALL __stdcall
|
||||
#ifdef SLCAN_EXPORT
|
||||
#define SLCANAPI __declspec(dllexport)
|
||||
#else
|
||||
#define SLCANAPI __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#define SLCAN_PROPERTY_INDEX_LINKNAME 0
|
||||
#define SLCAN_PROPERTY_INDEX_INSTANCEID 1
|
||||
|
||||
#define SLCAN_PROPERTY_INDEX_DEVICEDESC 2
|
||||
#define SLCAN_PROPERTY_INDEX_FRIENDLYNAME 3
|
||||
#define SLCAN_PROPERTY_INDEX_PHOBJECTNAME 4
|
||||
#define SLCAN_PROPERTY_INDEX_MFG 5
|
||||
#define SLCAN_PROPERTY_INDEX_LOCATIONINFO 6
|
||||
#define SLCAN_PROPERTY_INDEX_ENUMERATOR 7
|
||||
#define SLCAN_PROPERTY_INDEX_CLASS 8
|
||||
#define SLCAN_PROPERTY_INDEX_CLASSGUID 9
|
||||
#define SLCAN_PROPERTY_INDEX_SERVICE 10
|
||||
#define SLCAN_PROPERTY_INDEX_DRIVER 11
|
||||
#define SLCAN_PROPERTY_INDEX_PORTNAME 12
|
||||
#define SLCAN_PROPERTY_INDEX_PRODUCT 13L
|
||||
#define SLCAN_PROPERTY_INDEX_MANUFACTURER 14L
|
||||
#define SLCAN_PROPERTY_INDEX_CONFIGURATION 15L
|
||||
#define SLCAN_PROPERTY_INDEX_INTERFACE 16L
|
||||
#define SLCAN_PROPERTY_INDEX_SERIAL 17L
|
||||
#define SLCAN_PROPERTY_INDEX_ALIAS 18L
|
||||
#define SLCAN_PROPERTY_INDEX_CHANNELLINK 19L
|
||||
#define SLCAN_PROPERTY_INDEX_SERIALID 20L
|
||||
|
||||
|
||||
#define SLCAN_MODE_CONFIG 0x00
|
||||
#define SLCAN_MODE_NORMAL 0x01
|
||||
#define SLCAN_MODE_LISTENONLY 0x02
|
||||
#define SLCAN_MODE_LOOPBACK 0x03
|
||||
#define SLCAN_MODE_SLEEP 0x04
|
||||
|
||||
#define SLCAN_BR_CIA_1000K 0x8000
|
||||
#define SLCAN_BR_CIA_800K 0x8001
|
||||
#define SLCAN_BR_CIA_500K 0x8002
|
||||
#define SLCAN_BR_CIA_250K 0x8003
|
||||
#define SLCAN_BR_CIA_125K 0x8004
|
||||
#define SLCAN_BR_CIA_50K 0x8005
|
||||
#define SLCAN_BR_CIA_20K 0x8006
|
||||
#define SLCAN_BR_CIA_10K 0x8007
|
||||
#define SLCAN_BR_400K 0x8008
|
||||
#define SLCAN_BR_200K 0x8009
|
||||
#define SLCAN_BR_100K 0x800A
|
||||
#define SLCAN_BR_83333 0x800B
|
||||
#define SLCAN_BR_33333 0x800C
|
||||
#define SLCAN_BR_25K 0x800D
|
||||
#define SLCAN_BR_5K 0x800E
|
||||
#define SLCAN_BR_30K 0x800F
|
||||
#define SLCAN_BR_300K 0x8010
|
||||
#define SLCAN_BR_LASTINDEX SLCAN_BR_300K
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define SLCAN_CAP_MODE_NORMAL 0x01
|
||||
#define SLCAN_CAP_MODE_LISTEN_ONLY 0x02
|
||||
#define SLCAN_CAP_MODE_LOOP_BACK 0x04
|
||||
#define SLCAN_CAP_MODE_SLEEP 0x08
|
||||
|
||||
#define SLCAN_CAP_TXMODE_ONE_SHOT 0x01
|
||||
#define SLCAN_CAP_TXMODE_TIMESTAMP 0x02
|
||||
|
||||
|
||||
#define SLCAN_CAP_CONTR_EXTERNAL 0x00
|
||||
#define SLCAN_CAP_CONTR_MCP2515 0x01
|
||||
#define SLCAN_CAP_CONTR_SJA1000 0x02
|
||||
|
||||
#define SLCAN_CAP_CONTR_INTERNAL 0x80
|
||||
#define SLCAN_CAP_CONTR_LPC 0x81
|
||||
#define SLCAN_CAP_CONTR_STM32 0x82
|
||||
#define SLCAN_CAP_CONTR_STM8 0x83
|
||||
#define SLCAN_CAP_CONTR_PIC 0x84
|
||||
#define SLCAN_CAP_CONTR_PIC_ECAN 0x85
|
||||
|
||||
#define SLCAN_CAP_PHYS_HS 0x01
|
||||
#define SLCAN_CAP_PHYS_LS 0x02
|
||||
#define SLCAN_CAP_PHYS_SW 0x04
|
||||
#define SLCAN_CAP_PHYS_J1708 0x08
|
||||
#define SLCAN_CAP_PHYS_LIN 0x10
|
||||
#define SLCAN_CAP_PHYS_KLINE 0x20
|
||||
|
||||
#define SLCAN_CAP_PHYS_LOAD 0x01
|
||||
|
||||
#define SLCAN_CAP_BITRATE_INDEX 0x01
|
||||
#define SLCAN_CAP_BITRATE_CUSTOM 0x02
|
||||
#define SLCAN_CAP_BITRATE_AUTOMATIC 0x04
|
||||
|
||||
|
||||
#define SLCAN_EVT_LEVEL_RX_MSG 0
|
||||
#define SLCAN_EVT_LEVEL_TIME_STAMP 1
|
||||
#define SLCAN_EVT_LEVEL_TX_MSG 2
|
||||
#define SLCAN_EVT_LEVEL_BUS_STATE 3
|
||||
#define SLCAN_EVT_LEVEL_COUNTS 4
|
||||
#define SLCAN_EVT_LEVEL_ERRORS 5
|
||||
|
||||
#define SLCAN_EVT_TYPE_RX 0x0
|
||||
#define SLCAN_EVT_TYPE_START_TX 0x1
|
||||
#define SLCAN_EVT_TYPE_END_TX 0x2
|
||||
#define SLCAN_EVT_TYPE_ABORT_TX 0x3
|
||||
#define SLCAN_EVT_TYPE_BUS_STATE 0x4
|
||||
#define SLCAN_EVT_TYPE_ERROR_COUNTS 0x5
|
||||
#define SLCAN_EVT_TYPE_BUS_ERROR 0x6
|
||||
#define SLCAN_EVT_TYPE_ARBITRATION_ERROR 0x7
|
||||
#define SLCAN_EVT_STAMP_INC 0xF
|
||||
|
||||
#define SLCAN_BUS_STATE_ERROR_ACTIVE 0x00
|
||||
#define SLCAN_BUS_STATE_ERROR_ACTIVE_WARN 0x01
|
||||
#define SLCAN_BUS_STATE_ERROR_PASSIVE 0x02
|
||||
#define SLCAN_BUS_STATE_BUSOFF 0x03
|
||||
|
||||
#define SLCAN_MES_INFO_EXT 0x01
|
||||
#define SLCAN_MES_INFO_RTR 0x02
|
||||
#define SLCAN_MES_INFO_ONESHOT 0x04
|
||||
|
||||
|
||||
|
||||
#define SLCAN_DEVOP_CREATE 0x00000000
|
||||
#define SLCAN_DEVOP_CREATEHANDLE 0x00000001
|
||||
#define SLCAN_DEVOP_OPEN 0x00000002
|
||||
#define SLCAN_DEVOP_CLOSE 0x00000003
|
||||
#define SLCAN_DEVOP_DESTROYHANDLE 0x00000004
|
||||
#define SLCAN_DEVOP_DESTROY 0x00000005
|
||||
|
||||
|
||||
#define SLCAN_INVALID_HANDLE_ERROR 0xE0001001
|
||||
#define SLCAN_DEVICE_INVALID_HANDLE_ERROR 0xE0001120
|
||||
#define SLCAN_HANDLE_INIT_ERROR 0xE0001017
|
||||
#define SLCAN_DEVICE_NOTOPEN_ERROR 0xE0001121
|
||||
|
||||
#define SLCAN_EVT_ERR_TYPE_BIT 0x00
|
||||
#define SLCAN_EVT_ERR_TYPE_FORM 0x01
|
||||
#define SLCAN_EVT_ERR_TYPE_STUFF 0x02
|
||||
#define SLCAN_EVT_ERR_TYPE_OTHER 0x03
|
||||
|
||||
#define SLCAN_EVT_ERR_DIR_TX 0x00
|
||||
#define SLCAN_EVT_ERR_DIR_RX 0x01
|
||||
|
||||
#define SLCAN_EVT_ERR_FRAME_SOF 0x03
|
||||
#define SLCAN_EVT_ERR_FRAME_ID28_ID21 0x02
|
||||
#define SLCAN_EVT_ERR_FRAME_ID20_ID18 0x06
|
||||
#define SLCAN_EVT_ERR_FRAME_SRTR 0x04
|
||||
#define SLCAN_EVT_ERR_FRAME_IDE 0x05
|
||||
#define SLCAN_EVT_ERR_FRAME_ID17_ID13 0x07
|
||||
#define SLCAN_EVT_ERR_FRAME_ID12_ID5 0x0F
|
||||
#define SLCAN_EVT_ERR_FRAME_ID4_ID0 0x0E
|
||||
#define SLCAN_EVT_ERR_FRAME_RTR 0x0C
|
||||
#define SLCAN_EVT_ERR_FRAME_RSRV0 0x0D
|
||||
#define SLCAN_EVT_ERR_FRAME_RSRV1 0x09
|
||||
#define SLCAN_EVT_ERR_FRAME_DLC 0x0B
|
||||
#define SLCAN_EVT_ERR_FRAME_DATA 0x0A
|
||||
#define SLCAN_EVT_ERR_FRAME_CRC_SEQ 0x08
|
||||
#define SLCAN_EVT_ERR_FRAME_CRC_DEL 0x18
|
||||
#define SLCAN_EVT_ERR_FRAME_ACK_SLOT 0x19
|
||||
#define SLCAN_EVT_ERR_FRAME_ACK_DEL 0x1B
|
||||
#define SLCAN_EVT_ERR_FRAME_EOF 0x1A
|
||||
#define SLCAN_EVT_ERR_FRAME_INTER 0x12
|
||||
#define SLCAN_EVT_ERR_FRAME_AER_FLAG 0x11
|
||||
#define SLCAN_EVT_ERR_FRAME_PER_FLAG 0x16
|
||||
#define SLCAN_EVT_ERR_FRAME_TDB 0x13
|
||||
#define SLCAN_EVT_ERR_FRAME_ERR_DEL 0x17
|
||||
#define SLCAN_EVT_ERR_FRAME_OVER_FLAG 0x1C
|
||||
|
||||
#define SLCAN_TX_STATUS_OK 0x00
|
||||
#define SLCAN_TX_STATUS_TIMEOUT 0x01
|
||||
#define SLCAN_TX_STATUS_BUSOFF 0x02
|
||||
#define SLCAN_TX_STATUS_ABORT 0x03
|
||||
#define SLCAN_TX_STATUS_NOT_ENA 0x04
|
||||
#define SLCAN_TX_STATUS_ERROR_ONE_SHOT 0x05
|
||||
#define SLCAN_TX_STATUS_INVALID_MODE 0x06
|
||||
#define SLCAN_TX_STATUS_UNKNOWN 0x0F
|
||||
|
||||
#define SLCAN_PURGE_TX_ABORT 0x01
|
||||
#define SLCAN_PURGE_RX_ABORT 0x02
|
||||
#define SLCAN_PURGE_TX_CLEAR 0x04
|
||||
#define SLCAN_PURGE_RX_CLEAR 0x08
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
typedef PVOID HSLCAN;
|
||||
|
||||
typedef struct _SLCAN_CAPABILITIES{
|
||||
|
||||
BYTE bModes;
|
||||
BYTE bTXModes;
|
||||
BYTE bMaxEventLevel;
|
||||
BYTE bController;
|
||||
BYTE bPhysical;
|
||||
BYTE bPhysicalLoad;
|
||||
BYTE bBitrates;
|
||||
BYTE bAdvancedModes;
|
||||
DWORD dwCanBaseClk;
|
||||
DWORD dwTimeStampClk;
|
||||
WORD wMaxBRP;
|
||||
}SLCAN_CAPABILITIES,*PSLCAN_CAPABILITIES;
|
||||
|
||||
typedef struct _SLCAN_BITRATE {
|
||||
WORD BRP;
|
||||
BYTE TSEG1;
|
||||
BYTE TSEG2;
|
||||
BYTE SJW;
|
||||
BYTE SAM;
|
||||
}SLCAN_BITRATE,*PSLCAN_BITRATE;
|
||||
|
||||
|
||||
typedef void (STDCALL* SLCAN_DEVICE_CALLBACK)(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex,
|
||||
DWORD dwOperation,
|
||||
PVOID pContext,
|
||||
DWORD dwContextSize
|
||||
);
|
||||
|
||||
typedef VOID (STDCALL* SLCAN_DEVICELIST_CALLBACK)(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex,
|
||||
PVOID pContext,
|
||||
DWORD dwContextSize
|
||||
);
|
||||
|
||||
typedef struct _SLCAN_MESSAGE{
|
||||
BYTE Info;
|
||||
DWORD ID;
|
||||
BYTE DataCount;
|
||||
BYTE Data[8];
|
||||
}SLCAN_MESSAGE,*PSLCAN_MESSAGE;
|
||||
|
||||
typedef struct _SLCAN_TXMESSAGE{
|
||||
LONG dwDelay;
|
||||
SLCAN_MESSAGE Msg;
|
||||
}SLCAN_TXMESSAGE,*PSLCAN_TXMESSAGE;
|
||||
|
||||
typedef struct _SLCAN_EVENT{
|
||||
BYTE EventType;
|
||||
DWORD TimeStampLo;
|
||||
union {
|
||||
SLCAN_MESSAGE Msg;
|
||||
DWORD TimeStamp[2];
|
||||
DWORD64 TimeStamp64;
|
||||
struct {
|
||||
BYTE BusMode;
|
||||
BYTE Dummy1;
|
||||
BYTE ErrCountRx;
|
||||
BYTE ErrCountTx;
|
||||
BYTE ErrType;
|
||||
BYTE ErrDir;
|
||||
BYTE ErrFrame;
|
||||
BYTE LostArbitration;
|
||||
};
|
||||
};
|
||||
}SLCAN_EVENT,*PSLCAN_EVENT;
|
||||
|
||||
typedef struct _SLCAN_STATE{
|
||||
BYTE BusMode;
|
||||
BYTE Dummy1;
|
||||
BYTE ErrCountRX;
|
||||
BYTE ErrCountTX;
|
||||
}SLCAN_STATE,*PSLCAN_STATE;
|
||||
|
||||
typedef union _SLCAN_TIMESTAMP{
|
||||
UINT64 Value;
|
||||
DWORD dwValue[2];
|
||||
USHORT wValue[4];
|
||||
BYTE bValue[8];
|
||||
}SLCAN_TIMESTAMP,*PSLCAN_TIMESTAMP;
|
||||
|
||||
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_Load(
|
||||
SLCAN_DEVICE_CALLBACK DeviceProc,
|
||||
SLCAN_DEVICELIST_CALLBACK DeviceListProc
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_Free(
|
||||
BOOL bDoCallBack
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_Update();
|
||||
|
||||
SLCANAPI HSLCAN STDCALL SlCan_GetDevice(
|
||||
DWORD dwIndex
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_GetDeviceCount();
|
||||
|
||||
|
||||
SLCANAPI HANDLE STDCALL SlCan_DeviceGetHandle(
|
||||
DWORD dwIndex
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetProperty(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex,
|
||||
PCHAR pBuf,
|
||||
DWORD dwSize
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetPropertyW(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex,
|
||||
PWCHAR pBuf,
|
||||
DWORD dwSize
|
||||
);
|
||||
|
||||
SLCANAPI HKEY STDCALL SlCan_DeviceGetRegKey(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex
|
||||
);
|
||||
|
||||
SLCANAPI PVOID STDCALL SlCan_DeviceSetContext(
|
||||
HSLCAN hDevice,
|
||||
PVOID pBuf,
|
||||
DWORD dwBufSize
|
||||
);
|
||||
|
||||
SLCANAPI PVOID STDCALL SlCan_DeviceGetContext(
|
||||
HSLCAN hDevice
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetContextSize(
|
||||
HSLCAN hDevice
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetAlias(
|
||||
HSLCAN hDevice,
|
||||
PCHAR pBuf
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetAliasW(
|
||||
HSLCAN hDevice,
|
||||
PWCHAR pBuf
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetAlias(
|
||||
HSLCAN hDevice,
|
||||
PCHAR pBuf,
|
||||
DWORD dwSize
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetAliasW(
|
||||
HSLCAN hDevice,
|
||||
PWCHAR pBuf,
|
||||
DWORD dwSize
|
||||
);
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetCapabilities(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_CAPABILITIES pCapabilities
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceOpen(
|
||||
HSLCAN hDevice
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceClose(
|
||||
HSLCAN hDevice
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetMode(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwMode
|
||||
);
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetMode(
|
||||
HSLCAN hDevice,
|
||||
PDWORD pdwMode
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetState(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_STATE pState
|
||||
);
|
||||
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetTXTimeOut(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwMillisecond
|
||||
);
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetTXTimeOut(
|
||||
HSLCAN hDevice,
|
||||
PDWORD pdwMillisecond
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetBitRate(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_BITRATE pBitRate
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetBitRate(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_BITRATE pBitRate
|
||||
);
|
||||
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceEnaRec(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetLatency(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetLatency(
|
||||
HSLCAN hDevice,
|
||||
PBYTE pbValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DevicePurge(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetEventLevel(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetEventLevel(
|
||||
HSLCAN hDevice,
|
||||
PBYTE pbValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetStartTimeStamp(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_TIMESTAMP pValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetStartTimeStamp(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_TIMESTAMP pValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetTimeStamp(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_TIMESTAMP pValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetTimeStampPeriod(
|
||||
HSLCAN hDevice,
|
||||
LONG lValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetTimeStampPeriod(
|
||||
HSLCAN hDevice,
|
||||
PLONG plValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetExMode(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetExMode(
|
||||
HSLCAN hDevice,
|
||||
PBYTE pbValue
|
||||
);
|
||||
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceWriteMessages(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_MESSAGE pMsg,
|
||||
DWORD dwCount,
|
||||
PBYTE pbStatus
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceWriteMessagesEx(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_TXMESSAGE pMsg,
|
||||
DWORD dwCount,
|
||||
PBYTE pbStatus,
|
||||
PDWORD pdwCount
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceReadMessages(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwTimeOut,
|
||||
PSLCAN_MESSAGE pMsg,
|
||||
DWORD dwCount,
|
||||
PDWORD pdwCount
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceReadEvents(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwTimeOut,
|
||||
PSLCAN_EVENT pEvent,
|
||||
DWORD dwCount,
|
||||
PDWORD pdwCount
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif //__SLCAN_H
|
BIN
Debug/debug/slcan.lib
Normal file
BIN
Debug/debug/slcan.lib
Normal file
Binary file not shown.
BIN
Qt5Core.dll → Dependencies/Qt5Core.dll
vendored
BIN
Qt5Core.dll → Dependencies/Qt5Core.dll
vendored
Binary file not shown.
BIN
Qt5Gui.dll → Dependencies/Qt5Gui.dll
vendored
BIN
Qt5Gui.dll → Dependencies/Qt5Gui.dll
vendored
Binary file not shown.
BIN
Dependencies/Qt5Network.dll
vendored
Normal file
BIN
Dependencies/Qt5Network.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/Qt5SerialBus.dll
vendored
Normal file
BIN
Dependencies/Qt5SerialBus.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/Qt5SerialPort.dll
vendored
Normal file
BIN
Dependencies/Qt5SerialPort.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/Qt5Svg.dll
vendored
Normal file
BIN
Dependencies/Qt5Svg.dll
vendored
Normal file
Binary file not shown.
BIN
Qt5Widgets.dll → Dependencies/Qt5Widgets.dll
vendored
BIN
Qt5Widgets.dll → Dependencies/Qt5Widgets.dll
vendored
Binary file not shown.
BIN
Dependencies/libgcc_s_seh-1.dll
vendored
Normal file
BIN
Dependencies/libgcc_s_seh-1.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/libstdc++-6.dll
vendored
Normal file
BIN
Dependencies/libstdc++-6.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/libwinpthread-1.dll
vendored
Normal file
BIN
Dependencies/libwinpthread-1.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/imageformats/qgif.dll
vendored
Normal file
BIN
Dependencies/plugins/imageformats/qgif.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/imageformats/qicns.dll
vendored
Normal file
BIN
Dependencies/plugins/imageformats/qicns.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/imageformats/qico.dll
vendored
Normal file
BIN
Dependencies/plugins/imageformats/qico.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/imageformats/qjpeg.dll
vendored
Normal file
BIN
Dependencies/plugins/imageformats/qjpeg.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/imageformats/qsvg.dll
vendored
Normal file
BIN
Dependencies/plugins/imageformats/qsvg.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/imageformats/qtga.dll
vendored
Normal file
BIN
Dependencies/plugins/imageformats/qtga.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/imageformats/qtiff.dll
vendored
Normal file
BIN
Dependencies/plugins/imageformats/qtiff.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/imageformats/qwbmp.dll
vendored
Normal file
BIN
Dependencies/plugins/imageformats/qwbmp.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/imageformats/qwebp.dll
vendored
Normal file
BIN
Dependencies/plugins/imageformats/qwebp.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/platforms/qwindows.dll
vendored
Normal file
BIN
Dependencies/plugins/platforms/qwindows.dll
vendored
Normal file
Binary file not shown.
BIN
Dependencies/plugins/styles/qwindowsvistastyle.dll
vendored
Normal file
BIN
Dependencies/plugins/styles/qwindowsvistastyle.dll
vendored
Normal file
Binary file not shown.
BIN
ExampleDLLs/LineRingerLib32Bit.dll
Normal file
BIN
ExampleDLLs/LineRingerLib32Bit.dll
Normal file
Binary file not shown.
BIN
ExampleDLLs/M3KTE_TERM.dll
Normal file
BIN
ExampleDLLs/M3KTE_TERM.dll
Normal file
Binary file not shown.
BIN
ExampleDLLs/UnionCom.dll
Normal file
BIN
ExampleDLLs/UnionCom.dll
Normal file
Binary file not shown.
BIN
ExampleDLLs/slcan.dll
Normal file
BIN
ExampleDLLs/slcan.dll
Normal file
Binary file not shown.
510
ExampleDLLs/slcan.h
Normal file
510
ExampleDLLs/slcan.h
Normal file
@ -0,0 +1,510 @@
|
||||
#ifndef __SLCAN_H__
|
||||
#define __SLCAN_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define STDCALL __stdcall
|
||||
#ifdef SLCAN_EXPORT
|
||||
#define SLCANAPI __declspec(dllexport)
|
||||
#else
|
||||
#define SLCANAPI __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#define SLCAN_PROPERTY_INDEX_LINKNAME 0
|
||||
#define SLCAN_PROPERTY_INDEX_INSTANCEID 1
|
||||
|
||||
#define SLCAN_PROPERTY_INDEX_DEVICEDESC 2
|
||||
#define SLCAN_PROPERTY_INDEX_FRIENDLYNAME 3
|
||||
#define SLCAN_PROPERTY_INDEX_PHOBJECTNAME 4
|
||||
#define SLCAN_PROPERTY_INDEX_MFG 5
|
||||
#define SLCAN_PROPERTY_INDEX_LOCATIONINFO 6
|
||||
#define SLCAN_PROPERTY_INDEX_ENUMERATOR 7
|
||||
#define SLCAN_PROPERTY_INDEX_CLASS 8
|
||||
#define SLCAN_PROPERTY_INDEX_CLASSGUID 9
|
||||
#define SLCAN_PROPERTY_INDEX_SERVICE 10
|
||||
#define SLCAN_PROPERTY_INDEX_DRIVER 11
|
||||
#define SLCAN_PROPERTY_INDEX_PORTNAME 12
|
||||
#define SLCAN_PROPERTY_INDEX_PRODUCT 13L
|
||||
#define SLCAN_PROPERTY_INDEX_MANUFACTURER 14L
|
||||
#define SLCAN_PROPERTY_INDEX_CONFIGURATION 15L
|
||||
#define SLCAN_PROPERTY_INDEX_INTERFACE 16L
|
||||
#define SLCAN_PROPERTY_INDEX_SERIAL 17L
|
||||
#define SLCAN_PROPERTY_INDEX_ALIAS 18L
|
||||
#define SLCAN_PROPERTY_INDEX_CHANNELLINK 19L
|
||||
#define SLCAN_PROPERTY_INDEX_SERIALID 20L
|
||||
|
||||
|
||||
#define SLCAN_MODE_CONFIG 0x00
|
||||
#define SLCAN_MODE_NORMAL 0x01
|
||||
#define SLCAN_MODE_LISTENONLY 0x02
|
||||
#define SLCAN_MODE_LOOPBACK 0x03
|
||||
#define SLCAN_MODE_SLEEP 0x04
|
||||
|
||||
#define SLCAN_BR_CIA_1000K 0x8000
|
||||
#define SLCAN_BR_CIA_800K 0x8001
|
||||
#define SLCAN_BR_CIA_500K 0x8002
|
||||
#define SLCAN_BR_CIA_250K 0x8003
|
||||
#define SLCAN_BR_CIA_125K 0x8004
|
||||
#define SLCAN_BR_CIA_50K 0x8005
|
||||
#define SLCAN_BR_CIA_20K 0x8006
|
||||
#define SLCAN_BR_CIA_10K 0x8007
|
||||
#define SLCAN_BR_400K 0x8008
|
||||
#define SLCAN_BR_200K 0x8009
|
||||
#define SLCAN_BR_100K 0x800A
|
||||
#define SLCAN_BR_83333 0x800B
|
||||
#define SLCAN_BR_33333 0x800C
|
||||
#define SLCAN_BR_25K 0x800D
|
||||
#define SLCAN_BR_5K 0x800E
|
||||
#define SLCAN_BR_30K 0x800F
|
||||
#define SLCAN_BR_300K 0x8010
|
||||
#define SLCAN_BR_LASTINDEX SLCAN_BR_300K
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define SLCAN_CAP_MODE_NORMAL 0x01
|
||||
#define SLCAN_CAP_MODE_LISTEN_ONLY 0x02
|
||||
#define SLCAN_CAP_MODE_LOOP_BACK 0x04
|
||||
#define SLCAN_CAP_MODE_SLEEP 0x08
|
||||
|
||||
#define SLCAN_CAP_TXMODE_ONE_SHOT 0x01
|
||||
#define SLCAN_CAP_TXMODE_TIMESTAMP 0x02
|
||||
|
||||
|
||||
#define SLCAN_CAP_CONTR_EXTERNAL 0x00
|
||||
#define SLCAN_CAP_CONTR_MCP2515 0x01
|
||||
#define SLCAN_CAP_CONTR_SJA1000 0x02
|
||||
|
||||
#define SLCAN_CAP_CONTR_INTERNAL 0x80
|
||||
#define SLCAN_CAP_CONTR_LPC 0x81
|
||||
#define SLCAN_CAP_CONTR_STM32 0x82
|
||||
#define SLCAN_CAP_CONTR_STM8 0x83
|
||||
#define SLCAN_CAP_CONTR_PIC 0x84
|
||||
#define SLCAN_CAP_CONTR_PIC_ECAN 0x85
|
||||
|
||||
#define SLCAN_CAP_PHYS_HS 0x01
|
||||
#define SLCAN_CAP_PHYS_LS 0x02
|
||||
#define SLCAN_CAP_PHYS_SW 0x04
|
||||
#define SLCAN_CAP_PHYS_J1708 0x08
|
||||
#define SLCAN_CAP_PHYS_LIN 0x10
|
||||
#define SLCAN_CAP_PHYS_KLINE 0x20
|
||||
|
||||
#define SLCAN_CAP_PHYS_LOAD 0x01
|
||||
|
||||
#define SLCAN_CAP_BITRATE_INDEX 0x01
|
||||
#define SLCAN_CAP_BITRATE_CUSTOM 0x02
|
||||
#define SLCAN_CAP_BITRATE_AUTOMATIC 0x04
|
||||
|
||||
|
||||
#define SLCAN_EVT_LEVEL_RX_MSG 0
|
||||
#define SLCAN_EVT_LEVEL_TIME_STAMP 1
|
||||
#define SLCAN_EVT_LEVEL_TX_MSG 2
|
||||
#define SLCAN_EVT_LEVEL_BUS_STATE 3
|
||||
#define SLCAN_EVT_LEVEL_COUNTS 4
|
||||
#define SLCAN_EVT_LEVEL_ERRORS 5
|
||||
|
||||
#define SLCAN_EVT_TYPE_RX 0x0
|
||||
#define SLCAN_EVT_TYPE_START_TX 0x1
|
||||
#define SLCAN_EVT_TYPE_END_TX 0x2
|
||||
#define SLCAN_EVT_TYPE_ABORT_TX 0x3
|
||||
#define SLCAN_EVT_TYPE_BUS_STATE 0x4
|
||||
#define SLCAN_EVT_TYPE_ERROR_COUNTS 0x5
|
||||
#define SLCAN_EVT_TYPE_BUS_ERROR 0x6
|
||||
#define SLCAN_EVT_TYPE_ARBITRATION_ERROR 0x7
|
||||
#define SLCAN_EVT_STAMP_INC 0xF
|
||||
|
||||
#define SLCAN_BUS_STATE_ERROR_ACTIVE 0x00
|
||||
#define SLCAN_BUS_STATE_ERROR_ACTIVE_WARN 0x01
|
||||
#define SLCAN_BUS_STATE_ERROR_PASSIVE 0x02
|
||||
#define SLCAN_BUS_STATE_BUSOFF 0x03
|
||||
|
||||
#define SLCAN_MES_INFO_EXT 0x01
|
||||
#define SLCAN_MES_INFO_RTR 0x02
|
||||
#define SLCAN_MES_INFO_ONESHOT 0x04
|
||||
|
||||
|
||||
|
||||
#define SLCAN_DEVOP_CREATE 0x00000000
|
||||
#define SLCAN_DEVOP_CREATEHANDLE 0x00000001
|
||||
#define SLCAN_DEVOP_OPEN 0x00000002
|
||||
#define SLCAN_DEVOP_CLOSE 0x00000003
|
||||
#define SLCAN_DEVOP_DESTROYHANDLE 0x00000004
|
||||
#define SLCAN_DEVOP_DESTROY 0x00000005
|
||||
|
||||
|
||||
#define SLCAN_INVALID_HANDLE_ERROR 0xE0001001
|
||||
#define SLCAN_DEVICE_INVALID_HANDLE_ERROR 0xE0001120
|
||||
#define SLCAN_HANDLE_INIT_ERROR 0xE0001017
|
||||
#define SLCAN_DEVICE_NOTOPEN_ERROR 0xE0001121
|
||||
|
||||
#define SLCAN_EVT_ERR_TYPE_BIT 0x00
|
||||
#define SLCAN_EVT_ERR_TYPE_FORM 0x01
|
||||
#define SLCAN_EVT_ERR_TYPE_STUFF 0x02
|
||||
#define SLCAN_EVT_ERR_TYPE_OTHER 0x03
|
||||
|
||||
#define SLCAN_EVT_ERR_DIR_TX 0x00
|
||||
#define SLCAN_EVT_ERR_DIR_RX 0x01
|
||||
|
||||
#define SLCAN_EVT_ERR_FRAME_SOF 0x03
|
||||
#define SLCAN_EVT_ERR_FRAME_ID28_ID21 0x02
|
||||
#define SLCAN_EVT_ERR_FRAME_ID20_ID18 0x06
|
||||
#define SLCAN_EVT_ERR_FRAME_SRTR 0x04
|
||||
#define SLCAN_EVT_ERR_FRAME_IDE 0x05
|
||||
#define SLCAN_EVT_ERR_FRAME_ID17_ID13 0x07
|
||||
#define SLCAN_EVT_ERR_FRAME_ID12_ID5 0x0F
|
||||
#define SLCAN_EVT_ERR_FRAME_ID4_ID0 0x0E
|
||||
#define SLCAN_EVT_ERR_FRAME_RTR 0x0C
|
||||
#define SLCAN_EVT_ERR_FRAME_RSRV0 0x0D
|
||||
#define SLCAN_EVT_ERR_FRAME_RSRV1 0x09
|
||||
#define SLCAN_EVT_ERR_FRAME_DLC 0x0B
|
||||
#define SLCAN_EVT_ERR_FRAME_DATA 0x0A
|
||||
#define SLCAN_EVT_ERR_FRAME_CRC_SEQ 0x08
|
||||
#define SLCAN_EVT_ERR_FRAME_CRC_DEL 0x18
|
||||
#define SLCAN_EVT_ERR_FRAME_ACK_SLOT 0x19
|
||||
#define SLCAN_EVT_ERR_FRAME_ACK_DEL 0x1B
|
||||
#define SLCAN_EVT_ERR_FRAME_EOF 0x1A
|
||||
#define SLCAN_EVT_ERR_FRAME_INTER 0x12
|
||||
#define SLCAN_EVT_ERR_FRAME_AER_FLAG 0x11
|
||||
#define SLCAN_EVT_ERR_FRAME_PER_FLAG 0x16
|
||||
#define SLCAN_EVT_ERR_FRAME_TDB 0x13
|
||||
#define SLCAN_EVT_ERR_FRAME_ERR_DEL 0x17
|
||||
#define SLCAN_EVT_ERR_FRAME_OVER_FLAG 0x1C
|
||||
|
||||
#define SLCAN_TX_STATUS_OK 0x00
|
||||
#define SLCAN_TX_STATUS_TIMEOUT 0x01
|
||||
#define SLCAN_TX_STATUS_BUSOFF 0x02
|
||||
#define SLCAN_TX_STATUS_ABORT 0x03
|
||||
#define SLCAN_TX_STATUS_NOT_ENA 0x04
|
||||
#define SLCAN_TX_STATUS_ERROR_ONE_SHOT 0x05
|
||||
#define SLCAN_TX_STATUS_INVALID_MODE 0x06
|
||||
#define SLCAN_TX_STATUS_UNKNOWN 0x0F
|
||||
|
||||
#define SLCAN_PURGE_TX_ABORT 0x01
|
||||
#define SLCAN_PURGE_RX_ABORT 0x02
|
||||
#define SLCAN_PURGE_TX_CLEAR 0x04
|
||||
#define SLCAN_PURGE_RX_CLEAR 0x08
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
typedef PVOID HSLCAN;
|
||||
|
||||
typedef struct _SLCAN_CAPABILITIES{
|
||||
|
||||
BYTE bModes;
|
||||
BYTE bTXModes;
|
||||
BYTE bMaxEventLevel;
|
||||
BYTE bController;
|
||||
BYTE bPhysical;
|
||||
BYTE bPhysicalLoad;
|
||||
BYTE bBitrates;
|
||||
BYTE bAdvancedModes;
|
||||
DWORD dwCanBaseClk;
|
||||
DWORD dwTimeStampClk;
|
||||
WORD wMaxBRP;
|
||||
}SLCAN_CAPABILITIES,*PSLCAN_CAPABILITIES;
|
||||
|
||||
typedef struct _SLCAN_BITRATE {
|
||||
WORD BRP;
|
||||
BYTE TSEG1;
|
||||
BYTE TSEG2;
|
||||
BYTE SJW;
|
||||
BYTE SAM;
|
||||
}SLCAN_BITRATE,*PSLCAN_BITRATE;
|
||||
|
||||
|
||||
typedef void (STDCALL* SLCAN_DEVICE_CALLBACK)(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex,
|
||||
DWORD dwOperation,
|
||||
PVOID pContext,
|
||||
DWORD dwContextSize
|
||||
);
|
||||
|
||||
typedef VOID (STDCALL* SLCAN_DEVICELIST_CALLBACK)(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex,
|
||||
PVOID pContext,
|
||||
DWORD dwContextSize
|
||||
);
|
||||
|
||||
typedef struct _SLCAN_MESSAGE{
|
||||
BYTE Info;
|
||||
DWORD ID;
|
||||
BYTE DataCount;
|
||||
BYTE Data[8];
|
||||
}SLCAN_MESSAGE,*PSLCAN_MESSAGE;
|
||||
|
||||
typedef struct _SLCAN_TXMESSAGE{
|
||||
LONG dwDelay;
|
||||
SLCAN_MESSAGE Msg;
|
||||
}SLCAN_TXMESSAGE,*PSLCAN_TXMESSAGE;
|
||||
|
||||
typedef struct _SLCAN_EVENT{
|
||||
BYTE EventType;
|
||||
DWORD TimeStampLo;
|
||||
union {
|
||||
SLCAN_MESSAGE Msg;
|
||||
DWORD TimeStamp[2];
|
||||
DWORD64 TimeStamp64;
|
||||
struct {
|
||||
BYTE BusMode;
|
||||
BYTE Dummy1;
|
||||
BYTE ErrCountRx;
|
||||
BYTE ErrCountTx;
|
||||
BYTE ErrType;
|
||||
BYTE ErrDir;
|
||||
BYTE ErrFrame;
|
||||
BYTE LostArbitration;
|
||||
};
|
||||
};
|
||||
}SLCAN_EVENT,*PSLCAN_EVENT;
|
||||
|
||||
typedef struct _SLCAN_STATE{
|
||||
BYTE BusMode;
|
||||
BYTE Dummy1;
|
||||
BYTE ErrCountRX;
|
||||
BYTE ErrCountTX;
|
||||
}SLCAN_STATE,*PSLCAN_STATE;
|
||||
|
||||
typedef union _SLCAN_TIMESTAMP{
|
||||
UINT64 Value;
|
||||
DWORD dwValue[2];
|
||||
USHORT wValue[4];
|
||||
BYTE bValue[8];
|
||||
}SLCAN_TIMESTAMP,*PSLCAN_TIMESTAMP;
|
||||
|
||||
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_Load(
|
||||
SLCAN_DEVICE_CALLBACK DeviceProc,
|
||||
SLCAN_DEVICELIST_CALLBACK DeviceListProc
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_Free(
|
||||
BOOL bDoCallBack
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_Update();
|
||||
|
||||
SLCANAPI HSLCAN STDCALL SlCan_GetDevice(
|
||||
DWORD dwIndex
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_GetDeviceCount();
|
||||
|
||||
|
||||
SLCANAPI HANDLE STDCALL SlCan_DeviceGetHandle(
|
||||
DWORD dwIndex
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetProperty(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex,
|
||||
PCHAR pBuf,
|
||||
DWORD dwSize
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetPropertyW(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex,
|
||||
PWCHAR pBuf,
|
||||
DWORD dwSize
|
||||
);
|
||||
|
||||
SLCANAPI HKEY STDCALL SlCan_DeviceGetRegKey(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwIndex
|
||||
);
|
||||
|
||||
SLCANAPI PVOID STDCALL SlCan_DeviceSetContext(
|
||||
HSLCAN hDevice,
|
||||
PVOID pBuf,
|
||||
DWORD dwBufSize
|
||||
);
|
||||
|
||||
SLCANAPI PVOID STDCALL SlCan_DeviceGetContext(
|
||||
HSLCAN hDevice
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetContextSize(
|
||||
HSLCAN hDevice
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetAlias(
|
||||
HSLCAN hDevice,
|
||||
PCHAR pBuf
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetAliasW(
|
||||
HSLCAN hDevice,
|
||||
PWCHAR pBuf
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetAlias(
|
||||
HSLCAN hDevice,
|
||||
PCHAR pBuf,
|
||||
DWORD dwSize
|
||||
);
|
||||
|
||||
SLCANAPI DWORD STDCALL SlCan_DeviceGetAliasW(
|
||||
HSLCAN hDevice,
|
||||
PWCHAR pBuf,
|
||||
DWORD dwSize
|
||||
);
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetCapabilities(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_CAPABILITIES pCapabilities
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceOpen(
|
||||
HSLCAN hDevice
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceClose(
|
||||
HSLCAN hDevice
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetMode(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwMode
|
||||
);
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetMode(
|
||||
HSLCAN hDevice,
|
||||
PDWORD pdwMode
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetState(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_STATE pState
|
||||
);
|
||||
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetTXTimeOut(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwMillisecond
|
||||
);
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetTXTimeOut(
|
||||
HSLCAN hDevice,
|
||||
PDWORD pdwMillisecond
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetBitRate(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_BITRATE pBitRate
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetBitRate(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_BITRATE pBitRate
|
||||
);
|
||||
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceEnaRec(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetLatency(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetLatency(
|
||||
HSLCAN hDevice,
|
||||
PBYTE pbValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DevicePurge(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetEventLevel(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetEventLevel(
|
||||
HSLCAN hDevice,
|
||||
PBYTE pbValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetStartTimeStamp(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_TIMESTAMP pValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetStartTimeStamp(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_TIMESTAMP pValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetTimeStamp(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_TIMESTAMP pValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetTimeStampPeriod(
|
||||
HSLCAN hDevice,
|
||||
LONG lValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetTimeStampPeriod(
|
||||
HSLCAN hDevice,
|
||||
PLONG plValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceSetExMode(
|
||||
HSLCAN hDevice,
|
||||
BYTE bValue
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceGetExMode(
|
||||
HSLCAN hDevice,
|
||||
PBYTE pbValue
|
||||
);
|
||||
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceWriteMessages(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_MESSAGE pMsg,
|
||||
DWORD dwCount,
|
||||
PBYTE pbStatus
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceWriteMessagesEx(
|
||||
HSLCAN hDevice,
|
||||
PSLCAN_TXMESSAGE pMsg,
|
||||
DWORD dwCount,
|
||||
PBYTE pbStatus,
|
||||
PDWORD pdwCount
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceReadMessages(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwTimeOut,
|
||||
PSLCAN_MESSAGE pMsg,
|
||||
DWORD dwCount,
|
||||
PDWORD pdwCount
|
||||
);
|
||||
|
||||
SLCANAPI BOOL STDCALL SlCan_DeviceReadEvents(
|
||||
HSLCAN hDevice,
|
||||
DWORD dwTimeOut,
|
||||
PSLCAN_EVENT pEvent,
|
||||
DWORD dwCount,
|
||||
PDWORD pdwCount
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif //__SLCAN_H
|
BIN
ExampleDLLs/slcan.lib
Normal file
BIN
ExampleDLLs/slcan.lib
Normal file
Binary file not shown.
BIN
kernel32.dll
BIN
kernel32.dll
Binary file not shown.
Binary file not shown.
BIN
libstdc++-6.dll
BIN
libstdc++-6.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user