Skip to content

Commit

Permalink
Merge pull request #47 from josevcm/develop
Browse files Browse the repository at this point in the history
Fix ISO7816 decoder
  • Loading branch information
josevcm authored Nov 30, 2024
2 parents a954193 + 2adb77c commit d1d1760
Show file tree
Hide file tree
Showing 17 changed files with 648 additions and 492 deletions.
4 changes: 2 additions & 2 deletions src/nfc-app/app-qt/src/main/cpp/QtWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,12 @@ struct QtWindow::Impl
});

// connect acquire timer signal
acquireTimerTimeoutConnection = connect(acquireTimer, &QTimer::timeout, [=] {
acquireTimerTimeoutConnection = acquireTimer->callOnTimeout([=] {
toggleStop();
});

// connect refresh timer signal
refreshTimerTimeoutConnection = connect(refreshTimer, &QTimer::timeout, [=] {
refreshTimerTimeoutConnection = refreshTimer->callOnTimeout([=] {
refreshView();
});

Expand Down
129 changes: 54 additions & 75 deletions src/nfc-app/app-qt/src/main/cpp/QtWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -486,87 +486,66 @@
<number>20</number>
</attribute>
</widget>
<widget class="QWidget" name="parserWidget">
<layout class="QVBoxLayout" name="parserViewLayout">
<property name="spacing">
<number>0</number>
<widget class="QSplitter" name="parserWidget">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="handleWidth">
<number>0</number>
</property>
<widget class="ParserWidget" name="parserView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="leftMargin">
<number>0</number>
<property name="font">
<font>
<family>Courier</family>
<pointsize>10</pointsize>
<bold>false</bold>
</font>
</property>
<property name="topMargin">
<number>0</number>
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="rightMargin">
<property name="lineWidth">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOn</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SelectionMode::SingleSelection</enum>
</property>
<item>
<widget class="ParserWidget" name="parserView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Courier</family>
<pointsize>10</pointsize>
<bold>false</bold>
</font>
</property>
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOn</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SelectionMode::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property>
<property name="rootIsDecorated">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="HexViewWidget" name="dataView" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
</widget>
</item>
</layout>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property>
<property name="rootIsDecorated">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="HexViewWidget" name="dataView" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>80</height>
</size>
</property>
</widget>
</widget>
</widget>
</item>
Expand Down
9 changes: 3 additions & 6 deletions src/nfc-app/app-qt/src/main/cpp/widgets/FrequencyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct FrequencyWidget::Impl
plot->legend->setColumnStretchFactor(1, 1);

// connect refresh timer signal
QObject::connect(refreshTimer, &QTimer::timeout, [=]() {
refreshTimer->callOnTimeout([=] {
refresh();
});

Expand Down Expand Up @@ -188,8 +188,8 @@ struct FrequencyWidget::Impl
{
double temp[buffer.elements()];

double decimation = buffer.decimation() > 0 ? (float) buffer.decimation() : 1.0f;
double binStep = (sampleRate / decimation) / (float) buffer.elements();
double decimation = buffer.decimation() > 0 ? (float)buffer.decimation() : 1.0f;
double binStep = (sampleRate / decimation) / (float)buffer.elements();
double lowerFreq = centerFreq - (sampleRate / (decimation * 2));
double upperFreq = centerFreq + (sampleRate / (decimation * 2));
double fftSize = buffer.elements();
Expand Down Expand Up @@ -389,6 +389,3 @@ QCPRange FrequencyWidget::scaleFilter(const QCPRange &newScale)
{
return AbstractPlotWidget::scaleFilter(newScale);
}



16 changes: 8 additions & 8 deletions src/nfc-app/app-qt/src/main/cpp/widgets/HexViewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct HexViewWidget::Impl
charHeight = addrFontMetrics.height();

// connect refresh timer signal
QObject::connect(blinkTimer, &QTimer::timeout, [=]() {
blinkTimer->callOnTimeout([=] {
if (widget->hasFocus())
{
cursorVisible = !cursorVisible;
Expand Down Expand Up @@ -163,7 +163,7 @@ struct HexViewWidget::Impl
else
painter.setBackground(defaultBrush);

painter.drawText(QRect(dataCoord + charCoord + 5, lineCoord, charWidth * 2, charHeight), Qt::AlignCenter, QString("%1").arg((int) data[pos] & 0xff, 2, 16, QChar('0')));
painter.drawText(QRect(dataCoord + charCoord + 5, lineCoord, charWidth * 2, charHeight), Qt::AlignCenter, QString("%1").arg((int)data[pos] & 0xff, 2, 16, QChar('0')));
}

// draw ascii data
Expand All @@ -177,7 +177,7 @@ struct HexViewWidget::Impl
else
painter.setBackground(defaultBrush);

painter.drawText(QRect(textCoord + charCoord + 5, lineCoord, charWidth, charHeight), Qt::AlignCenter, (int) data[pos] >= 0x20 ? QString("%1").arg((char) data[pos]) : ".");
painter.drawText(QRect(textCoord + charCoord + 5, lineCoord, charWidth, charHeight), Qt::AlignCenter, (int)data[pos] >= 0x20 ? QString("%1").arg((char)data[pos]) : ".");
}
}

Expand Down Expand Up @@ -215,7 +215,7 @@ struct HexViewWidget::Impl

for (int i = from; i < value.count() && i < to; i++)
{
text.append(value[i] >= 0x20 ? QString("%1").arg((char) value[i]) : ".");
text.append(value[i] >= 0x20 ? QString("%1").arg((char)value[i]) : ".");
}

return text.trimmed();
Expand All @@ -242,7 +242,7 @@ void HexViewWidget::setCursor(int position)
{
if (impl->data.size() > 0)
{
impl->cursorPosition = std::clamp(position, 0, (int) impl->data.size() - 1);
impl->cursorPosition = std::clamp(position, 0, (int)impl->data.size() - 1);
impl->cursorVisible = true;

impl->blinkTimer->start(500);
Expand All @@ -255,8 +255,8 @@ void HexViewWidget::setSelection(int start, int end)
{
if (start >= 0 && end >= start && impl->data.size() > 0)
{
impl->selectionStart = std::clamp(start, 0, (int) impl->data.size() - 1);
impl->selectionEnd = std::clamp(end, 0, (int) impl->data.size() - 1);
impl->selectionStart = std::clamp(start, 0, (int)impl->data.size() - 1);
impl->selectionEnd = std::clamp(end, 0, (int)impl->data.size() - 1);

QClipboard *clipboard = QApplication::clipboard();

Expand Down Expand Up @@ -365,4 +365,4 @@ void HexViewWidget::mousePressEvent(QMouseEvent *event)
{
setSelection(0, 0);
}
}
}
3 changes: 1 addition & 2 deletions src/nfc-lib/lib-lab/lab-data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ set(PRIVATE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp)
set(PUBLIC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/main/include)

add_library(lab-data STATIC
src/main/cpp/Crc.cpp
src/main/cpp/RawFrame.cpp
)

#target_compile_options(nfc-tasks PRIVATE "-fopt-info-vec-optimized")

target_include_directories(lab-data PUBLIC ${PUBLIC_INCLUDE_DIR})
target_include_directories(lab-data PRIVATE ${PRIVATE_SOURCE_DIR})

Expand Down
Loading

0 comments on commit d1d1760

Please sign in to comment.