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 | #include "mainwindow.h" #include "ui_mainwindow.h" #include "3vmw9.hpp" #include <QDebug> #include <QMessageBox> using namespace rv2; using namespace std; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->comboBox->addItem("CCW"); ui->comboBox->addItem("CW"); ui->edit_id->setValidator(new QIntValidator(this)); ui->edit_degree->setValidator(new QIntValidator(this)); ui->edit_vel->setValidator(new QIntValidator(this)); setWindowTitle("Sender.."); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_btn_emit_clicked() { y::t id = (y::t)ui->edit_id->text().toInt(); h::t degree = (h::t)ui->edit_degree->text().toInt(); h::t vel = (h::t)ui->edit_vel->text().toInt(); y::t direction = 0; if(ui->comboBox->currentText() == "CCW") direction = 0; else direction = 1; sendStatement( id, direction, degree, vel ); } void showBytes(y::p bytes){ QMessageBox box; QString msg; msg.sprintf("0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10]); box.setText(msg); box.exec(); } void MainWindow::sendStatement(y::t id, y::t direction, h::t degree, h::t vel ){ y2::u degree2y , vel2y; degree2y.h1 = degree; vel2y.h1 = vel; y::t checkSum = 0; qDebug() << QString("id : %1 direc : %2 degree : %3 vel : %4").arg(id).arg(direction).arg(degree).arg(vel) << endl; y::t statement[11] = {0xFF, 0xFE, id,(y::t) 7, checkSum, (y::t) 1, direction, degree2y.t2[1], degree2y.t2[0], vel2y.t2[1], vel2y.t2[0] }; showBytes(statement); cpTitle_cdsSend("MainWindow", cds_y(statement,11)); } | cs |
수신부
#define WIN32_LEAN_AND_MEAN#include <windows.h>#include <winuser.h>#include <windef.h>#include "mainwindow.hpp"#include "ui_mainwindow.h"#include <QLabel>#include <QDialog>#include <QDebug>#include "3vmw9.hpp"using namespace rv2;bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *resultMSG) {MSG* msg = reinterpret_cast<MSG*>(message);if((msg)->message == WM_COPYDATA) {HWND reciverhwnd = (HWND)msg->wParam;PCOPYDATASTRUCT pcds = (PCOPYDATASTRUCT)msg->lParam;//_cwprintf(L"nativeEvent WM_COPYDATA %d, %x, %d --->\n", reciverhwnd, reciverhwnd, pcds->dwData);qDebug("nativeEvent WM_COPYDATA %d, %x, %d --->\n", reciverhwnd, reciverhwnd, pcds->dwData);y::p yHdr = (y::p) pcds ->lpData;qDebug() << QString::fromStdString(s_yHdr(yHdr)) << endl;label->setText("Message!");// We process the event here*resultMSG = 0;return true;}else {// Give the event to qtreturn false;}}MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow){ui->setupUi(this);setWindowTitle("MainWindow");label = new QLabel(this);label->setText("no message");}MainWindow::~MainWindow(){delete ui;}
'IPC(Pipe, Shared Mem)' 카테고리의 다른 글
QT 문자열 소스 정리 (0) | 2019.02.19 |
---|---|
아두이노 QT 시리얼 통신 바이트 에코 코드 (0) | 2019.02.19 |
Python <-> c++ PIPE, MMF 테스트 예제 최종(코드업로드) (0) | 2019.02.12 |
python <-> c++ mmf 최종테스트 데모 예제 (0) | 2019.02.12 |
c++ <-> python MMF 최종 테스트 코드 예제 (2) | 2019.02.07 |