python-can-cansub 2026.5.22__tar.gz → 2026.5.28__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-can-cansub
3
- Version: 2026.5.22
3
+ Version: 2026.5.28
4
4
  Summary: CANsub python-can interface
5
5
  Project-URL: Homepage, https://csselectronics.com/
6
6
  Project-URL: Source, https://github.com/CSS-Electronics/python-can-cansub
@@ -72,8 +72,8 @@ Example of using `detect_available_configs` to automatically discover (uses mDNS
72
72
  ```python
73
73
  configs = can.detect_available_configs(interfaces=["cansub"])
74
74
  # e.g. [{"interface": "cansub", "channel": "aabbccdd-usb.local@1"},
75
- # {"interface": "cansub", "channel": "aabbccdd-usb.local@2"}
76
- # {"interface": "cansub", "channel": "11223344-eth.local@1"}
75
+ # {"interface": "cansub", "channel": "aabbccdd-usb.local@2"},
76
+ # {"interface": "cansub", "channel": "11223344-eth.local@1"},
77
77
  # {"interface": "cansub", "channel": "11223344-eth.local@2"}]
78
78
  ```
79
79
 
@@ -145,16 +145,13 @@ with can.Bus(**configs[0], bitrate=250_000, data_bitrate=1_000_000, can_filters=
145
145
 
146
146
  `bus.recv()` blocks until a frame arrives. A `can.Notifier` runs a background thread that dispatches received frames to one or more *listeners*, allowing the main program to continue other work.
147
147
 
148
- python-can provides built-in listeners including `can.Printer` (print to stdout) and `can.Logger` (log to file). The example below logs to a CSV file while the main program continues. Custom listeners can be implemented by subclassing `can.Listener`.
148
+ python-can provides built-in listeners including `can.Printer` (print to stdout) and `can.Logger` (log to file). The example below prints to stdout and logs to a CSV file while the main program continues. Custom listeners can be implemented by subclassing `can.Listener`.
149
149
 
150
150
  ```python
151
151
  from time import sleep
152
152
 
153
- print_listener = can.Printer()
154
- csv_listener = can.Logger("log.csv")
155
-
156
153
  with can.Bus(**configs[0], bitrate=250_000, data_bitrate=1_000_000) as bus:
157
- with can.Notifier([bus], listeners=[print_listener, csv_listener]):
154
+ with can.Notifier([bus], listeners=[can.Printer(), can.Logger("log.csv")]):
158
155
 
159
156
  # Perform other tasks here while frames are received in the background
160
157
  sleep(10)
@@ -205,12 +202,14 @@ The common argument pattern for the CANsub:
205
202
  --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000
206
203
  ```
207
204
 
205
+ Note that the *filter* argument supported by some command-line tools is limited to standard (11-bit) CAN IDs. Filtering on extended (29-bit) IDs requires the python-can API.
206
+
208
207
  ### can_logger
209
208
 
210
- Log received frames to a file (CSV by default; format inferred from file extension):
209
+ Log received frames to a file (format inferred from file extension):
211
210
 
212
211
  ```bash
213
- can_logger --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000 --output-file log.csv
212
+ can_logger --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000 --file_name log.csv
214
213
  ```
215
214
 
216
215
  ### can_player
@@ -229,13 +228,15 @@ Live terminal viewer showing received frames, updated counts, timestamps, and by
229
228
  can_viewer --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000
230
229
  ```
231
230
 
231
+ On Windows, the can_viewer requires `windows-curses` (`pip install windows-curses`).
232
+
232
233
  ### can_bridge
233
234
 
234
235
  Forward all frames received on one bus to another (e.g. bridge two CANsub channels):
235
236
 
236
237
  ```bash
237
- can_bridge --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000 \
238
- --interface2 cansub --channel2 aabbccdd-usb.local@2 --bitrate2 250000 --data-bitrate2 1000000
238
+ can_bridge --bus1-interface cansub --bus1-channel aabbccdd-usb.local@1 --bus1-bitrate 250000 --bus1-data-bitrate 1000000 \
239
+ --bus2-interface cansub --bus2-channel aabbccdd-usb.local@2 --bus2-bitrate 250000 --bus2-data-bitrate 1000000
239
240
  ```
240
241
 
241
242
  ### can_logconvert
@@ -53,8 +53,8 @@ Example of using `detect_available_configs` to automatically discover (uses mDNS
53
53
  ```python
54
54
  configs = can.detect_available_configs(interfaces=["cansub"])
55
55
  # e.g. [{"interface": "cansub", "channel": "aabbccdd-usb.local@1"},
56
- # {"interface": "cansub", "channel": "aabbccdd-usb.local@2"}
57
- # {"interface": "cansub", "channel": "11223344-eth.local@1"}
56
+ # {"interface": "cansub", "channel": "aabbccdd-usb.local@2"},
57
+ # {"interface": "cansub", "channel": "11223344-eth.local@1"},
58
58
  # {"interface": "cansub", "channel": "11223344-eth.local@2"}]
59
59
  ```
60
60
 
@@ -126,16 +126,13 @@ with can.Bus(**configs[0], bitrate=250_000, data_bitrate=1_000_000, can_filters=
126
126
 
127
127
  `bus.recv()` blocks until a frame arrives. A `can.Notifier` runs a background thread that dispatches received frames to one or more *listeners*, allowing the main program to continue other work.
128
128
 
129
- python-can provides built-in listeners including `can.Printer` (print to stdout) and `can.Logger` (log to file). The example below logs to a CSV file while the main program continues. Custom listeners can be implemented by subclassing `can.Listener`.
129
+ python-can provides built-in listeners including `can.Printer` (print to stdout) and `can.Logger` (log to file). The example below prints to stdout and logs to a CSV file while the main program continues. Custom listeners can be implemented by subclassing `can.Listener`.
130
130
 
131
131
  ```python
132
132
  from time import sleep
133
133
 
134
- print_listener = can.Printer()
135
- csv_listener = can.Logger("log.csv")
136
-
137
134
  with can.Bus(**configs[0], bitrate=250_000, data_bitrate=1_000_000) as bus:
138
- with can.Notifier([bus], listeners=[print_listener, csv_listener]):
135
+ with can.Notifier([bus], listeners=[can.Printer(), can.Logger("log.csv")]):
139
136
 
140
137
  # Perform other tasks here while frames are received in the background
141
138
  sleep(10)
@@ -186,12 +183,14 @@ The common argument pattern for the CANsub:
186
183
  --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000
187
184
  ```
188
185
 
186
+ Note that the *filter* argument supported by some command-line tools is limited to standard (11-bit) CAN IDs. Filtering on extended (29-bit) IDs requires the python-can API.
187
+
189
188
  ### can_logger
190
189
 
191
- Log received frames to a file (CSV by default; format inferred from file extension):
190
+ Log received frames to a file (format inferred from file extension):
192
191
 
193
192
  ```bash
194
- can_logger --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000 --output-file log.csv
193
+ can_logger --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000 --file_name log.csv
195
194
  ```
196
195
 
197
196
  ### can_player
@@ -210,13 +209,15 @@ Live terminal viewer showing received frames, updated counts, timestamps, and by
210
209
  can_viewer --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000
211
210
  ```
212
211
 
212
+ On Windows, the can_viewer requires `windows-curses` (`pip install windows-curses`).
213
+
213
214
  ### can_bridge
214
215
 
215
216
  Forward all frames received on one bus to another (e.g. bridge two CANsub channels):
216
217
 
217
218
  ```bash
218
- can_bridge --interface cansub --channel aabbccdd-usb.local@1 --bitrate 250000 --data-bitrate 1000000 \
219
- --interface2 cansub --channel2 aabbccdd-usb.local@2 --bitrate2 250000 --data-bitrate2 1000000
219
+ can_bridge --bus1-interface cansub --bus1-channel aabbccdd-usb.local@1 --bus1-bitrate 250000 --bus1-data-bitrate 1000000 \
220
+ --bus2-interface cansub --bus2-channel aabbccdd-usb.local@2 --bus2-bitrate 250000 --bus2-data-bitrate 1000000
220
221
  ```
221
222
 
222
223
  ### can_logconvert
@@ -2,6 +2,8 @@
2
2
 
3
3
  This project uses a **private repository for development** and a **public repository for cleaned releases**.
4
4
 
5
+ The private repository is hosted on Bitbucket while the public repository is hosted on GitHub (https://github.com/CSS-Electronics/python-can-cansub).
6
+
5
7
  ## Branches
6
8
 
7
9
  ### `master`
@@ -50,7 +52,7 @@ The public repository remote is not kept configured permanently.
50
52
  Push only when intentionally publishing:
51
53
 
52
54
  ```bash
53
- git push git@github.com:YOUR_USER/YOUR_PUBLIC_REPO.git public-master:master
55
+ git push git@github.com:CSS-Electronics/python-can-cansub.git public-master:master
54
56
  ```
55
57
 
56
58
  This pushes:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-can-cansub"
7
- version = "2026.05.22"
7
+ version = "2026.05.28"
8
8
  authors = [
9
9
  { name="CSS Electronics" },
10
10
  { email="contact@csselectronics.com" },
@@ -132,7 +132,7 @@ class CanSub(can.BusABC):
132
132
  del error_frames
133
133
 
134
134
  # Set channel info (required by python-can)
135
- self.channel_info = f"CANSUB{self.channel}"
135
+ self.channel_info = f"{address}@{self.channel}"
136
136
 
137
137
  # Path to device root certificate
138
138
  self.cansub_cert = str(Path(__file__).with_name("cansub_root_cert.crt"))
@@ -453,9 +453,6 @@ class CanSub(can.BusABC):
453
453
  if timeout is not None and timeout < 0:
454
454
  raise can.exceptions.CanOperationError("Invalid timeout value")
455
455
 
456
- if not (msg.channel is None or msg.channel == self.channel):
457
- raise can.exceptions.CanOperationError("Invalid channel")
458
-
459
456
  try:
460
457
  if timeout is None:
461
458
  # Wait indefinitely for queue space
@@ -474,7 +471,7 @@ class CanSub(can.BusABC):
474
471
  """
475
472
  See "recv" and "_recv_internal" in can.BusABC
476
473
 
477
- Always return that message has already been filtered.
474
+ Always return that the message has already been filtered.
478
475
  """
479
476
  if timeout is not None and timeout < 0:
480
477
  raise can.exceptions.CanOperationError("Invalid timeout value")
@@ -531,9 +528,6 @@ class CanSub(can.BusABC):
531
528
  self.can_send_queue.queue.clear()
532
529
 
533
530
  def _apply_filters(self, filters: Optional[can.typechecking.CanFilters]) -> None:
534
- """
535
- NOTE: This python-can function does not take channel information (applies provided filters to all channels)
536
- """
537
531
 
538
532
  # Python-can specify that all messages should be accepted if filters are None or empty list
539
533
  if filters is None or len(filters) == 0:
@@ -542,13 +536,13 @@ class CanSub(can.BusABC):
542
536
  can.typechecking.CanFilter(extended=True, can_id=0, can_mask=0) # Accept all ext messages
543
537
  ]
544
538
 
545
- # Change to CanSubHwFilter type
546
- can_hw_filters = [CanSubHwFilter(is_extended=x["extended"],
539
+ # Change to CanSubHwFilter type. When "extended" field not provided, default to False (required by cmd-tools)
540
+ can_hw_filters = [CanSubHwFilter(is_extended=x.get("extended", False),
547
541
  is_range=False,
548
542
  f1=x["can_id"],
549
543
  f2=x["can_mask"]) for x in filters]
550
544
 
551
- # Apply filters to all channels
545
+ # Apply hardware filter
552
546
  self.set_hw_filters(can_hw_filters)
553
547
 
554
548
  def set_hw_filters(self, can_hw_filters: Optional[CanSubHwFilters]) -> None: