1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
/**
* @licence app begin@
* Copyright (C) 2014 BMW AG
*
* This file is part of COVESA Project Dlt Viewer.
*
* Contributions are licensed to the COVESA Alliance under one or more
* Contribution License Agreements.
*
* \copyright
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
* this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* \author
* Alexander Wenzel <alexander.aw.wenzel@bmw.de>
*
* \file mainwindow.cpp
* For further information see http://www.covesa.global/.
* @licence end@
*/
#include "QMessageBox"
#include <QFile>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <qwaitcondition.h>
#include "example5.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
example5_init();
server.listen(QHostAddress::Any,8888);
connect(&server,SIGNAL(newConnection()),this,SLOT(newConnection()));
ui->lineEditMessages->setText("100");
socket = 0;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButtonMessage_clicked()
{
example5_test1();
}
void MainWindow::on_pushButtonMessage2_clicked()
{
example5_test2();
}
void MainWindow::on_pushButtonMessage3_clicked()
{
example5_test3(ui->lineEditMessages->text().toInt());
}
void MainWindow::on_pushButtonSend_clicked()
{
unsigned char *DLTdata;
int DLTlength;
while((DLTlength = dlt_user_log_read(&DLTdata)) > 0)
{
//LOGGER_Send((char*)DLTdata,DLTlength);
socket->write((const char*)DLTdata,DLTlength);
dlt_user_log_read_ack(DLTlength);
}
}
void MainWindow::newConnection()
{
QMessageBox::information(this,"DLT Embedded Test","Connected");
socket = server.nextPendingConnection();
}
void MainWindow::on_pushButtonSendFile_clicked()
{
char buffer[100];
int length;
int size;
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open DLT Log file"), "", tr("DLT Files (*.dlt);;All files (*.*)"));
if(fileName.isEmpty())
{
return;
}
QFile file(fileName);
file.open(QIODevice::ReadOnly);
size = file.size();
//for(int num = 0;num < size;num+=51)
{
//file.seek(num);
file.seek(ui->lineEditFileOffset->text().toInt());
while (!file.atEnd()) {
length = file.read(buffer,1);
socket->write(buffer,length);
}
}
file.close();
}
|