mirror of
https://github.com/caperren/school_archives.git
synced 2025-11-09 21:51:15 +00:00
Added old firmware and pcb design files
These are all design documents that I thought I had lost. It's may make me cringe, but it's still cool to use it to see how far I've come.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
|
||||
#include "PortListener.h"
|
||||
#include <QtDebug>
|
||||
|
||||
PortListener::PortListener(const QString &portName)
|
||||
{
|
||||
qDebug() << "hi there";
|
||||
this->port = new QextSerialPort(portName, QextSerialPort::EventDriven);
|
||||
port->setBaudRate(BAUD9600);
|
||||
port->setFlowControl(FLOW_OFF);
|
||||
port->setParity(PAR_NONE);
|
||||
port->setDataBits(DATA_8);
|
||||
port->setStopBits(STOP_2);
|
||||
|
||||
if (port->open(QIODevice::ReadWrite) == true) {
|
||||
connect(port, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
||||
connect(port, SIGNAL(dsrChanged(bool)), this, SLOT(onDsrChanged(bool)));
|
||||
if (!(port->lineStatus() & LS_DSR))
|
||||
qDebug() << "warning: device is not turned on";
|
||||
qDebug() << "listening for data on" << port->portName();
|
||||
}
|
||||
else {
|
||||
qDebug() << "device failed to open:" << port->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
void PortListener::onReadyRead()
|
||||
{
|
||||
QByteArray bytes;
|
||||
int a = port->bytesAvailable();
|
||||
bytes.resize(a);
|
||||
port->read(bytes.data(), bytes.size());
|
||||
qDebug() << "bytes read:" << bytes.size();
|
||||
qDebug() << "bytes:" << bytes;
|
||||
}
|
||||
|
||||
void PortListener::onDsrChanged(bool status)
|
||||
{
|
||||
if (status)
|
||||
qDebug() << "device was turned on";
|
||||
else
|
||||
qDebug() << "device was turned off";
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
|
||||
#ifndef PORTLISTENER_H_
|
||||
#define PORTLISTENER_H_
|
||||
|
||||
#include <QObject>
|
||||
#include "qextserialport.h"
|
||||
|
||||
class PortListener : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PortListener(const QString &portName);
|
||||
|
||||
private:
|
||||
QextSerialPort *port;
|
||||
|
||||
private slots:
|
||||
void onReadyRead();
|
||||
void onDsrChanged(bool status);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /*PORTLISTENER_H_*/
|
||||
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Users\Corwin\AppData\Roaming\Insync\App\res\shared-folder-vista-7.ico,0
|
||||
@@ -0,0 +1,7 @@
|
||||
TEMPLATE = app
|
||||
DEPENDPATH += .
|
||||
CONFIG += console
|
||||
include(../../src/qextserialport.pri)
|
||||
|
||||
SOURCES += main.cpp PortListener.cpp
|
||||
HEADERS += PortListener.h
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @file main.cpp
|
||||
* @brief Main file.
|
||||
* @author Michal Policht
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include "PortListener.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
QString portName = QLatin1String("COM1"); // update this to use your port of choice
|
||||
PortListener listener(portName); // signals get hooked up internally
|
||||
|
||||
// start the event loop and wait for signals
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user