Skip to content

Commit d1d1760

Browse files
authored
Merge pull request #47 from josevcm/develop
Fix ISO7816 decoder
2 parents a954193 + 2adb77c commit d1d1760

File tree

17 files changed

+648
-492
lines changed

17 files changed

+648
-492
lines changed

src/nfc-app/app-qt/src/main/cpp/QtWindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,12 @@ struct QtWindow::Impl
433433
});
434434

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

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

src/nfc-app/app-qt/src/main/cpp/QtWindow.ui

Lines changed: 54 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -486,87 +486,66 @@
486486
<number>20</number>
487487
</attribute>
488488
</widget>
489-
<widget class="QWidget" name="parserWidget">
490-
<layout class="QVBoxLayout" name="parserViewLayout">
491-
<property name="spacing">
492-
<number>0</number>
489+
<widget class="QSplitter" name="parserWidget">
490+
<property name="orientation">
491+
<enum>Qt::Orientation::Vertical</enum>
492+
</property>
493+
<property name="handleWidth">
494+
<number>0</number>
495+
</property>
496+
<widget class="ParserWidget" name="parserView">
497+
<property name="sizePolicy">
498+
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
499+
<horstretch>0</horstretch>
500+
<verstretch>0</verstretch>
501+
</sizepolicy>
493502
</property>
494-
<property name="leftMargin">
495-
<number>0</number>
503+
<property name="font">
504+
<font>
505+
<family>Courier</family>
506+
<pointsize>10</pointsize>
507+
<bold>false</bold>
508+
</font>
496509
</property>
497-
<property name="topMargin">
498-
<number>0</number>
510+
<property name="frameShape">
511+
<enum>QFrame::Shape::NoFrame</enum>
499512
</property>
500-
<property name="rightMargin">
513+
<property name="lineWidth">
501514
<number>0</number>
502515
</property>
503-
<property name="bottomMargin">
504-
<number>0</number>
516+
<property name="horizontalScrollBarPolicy">
517+
<enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOn</enum>
518+
</property>
519+
<property name="selectionMode">
520+
<enum>QAbstractItemView::SelectionMode::SingleSelection</enum>
505521
</property>
506-
<item>
507-
<widget class="ParserWidget" name="parserView">
508-
<property name="sizePolicy">
509-
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
510-
<horstretch>0</horstretch>
511-
<verstretch>0</verstretch>
512-
</sizepolicy>
513-
</property>
514-
<property name="font">
515-
<font>
516-
<family>Courier</family>
517-
<pointsize>10</pointsize>
518-
<bold>false</bold>
519-
</font>
520-
</property>
521-
<property name="frameShape">
522-
<enum>QFrame::Shape::NoFrame</enum>
523-
</property>
524-
<property name="lineWidth">
525-
<number>0</number>
526-
</property>
527-
<property name="horizontalScrollBarPolicy">
528-
<enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOn</enum>
529-
</property>
530-
<property name="selectionMode">
531-
<enum>QAbstractItemView::SelectionMode::SingleSelection</enum>
532-
</property>
533-
<property name="selectionBehavior">
534-
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
535-
</property>
536-
<property name="rootIsDecorated">
537-
<bool>true</bool>
538-
</property>
539-
<property name="headerHidden">
540-
<bool>false</bool>
541-
</property>
542-
<property name="wordWrap">
543-
<bool>true</bool>
544-
</property>
545-
</widget>
546-
</item>
547-
<item>
548-
<widget class="HexViewWidget" name="dataView" native="true">
549-
<property name="sizePolicy">
550-
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
551-
<horstretch>0</horstretch>
552-
<verstretch>0</verstretch>
553-
</sizepolicy>
554-
</property>
555-
<property name="minimumSize">
556-
<size>
557-
<width>0</width>
558-
<height>80</height>
559-
</size>
560-
</property>
561-
<property name="maximumSize">
562-
<size>
563-
<width>16777215</width>
564-
<height>80</height>
565-
</size>
566-
</property>
567-
</widget>
568-
</item>
569-
</layout>
522+
<property name="selectionBehavior">
523+
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
524+
</property>
525+
<property name="rootIsDecorated">
526+
<bool>true</bool>
527+
</property>
528+
<property name="headerHidden">
529+
<bool>false</bool>
530+
</property>
531+
<property name="wordWrap">
532+
<bool>true</bool>
533+
</property>
534+
</widget>
535+
<widget class="HexViewWidget" name="dataView" native="true">
536+
<property name="sizePolicy">
537+
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
538+
<horstretch>0</horstretch>
539+
<verstretch>0</verstretch>
540+
</sizepolicy>
541+
</property>
542+
<property name="minimumSize">
543+
<size>
544+
<width>0</width>
545+
<height>80</height>
546+
</size>
547+
</property>
548+
</widget>
570549
</widget>
571550
</widget>
572551
</item>

src/nfc-app/app-qt/src/main/cpp/widgets/FrequencyWidget.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct FrequencyWidget::Impl
156156
plot->legend->setColumnStretchFactor(1, 1);
157157

158158
// connect refresh timer signal
159-
QObject::connect(refreshTimer, &QTimer::timeout, [=]() {
159+
refreshTimer->callOnTimeout([=] {
160160
refresh();
161161
});
162162

@@ -188,8 +188,8 @@ struct FrequencyWidget::Impl
188188
{
189189
double temp[buffer.elements()];
190190

191-
double decimation = buffer.decimation() > 0 ? (float) buffer.decimation() : 1.0f;
192-
double binStep = (sampleRate / decimation) / (float) buffer.elements();
191+
double decimation = buffer.decimation() > 0 ? (float)buffer.decimation() : 1.0f;
192+
double binStep = (sampleRate / decimation) / (float)buffer.elements();
193193
double lowerFreq = centerFreq - (sampleRate / (decimation * 2));
194194
double upperFreq = centerFreq + (sampleRate / (decimation * 2));
195195
double fftSize = buffer.elements();
@@ -389,6 +389,3 @@ QCPRange FrequencyWidget::scaleFilter(const QCPRange &newScale)
389389
{
390390
return AbstractPlotWidget::scaleFilter(newScale);
391391
}
392-
393-
394-

src/nfc-app/app-qt/src/main/cpp/widgets/HexViewWidget.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct HexViewWidget::Impl
8989
charHeight = addrFontMetrics.height();
9090

9191
// connect refresh timer signal
92-
QObject::connect(blinkTimer, &QTimer::timeout, [=]() {
92+
blinkTimer->callOnTimeout([=] {
9393
if (widget->hasFocus())
9494
{
9595
cursorVisible = !cursorVisible;
@@ -163,7 +163,7 @@ struct HexViewWidget::Impl
163163
else
164164
painter.setBackground(defaultBrush);
165165

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

169169
// draw ascii data
@@ -177,7 +177,7 @@ struct HexViewWidget::Impl
177177
else
178178
painter.setBackground(defaultBrush);
179179

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

@@ -215,7 +215,7 @@ struct HexViewWidget::Impl
215215

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

221221
return text.trimmed();
@@ -242,7 +242,7 @@ void HexViewWidget::setCursor(int position)
242242
{
243243
if (impl->data.size() > 0)
244244
{
245-
impl->cursorPosition = std::clamp(position, 0, (int) impl->data.size() - 1);
245+
impl->cursorPosition = std::clamp(position, 0, (int)impl->data.size() - 1);
246246
impl->cursorVisible = true;
247247

248248
impl->blinkTimer->start(500);
@@ -255,8 +255,8 @@ void HexViewWidget::setSelection(int start, int end)
255255
{
256256
if (start >= 0 && end >= start && impl->data.size() > 0)
257257
{
258-
impl->selectionStart = std::clamp(start, 0, (int) impl->data.size() - 1);
259-
impl->selectionEnd = std::clamp(end, 0, (int) impl->data.size() - 1);
258+
impl->selectionStart = std::clamp(start, 0, (int)impl->data.size() - 1);
259+
impl->selectionEnd = std::clamp(end, 0, (int)impl->data.size() - 1);
260260

261261
QClipboard *clipboard = QApplication::clipboard();
262262

@@ -365,4 +365,4 @@ void HexViewWidget::mousePressEvent(QMouseEvent *event)
365365
{
366366
setSelection(0, 0);
367367
}
368-
}
368+
}

src/nfc-lib/lib-lab/lab-data/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ set(PRIVATE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp)
44
set(PUBLIC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/main/include)
55

66
add_library(lab-data STATIC
7+
src/main/cpp/Crc.cpp
78
src/main/cpp/RawFrame.cpp
89
)
910

10-
#target_compile_options(nfc-tasks PRIVATE "-fopt-info-vec-optimized")
11-
1211
target_include_directories(lab-data PUBLIC ${PUBLIC_INCLUDE_DIR})
1312
target_include_directories(lab-data PRIVATE ${PRIVATE_SOURCE_DIR})
1413

0 commit comments

Comments
 (0)