Skip to content

Commit

Permalink
Use QSerialPort instead of QextSerialPort. Made compiling again worki…
Browse files Browse the repository at this point in the history
…ng for QT under MSVC and also as multicore if supported.
  • Loading branch information
Larswad committed Mar 8, 2015
1 parent bb32702 commit 30c7a09
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 227 deletions.
8 changes: 0 additions & 8 deletions README.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ files in release and debug folders under the source folder.

Build a single executable without dependencies:
-----------------------------------------------


REQUIREMENTS: (external dependencies):
QextSerialPort project:
https://code.google.com/p/qextserialport/

The QextSerialPort project should be located on the same directory level as the "rpi2iec" project.

Optional: Max7219 driver library (modified by Lars Wadefalk to c++ with support for progress bar display and scroller).
Github project:
https://github.com/Larswad/arduino_max7219.git
Expand Down
1 change: 1 addition & 0 deletions logger.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "logger.hpp"
#include <iso646.h>
#include <QDate>
#include <QSettings>

Expand Down
40 changes: 18 additions & 22 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ QStringList LOG_LEVELS = (QStringList()


// Default Device and Arduino PIN configuration.
const uint DEFAULT_BAUDRATE = BAUD115200;
const uint DEFAULT_BAUDRATE = QSerialPort::Baud115200;
const uint DEFAULT_DEVICE_NUMBER = 8;
const uint DEFAULT_RESET_PIN = 7;
const uint DEFAULT_CLOCK_PIN = 4;
Expand Down Expand Up @@ -134,7 +134,7 @@ const QString PROGRAM_VERSION_HISTORY = qApp->tr(
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_port(QextSerialPort::EventDriven, this)
, m_port(this)
, m_isConnected(false)
, m_iface()
, m_isInitialized(false)
Expand All @@ -149,15 +149,15 @@ MainWindow::MainWindow(QWidget* parent) :
loggerInstance().addTransport(this);

// Set up the port basic parameters, these won't change...promise.
m_port.setDataBits(DATA_8);
m_port.setParity(PAR_NONE);
m_port.setFlowControl(FLOW_OFF);
m_port.setStopBits(STOP_1);
m_port.setDataBits(QSerialPort::Data8);
m_port.setParity(QSerialPort::NoParity);
m_port.setFlowControl(QSerialPort::NoFlowControl);
m_port.setStopBits(QSerialPort::OneStop);

enumerateComPorts();

readSettings();
m_port.setBaudRate(static_cast<BaudRateType>(m_appSettings.baudRate));
m_port.setBaudRate(static_cast<QSerialPort::BaudRate>(m_appSettings.baudRate));
usePortByFriendlyName(m_appSettings.portName);

m_port.open(QIODevice::ReadWrite);
Expand Down Expand Up @@ -267,33 +267,29 @@ void MainWindow::onCbmMachineSelected(QAction* pAction)

void MainWindow::enumerateComPorts()
{
m_ports = QextSerialEnumerator::getPorts();
m_ports = QSerialPortInfo::availablePorts();

// Manually add the ports that the enumerator can't know about.
#if defined(__arm__)
// just for the Raspberry PI.
static QextPortInfo piPort = { "/dev/ttyAMA0", "ttyAMA0", "Arduino AMA0", "", 0, 0 };
m_ports.insert(0, piPort);
// m_port.setBaudRate(BAUD57600/*BAUD1152000*/);
#elif defined(Q_OS_LINUX)
static QextPortInfo unixPort = { "/dev/ttyACM0", "ttyACM0", "Arduino ACM0", "", 0, 0 };
m_ports.insert(0, unixPort);
// static QSerialPortInfo piPort("ttyAMA0");/* = { "/dev/ttyAMA0", "ttyAMA0", "Arduino AMA0", "", 0, 0 };*/
// m_ports.insert(0, piPort);
#elif defined(Q_OS_MAC)
QDir dev("/dev","tty.usbmodem*", QDir::Name,QDir::Files bitor QDir::Readable bitor QDir::Writable bitor QDir::System);
QDir dev("/dev", "tty.usbmodem*", QDir::Name,QDir::Files bitor QDir::Readable bitor QDir::Writable bitor QDir::System);
foreach(const QFileInfo entry, dev.entryInfoList()) {
static QextPortInfo unixPort = { entry.absoluteFilePath(), entry.fileName(), entry.fileName(), "", 0, 0 };
m_ports.insert(0, unixPort);
static QSerialPortInfo macPort(entry.fileName); /* = { entry.absoluteFilePath(), entry.fileName(), entry.fileName(), "", 0, 0 };*/
m_ports.insert(0, macPort);
}
#endif
} // enumerateComPorts


void MainWindow::usePortByFriendlyName(const QString& friendlyName)
{
foreach(QextPortInfo port, m_ports) {
if(port.friendName == friendlyName) {
foreach(QSerialPortInfo port, m_ports) {
if(port.portName() == friendlyName) {
// found it, set it and be done.
m_port.setPortName(port.portName);
m_port.setPort(port);
break;
}
}
Expand Down Expand Up @@ -339,7 +335,7 @@ void MainWindow::on_actionSettings_triggered()
updateImageList();
}
if(m_appSettings.baudRate not_eq oldSettings.baudRate)
m_port.setBaudRate(static_cast<BaudRateType>(m_appSettings.baudRate));
m_port.setBaudRate(static_cast<QSerialPort::BaudRate>(m_appSettings.baudRate));

// Was port changed?
if(m_appSettings.portName not_eq oldSettings.portName) {
Expand Down Expand Up @@ -392,7 +388,7 @@ void MainWindow::readSettings()
m_appSettings.lastSpecificMounted = sets.value("singleImageName").toString();
QDir::setCurrent(m_appSettings.imageDirectory);
ui->imageFilter->setText(sets.value("imageFilter", QString()).toString());
m_appSettings.portName = sets.value("portName", m_ports.isEmpty() ? "COM1" : m_ports.first().friendName).toString();
m_appSettings.portName = sets.value("portName", m_ports.isEmpty() ? "COM1" : m_ports.first().portName()).toString();
m_appSettings.baudRate = sets.value("baudRate", QString::number(DEFAULT_BAUDRATE)).toUInt();
m_appSettings.deviceNumber = sets.value("deviceNumber", QString::number(DEFAULT_DEVICE_NUMBER)).toUInt();
m_appSettings.atnPin = sets.value("atnPin", QString::number(DEFAULT_ATN_PIN)).toUInt();
Expand Down
6 changes: 3 additions & 3 deletions mainwindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QStandardItemModel>
#include <QFileInfo>
#include <QFileSystemWatcher>
#include <qextserialport.h>
#include <QtSerialPort/QtSerialPort>
#include <QMap>
#include "interface.hpp"
#include "logger.hpp"
Expand Down Expand Up @@ -111,12 +111,12 @@ private slots:
void cbmCursorVisible(bool visible = true);

Ui::MainWindow *ui;
QextSerialPort m_port;
QSerialPort m_port;
QByteArray m_pendingBuffer;
bool m_isConnected;
FacilityMap m_clientFacilities;
Interface m_iface;
QextPortInfoList m_ports;
QList<QSerialPortInfo> m_ports;
QStandardItemModel* m_dirListItemModel;
QFileInfoList m_filteredInfoList;
QFileInfoList m_infoList;
Expand Down
1 change: 1 addition & 0 deletions mountspecificfile.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <QFileDialog>
#include <iso646.h>
#include "mountspecificfile.h"
#include "ui_mountspecificfile.h"

Expand Down
99 changes: 44 additions & 55 deletions notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ REBOOT!
test that this works with minicom:
minicom -b 9600 -o -D /dev/ttyAMA0


--------------------------------------------------
qt support for serial port:
--------------------------------------------------

qextserialport is found here:
git clone https://code.google.com/p/qextserialport/

(simply build with qmake)
TODO: QT5 has specific class for serial port support. Future versions may preferably use this instead!

------------------------------------------------------
How to test the ATN, CLOCK, DATA lines from CBM basic:
------------------------------------------------------
Expand Down Expand Up @@ -128,7 +117,7 @@ If 'l' is returned, there was no more data
CBM syntax:
--------------------------------------------------
LOAD"<<",8 Reset interface and communication state. Do this if there is problem with PC to arduino sync.
Read < as the petscii back-arrow.
Read < as the petscii back-arrow.

LOAD "!!",8
Retreive information about the current used file system / image.
Expand All @@ -137,7 +126,7 @@ In Nativs FS mode: (the default mode)

LOAD "*",8 Load the first file from the current disk image or the native fs.
LOAD"$",8 Gets directory listing, equivalent to LOAD".",8
Loads the current directory, either inside an image or the native fs.
Loads the current directory, either inside an image or the native fs.
LOAD"gamesdir",8 Enter the "gamesdir" directory, and get listing.
LOAD"..",8 Up one directory and get directory listing.
LOAD"tetris.prg",8 Loads the "tetris.prg" program file.
Expand All @@ -147,15 +136,15 @@ LOAD"tape.t64",8 Loads the tape.t64 tape image and enters T64 mode.
LOAD "FILE.M2I",8 Move into a M2I "image" and load the list of contained native fs files.

In D64 mode:
Load "$", "*" wildcards, filenames works (almost) as espected on a 1541.
LOAD"<",8 (back-arrow). Escape D64 mode, and back to FAT mode.
SAVE"abc",8 Fools the CBM, but has no effect. Saves in D64 are
not implemented
Load "$", "*" wildcards, filenames works (almost) as espected on a 1541.
LOAD"<",8 (back-arrow). Escape D64 mode, and back to FAT mode.
SAVE"abc",8 Fools the CBM, but has no effect. Saves in D64 are
not implemented

In T64 mode:
Load "$", "*" wildcards, filenames works as if it was a D64.
LOAD"<",8 (back-arrow). Escape T64 mode, and back to FAT mode.
SAVE"abc",8 Fools the CBM, but has no effect.
Load "$", "*" wildcards, filenames works as if it was a D64.
LOAD"<",8 (back-arrow). Escape T64 mode, and back to FAT mode.
SAVE"abc",8 Fools the CBM, but has no effect.


NOTE:
Expand All @@ -167,37 +156,37 @@ Try a LOAD"<<",8 to try going into initial state.

1541 original commands implemented / to implement (X means implemented and working).
------------------------------------------------------------------------------------
UI- / UI+: Switch to VIC20 / VIC64 speed
NEW:name,id (abbreviated N:name,id) If id is left out directory is just cleared.
COPY:newfile=oldfile (abbreviated C:newfile=oldfile) If oldfile is several comma separated names they are concatenated.
RENAME:newfile=oldfile (abbreviated R:newfile=oldfile)
SCRATCH:filename (abbreviated S:filename) If oldfile is several comma separated names they are concatenated.
INITIALIZE (abbreviated I) Initialize drive (reset states)
VALIDATE (abbreviated V) Reorganize drive, like defragment
PRINT#file#, "BLOCK-READ:" channel; drive; track; block (abbreviated PRINT#file#, "B-R:" channel; drive; track; block
PRINT#file#, "BLOCK-WRITE:" channel; drive; track; block (abbreviated PRINT#file, "B-W:" channel; drive; track; block)
PRINT#file#, "BLOCK-ALLOCATE:" drive; track; block
PRINT#file#, "BLOCK-FREE:" drive; track; block (abbreviated PRINT#file#, "B-F:" drive; track; block
PRINT#file#, "B-P:" channel; position To set buffer pointer
PRINT#file#, "P" CHR$(channel#) CHR$(rec#lo) CHR$(rec#hi)CHR$(position) Set position in REL files
PRINT#file#, "U1:" channel; drive; track; block (abbreviated PRINT#file#, "UA:" channel; drive; track; block) USER1 command
PRINT#file#, "U2:" channel; drive; track; block (abbreviated PRINT#file#, "UB:" channel; drive; track; block USER2 command
PRINT#file#, "M-R" CHR$(low byte of address) CHR$(high byte) memory read
PRINT#file#, "M-W" CHR$(low address byte) CHR$(high address byte)CHR$(#-of-characters) byte data memory write
PRINT#file#, "M-E" CHR$(low address byte) CHR$(high byte) memory execute
PRINT#file#,"M-W:" CHR$(119) CHR$(0) CHR$(2) CHR$(address+32)CHR$(address+64) change device number
UI- / UI+: Switch to VIC20 / VIC64 speed
NEW:name,id (abbreviated N:name,id) If id is left out directory is just cleared.
COPY:newfile=oldfile (abbreviated C:newfile=oldfile) If oldfile is several comma separated names they are concatenated.
RENAME:newfile=oldfile (abbreviated R:newfile=oldfile)
SCRATCH:filename (abbreviated S:filename) If oldfile is several comma separated names they are concatenated.
INITIALIZE (abbreviated I) Initialize drive (reset states)
VALIDATE (abbreviated V) Reorganize drive, like defragment
PRINT#file#, "BLOCK-READ:" channel; drive; track; block (abbreviated PRINT#file#, "B-R:" channel; drive; track; block
PRINT#file#, "BLOCK-WRITE:" channel; drive; track; block (abbreviated PRINT#file, "B-W:" channel; drive; track; block)
PRINT#file#, "BLOCK-ALLOCATE:" drive; track; block
PRINT#file#, "BLOCK-FREE:" drive; track; block (abbreviated PRINT#file#, "B-F:" drive; track; block
PRINT#file#, "B-P:" channel; position To set buffer pointer
PRINT#file#, "P" CHR$(channel#) CHR$(rec#lo) CHR$(rec#hi)CHR$(position) Set position in REL files
PRINT#file#, "U1:" channel; drive; track; block (abbreviated PRINT#file#, "UA:" channel; drive; track; block) USER1 command
PRINT#file#, "U2:" channel; drive; track; block (abbreviated PRINT#file#, "UB:" channel; drive; track; block USER2 command
PRINT#file#, "M-R" CHR$(low byte of address) CHR$(high byte) memory read
PRINT#file#, "M-W" CHR$(low address byte) CHR$(high address byte)CHR$(#-of-characters) byte data memory write
PRINT#file#, "M-E" CHR$(low address byte) CHR$(high byte) memory execute
PRINT#file#,"M-W:" CHR$(119) CHR$(0) CHR$(2) CHR$(address+32)CHR$(address+64) change device number

X LOAD PROGRAM WILDCARD support working?
SAVE PROGRAM Must handle save with replace, @0:filename
SAVE PROGRAM Must handle save with replace, @0:filename

sdi2ec support:
---------------------------------------------

Changing directories (CMD syntax):
OPEN1,8,15,"CD/SOMEDIR/":CLOSE1 - change to SOMEDIR (relative, in uno2iec relative to current directory)
OPEN1,8,15,"CD//":CLOSE1 - change to root directory (In Uno2iec this root means: base path)
OPEN1,8,15,"CD//SOMEDIR/":CLOSE1 - change to SOMEDIR (in root)
OPEN1,8,15,"CD:←":CLOSE1 - go to parent directory
OPEN1,8,15,"CD/SOMEDIR/":CLOSE1 - change to SOMEDIR (relative, in uno2iec relative to current directory)
OPEN1,8,15,"CD//":CLOSE1 - change to root directory (In Uno2iec this root means: base path)
OPEN1,8,15,"CD//SOMEDIR/":CLOSE1 - change to SOMEDIR (in root)
OPEN1,8,15,"CD:←":CLOSE1 - go to parent directory

Using M2Is or D64s:

Expand All @@ -207,13 +196,13 @@ OPEN1,8,15,"CD:←":CLOSE1 - leave M2I/D64

Loading files:

LOAD"//SOMEDIR/:SOMEFILE" - load SOMEFILE in SOMEDIR (filename gets separated from path using colon)
Change device address
LOAD"//SOMEDIR/:SOMEFILE" - load SOMEFILE in SOMEDIR (filename gets separated from path using colon)
Change device address

Change device address:

OPEN1,current address,15,"U0>"+CHR$(new address):CLOSE1 - change sd2iec device number to new address
OPEN1,device address,15,"XW":close1 - this will save settings to eeprom (required if you want to set new device address as default)
OPEN1,current address,15,"U0>"+CHR$(new address):CLOSE1 - change sd2iec device number to new address
OPEN1,device address,15,"XW":close1 - this will save settings to eeprom (required if you want to set new device address as default)


files of interest in sd2iec:
Expand All @@ -234,13 +223,13 @@ parser.c / .h

fastloader.c / .h
avr/
crc.h
crc7asm.h
fastloader-ii.S
arch-config.h
arch-timer.c / .h
atomic.h
avrcompat.h
crc.h
crc7asm.h
fastloader-ii.S
arch-config.h
arch-timer.c / .h
atomic.h
avrcompat.h


files of little interest in sd2ec:
Expand Down
Loading

0 comments on commit 30c7a09

Please sign in to comment.