pyxcp 0.22.5__tar.gz → 0.22.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyxcp might be problematic. Click here for more details.

Files changed (124) hide show
  1. {pyxcp-0.22.5 → pyxcp-0.22.6}/PKG-INFO +1 -1
  2. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyproject.toml +3 -2
  3. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/__init__.py +1 -1
  4. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/unfolder.hpp +84 -1
  5. pyxcp-0.22.6/pyxcp/scripts/xcp_examples.py +64 -0
  6. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/transport/sxi.py +2 -2
  7. {pyxcp-0.22.5 → pyxcp-0.22.6}/CMakeLists.txt +0 -0
  8. {pyxcp-0.22.5 → pyxcp-0.22.6}/LICENSE +0 -0
  9. {pyxcp-0.22.5 → pyxcp-0.22.6}/README.md +0 -0
  10. {pyxcp-0.22.5 → pyxcp-0.22.6}/build_ext.py +0 -0
  11. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/EtasCANMonitoring.a2l +0 -0
  12. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/EtasCANMonitoring.aml +0 -0
  13. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/XCP_Common.aml +0 -0
  14. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/XCPonCAN.aml +0 -0
  15. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/XCPonEth.aml +0 -0
  16. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/XCPonFlx.aml +0 -0
  17. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/XCPonSxI.aml +0 -0
  18. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/XCPonUSB.aml +0 -0
  19. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/ifdata_CAN.a2l +0 -0
  20. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/ifdata_Eth.a2l +0 -0
  21. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/ifdata_Flx.a2l +0 -0
  22. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/ifdata_SxI.a2l +0 -0
  23. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/aml/ifdata_USB.a2l +0 -0
  24. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/asam/__init__.py +0 -0
  25. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/asam/types.py +0 -0
  26. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/asamkeydll.c +0 -0
  27. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/asamkeydll.sh +0 -0
  28. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/checksum.py +0 -0
  29. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cmdline.py +0 -0
  30. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/config/__init__.py +0 -0
  31. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/config/legacy.py +0 -0
  32. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/constants.py +0 -0
  33. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cpp_ext/__init__.py +0 -0
  34. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cpp_ext/bin.hpp +0 -0
  35. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cpp_ext/blockmem.hpp +0 -0
  36. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cpp_ext/daqlist.hpp +0 -0
  37. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cpp_ext/event.hpp +0 -0
  38. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cpp_ext/extension_wrapper.cpp +0 -0
  39. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cpp_ext/helper.hpp +0 -0
  40. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cpp_ext/mcobject.hpp +0 -0
  41. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/cpp_ext/tsqueue.hpp +0 -0
  42. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/daq_stim/__init__.py +0 -0
  43. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/daq_stim/optimize/__init__.py +0 -0
  44. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/daq_stim/optimize/binpacking.py +0 -0
  45. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/daq_stim/scheduler.cpp +0 -0
  46. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/daq_stim/scheduler.hpp +0 -0
  47. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/daq_stim/stim.cpp +0 -0
  48. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/daq_stim/stim.hpp +0 -0
  49. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/daq_stim/stim_wrapper.cpp +0 -0
  50. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/dllif.py +0 -0
  51. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/errormatrix.py +0 -0
  52. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/conf_can.toml +0 -0
  53. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/conf_can_user.toml +0 -0
  54. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/conf_can_vector.json +0 -0
  55. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/conf_can_vector.toml +0 -0
  56. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/conf_eth.toml +0 -0
  57. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/conf_nixnet.json +0 -0
  58. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/conf_socket_can.toml +0 -0
  59. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/conf_sxi.json +0 -0
  60. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/conf_sxi.toml +0 -0
  61. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/ex_arrow.py +0 -0
  62. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/ex_mdf.py +0 -0
  63. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/ex_sqlite.py +0 -0
  64. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/run_daq.py +0 -0
  65. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/xcp_policy.py +0 -0
  66. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/xcp_read_benchmark.py +0 -0
  67. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/xcp_skel.py +0 -0
  68. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/xcp_unlock.py +0 -0
  69. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/xcp_user_supplied_driver.py +0 -0
  70. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/xcphello.py +0 -0
  71. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/examples/xcphello_recorder.py +0 -0
  72. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/master/__init__.py +0 -0
  73. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/master/errorhandler.py +0 -0
  74. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/master/master.py +0 -0
  75. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/py.typed +0 -0
  76. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/__init__.py +0 -0
  77. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/build_clang.cmd +0 -0
  78. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/build_clang.sh +0 -0
  79. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/build_gcc.cmd +0 -0
  80. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/build_gcc.sh +0 -0
  81. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/build_gcc_arm.sh +0 -0
  82. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/converter/__init__.py +0 -0
  83. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/lz4.c +0 -0
  84. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/lz4.h +0 -0
  85. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/lz4hc.c +0 -0
  86. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/lz4hc.h +0 -0
  87. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/mio.hpp +0 -0
  88. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/reader.hpp +0 -0
  89. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/reco.py +0 -0
  90. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/recorder.rst +0 -0
  91. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/rekorder.cpp +0 -0
  92. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/rekorder.hpp +0 -0
  93. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/setup.py +0 -0
  94. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/test_reko.py +0 -0
  95. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/wrap.cpp +0 -0
  96. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/recorder/writer.hpp +0 -0
  97. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/scripts/__init__.py +0 -0
  98. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/scripts/pyxcp_probe_can_drivers.py +0 -0
  99. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/scripts/xcp_fetch_a2l.py +0 -0
  100. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/scripts/xcp_id_scanner.py +0 -0
  101. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/scripts/xcp_info.py +0 -0
  102. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/scripts/xcp_profile.py +0 -0
  103. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/stim/__init__.py +0 -0
  104. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/tests/test_asam_types.py +0 -0
  105. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/tests/test_binpacking.py +0 -0
  106. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/tests/test_can.py +0 -0
  107. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/tests/test_checksum.py +0 -0
  108. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/tests/test_daq.py +0 -0
  109. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/tests/test_frame_padding.py +0 -0
  110. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/tests/test_master.py +0 -0
  111. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/tests/test_transport.py +0 -0
  112. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/tests/test_utils.py +0 -0
  113. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/timing.py +0 -0
  114. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/transport/__init__.py +0 -0
  115. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/transport/base.py +0 -0
  116. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/transport/base_transport.hpp +0 -0
  117. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/transport/can.py +0 -0
  118. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/transport/eth.py +0 -0
  119. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/transport/transport_wrapper.cpp +0 -0
  120. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/transport/usb_transport.py +0 -0
  121. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/types.py +0 -0
  122. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/utils.py +0 -0
  123. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/vector/__init__.py +0 -0
  124. {pyxcp-0.22.5 → pyxcp-0.22.6}/pyxcp/vector/map.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyxcp
3
- Version: 0.22.5
3
+ Version: 0.22.6
4
4
  Summary: Universal Calibration Protocol for Python
5
5
  Home-page: https://github.com/christoph2/pyxcp
6
6
  License: LGPLv3
@@ -36,7 +36,7 @@ dynamic = ["license", "readme", "authors", "requires-python", "description", "cl
36
36
  [tool.poetry]
37
37
  authors = ["Christoph Schueler <cpu.gems@googlemail.com>"]
38
38
  name = "pyxcp"
39
- version = "0.22.5"
39
+ version = "0.22.6"
40
40
  readme = "README.md"
41
41
  description = "Universal Calibration Protocol for Python"
42
42
  keywords = ["automotive", "ecu", "xcp", "asam", "autosar"]
@@ -101,6 +101,7 @@ xcp-id-scanner = "pyxcp.scripts.xcp_id_scanner:main"
101
101
  xcp-fetch-a2l = "pyxcp.scripts.xcp_fetch_a2l:main"
102
102
  xcp-info = "pyxcp.scripts.xcp_info:main"
103
103
  xcp-profile = "pyxcp.scripts.xcp_profile:main"
104
+ xcp-examples = "pyxcp.scripts.xcp_examples:main"
104
105
 
105
106
  [tool.pytest]
106
107
  addopts = "--verbose --tb=short --junitxml=result.xml -o junit_family=xunit2"
@@ -143,7 +144,7 @@ show-source = true
143
144
  max-line-length = 132
144
145
  select = ["B","C","E","F","W","T4","B9"]
145
146
  # extend-select = "B950"
146
- # extend-ignore = ["E203", "E501", "E701"]
147
+ extend-ignore = ["E203", "E501", "E701"]
147
148
 
148
149
  [tool.ruff]
149
150
  line-length = 132
@@ -17,4 +17,4 @@ tb_install(show_locals=True, max_frames=3) # Install custom exception handler.
17
17
 
18
18
  # if you update this manually, do not forget to update
19
19
  # .bumpversion.cfg and pyproject.toml.
20
- __version__ = "0.22.5"
20
+ __version__ = "0.22.6"
@@ -7,6 +7,7 @@
7
7
  #include <charconv>
8
8
  #include <cstring>
9
9
  #include <iostream>
10
+ #include <limits>
10
11
  #include <map>
11
12
  #if __has_include(<stdfloat>)
12
13
  #include <stdfloat>
@@ -637,6 +638,33 @@ struct MeasurementParameters {
637
638
  return m_first_pids;
638
639
  }
639
640
 
641
+ #undef max // Thanks to Windows.
642
+
643
+ auto get_overflow_value() const {
644
+ std::uint64_t ov_value{};
645
+ switch (m_ts_size) {
646
+ case 1:
647
+ ov_value = std::numeric_limits<std::uint8_t>::max();
648
+ break;
649
+ case 2:
650
+ ov_value = std::numeric_limits<std::uint16_t>::max();
651
+ break;
652
+ case 4:
653
+ ov_value = std::numeric_limits<std::uint32_t>::max();
654
+ break;
655
+ // case 8:
656
+ // ov_value = std::numeric_limits<std::uint64_t>::max() + 1;
657
+ // break;
658
+ default:
659
+ throw std::runtime_error("Invalid timestamp size");
660
+ }
661
+ ov_value++;
662
+ std::cout << "TS-V: " << ov_value << " scale: " << m_ts_scale_factor << std::endl;
663
+ ov_value = static_cast<std::uint64_t>(ov_value * m_ts_scale_factor);
664
+ std::cout << "OVRF-Value: " << ov_value << std::endl;
665
+ return ov_value;
666
+ }
667
+
640
668
  std::uint8_t m_byte_order;
641
669
  std::uint8_t m_id_field_size;
642
670
  bool m_timestamps_supported;
@@ -1050,6 +1078,9 @@ class DAQPolicyBase {
1050
1078
  }
1051
1079
 
1052
1080
  virtual void set_parameters(const MeasurementParameters& params) noexcept {
1081
+ m_overflow_value = params.get_overflow_value();
1082
+ m_overflow_counter = 0ULL;
1083
+ std::cout << "Overflow value: " << m_overflow_value << ", Overflow counter: " << m_overflow_counter << std::endl;
1053
1084
  initialize();
1054
1085
  }
1055
1086
 
@@ -1058,6 +1089,9 @@ class DAQPolicyBase {
1058
1089
  virtual void initialize() = 0;
1059
1090
 
1060
1091
  virtual void finalize() = 0;
1092
+ private:
1093
+ std::uint64_t m_overflow_value{};
1094
+ std::uint64_t m_overflow_counter{};
1061
1095
  };
1062
1096
 
1063
1097
  class DaqRecorderPolicy : public DAQPolicyBase {
@@ -1164,6 +1198,38 @@ struct ValueHolder {
1164
1198
  std::any m_value;
1165
1199
  };
1166
1200
 
1201
+ class Overflow {
1202
+ public:
1203
+
1204
+ Overflow(std::uint64_t overflow_value) : m_overflow_value(overflow_value), m_overflow_counter(0ULL), m_previous_timestamp(0ULL) {
1205
+ }
1206
+
1207
+ auto get_previous_timestamp() const noexcept {
1208
+ return m_previous_timestamp;
1209
+ }
1210
+
1211
+ void set_previous_timestamp(std::uint64_t timestamp) noexcept {
1212
+ m_previous_timestamp = timestamp;
1213
+ }
1214
+
1215
+ void inc_overflow_counter() noexcept {
1216
+ m_overflow_counter++;
1217
+ }
1218
+
1219
+ auto get_overflow_counter() const noexcept {
1220
+ return m_overflow_counter;
1221
+ }
1222
+
1223
+ auto get_value() const noexcept {
1224
+ return m_overflow_value * m_overflow_counter;
1225
+ }
1226
+
1227
+ private:
1228
+ std::uint64_t m_overflow_value{};
1229
+ std::uint64_t m_overflow_counter{};
1230
+ std::uint64_t m_previous_timestamp{};
1231
+ };
1232
+
1167
1233
  class XcpLogFileDecoder {
1168
1234
  public:
1169
1235
 
@@ -1172,6 +1238,11 @@ class XcpLogFileDecoder {
1172
1238
  if (metadata != "") {
1173
1239
  auto des = Deserializer(metadata);
1174
1240
  m_params = des.run();
1241
+
1242
+ for (auto idx=0; idx < m_params.get_daq_lists().size(); ++idx) {
1243
+ m_overflows.emplace_back(Overflow(m_params.get_overflow_value()));
1244
+ }
1245
+
1175
1246
  m_decoder = std::make_unique<DAQProcessor>(m_params);
1176
1247
  } else {
1177
1248
  // cannot proceed!!!
@@ -1215,7 +1286,18 @@ class XcpLogFileDecoder {
1215
1286
  auto result = m_decoder->feed(timestamp, str_data);
1216
1287
  if (result) {
1217
1288
  const auto& [daq_list, ts0, ts1, meas] = *result;
1218
- on_daq_list(daq_list, ts0, ts1, meas);
1289
+
1290
+ auto& overflow = m_overflows[daq_list];
1291
+
1292
+ if (overflow.get_previous_timestamp() > ts1) {
1293
+ overflow.inc_overflow_counter();
1294
+ // Maybe on debug-level?
1295
+ // std::cout << "Overflow detected, counter: " << overflow.get_overflow_counter() << " " << overflow.get_previous_timestamp() << " " << ts1 << std::endl;
1296
+ }
1297
+
1298
+ on_daq_list(daq_list, ts0, ts1 + overflow.get_value(), meas);
1299
+
1300
+ overflow.set_previous_timestamp(ts1);
1219
1301
  }
1220
1302
  }
1221
1303
  }
@@ -1244,6 +1326,7 @@ class XcpLogFileDecoder {
1244
1326
  XcpLogFileReader m_reader;
1245
1327
  std::unique_ptr<DAQProcessor> m_decoder;
1246
1328
  MeasurementParameters m_params;
1329
+ std::vector<Overflow> m_overflows;
1247
1330
  };
1248
1331
 
1249
1332
  #endif // RECORDER_UNFOLDER_HPP
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env python
2
+
3
+ """
4
+ Copy pyXCP examples to a given directory.
5
+ """
6
+
7
+ import argparse
8
+ import sys
9
+ from pathlib import Path
10
+
11
+ from pyxcp import console
12
+
13
+
14
+ pyver = sys.version_info
15
+ if pyver.major == 3 and pyver.minor <= 9:
16
+ import pkg_resources
17
+
18
+ def copy_files_from_package(package_name: str, source_directory: str, args: argparse.Namespace) -> None:
19
+ destination_directory = args.output_directory
20
+ force = args.force
21
+ for fn in pkg_resources.resource_listdir(package_name, source_directory):
22
+ source_file = Path(pkg_resources.resource_filename(package_name, f"{source_directory}/{fn}"))
23
+ if source_file.suffix == ".py":
24
+ dest_file = Path(destination_directory) / fn
25
+ if dest_file.exists() and not force:
26
+ console.print(f"[white]Destination file [blue]{fn!r} [white]already exists. Skipping.")
27
+ continue
28
+ console.print(f"[blue]{source_file} [white]==> [green]{dest_file}")
29
+ data = source_file.read_text(encoding="utf-8")
30
+ dest_file.parent.mkdir(parents=True, exist_ok=True)
31
+ dest_file.write_text(data, encoding="utf-8")
32
+
33
+ else:
34
+ import importlib.resources
35
+
36
+ def copy_files_from_package(package_name: str, source_directory: str, args: argparse.Namespace) -> None:
37
+ destination_directory = args.output_directory
38
+ force = args.force
39
+ for fn in importlib.resources.files(f"{package_name}.{source_directory}").iterdir():
40
+ if fn.suffix == ".py":
41
+ data = fn.read_text(encoding="utf-8")
42
+ dest_file = Path(destination_directory) / fn.name
43
+ if dest_file.exists() and not force:
44
+ console.print(f"[white]Destination file [blue]{fn.name!r} [white]already exists. Skipping.")
45
+ continue
46
+ console.print(f"[blue]{fn} [white]==> [green]{dest_file}")
47
+ dest_file.parent.mkdir(parents=True, exist_ok=True)
48
+ dest_file.write_text(data, encoding="utf-8")
49
+
50
+
51
+ def main():
52
+ parser = argparse.ArgumentParser(description=__doc__)
53
+
54
+ parser.add_argument("output_directory", metavar="output_directory", type=Path, help="output directory")
55
+
56
+ parser.add_argument("-f", "--force", action="store_true", help="overwrite existing files.")
57
+
58
+ args = parser.parse_args()
59
+ print("Copying pyXCP examples...\n")
60
+ copy_files_from_package("pyxcp", "examples", args)
61
+
62
+
63
+ if __name__ == "__main__":
64
+ main()
@@ -109,7 +109,7 @@ class SxI(BaseTransport):
109
109
  while True:
110
110
  if self.closeEvent.is_set():
111
111
  return
112
- if not self.comm_port.in_waiting():
112
+ if not self.comm_port.in_waiting:
113
113
  continue
114
114
 
115
115
  recv_timestamp = self.timestamp.value
@@ -129,5 +129,5 @@ class SxI(BaseTransport):
129
129
  self.post_send_timestamp = self.timestamp.value
130
130
 
131
131
  def close_connection(self) -> None:
132
- if hasattr(self, "comm_port") and self.comm_port.is_open() and not self.has_user_supplied_interface:
132
+ if hasattr(self, "comm_port") and self.comm_port.is_open and not self.has_user_supplied_interface:
133
133
  self.comm_port.close()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes