PyVLCB 0.2.6__tar.gz → 0.2.8__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.
- {pyvlcb-0.2.6/src/PyVLCB.egg-info → pyvlcb-0.2.8}/PKG-INFO +1 -1
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/pyproject.toml +1 -1
- {pyvlcb-0.2.6 → pyvlcb-0.2.8/src/PyVLCB.egg-info}/PKG-INFO +1 -1
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/PyVLCB.egg-info/SOURCES.txt +1 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/pyvlcb/__init__.py +9 -2
- pyvlcb-0.2.8/src/pyvlcb/tests/test_opcodes.py +23 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/pyvlcb/tests/test_vlcb.py +1 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/pyvlcb/vlcbformat.py +4 -3
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/LICENSE +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/README.md +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/setup.cfg +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/PyVLCB.egg-info/dependency_links.txt +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/PyVLCB.egg-info/requires.txt +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/PyVLCB.egg-info/top_level.txt +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/pyvlcb/canusb.py +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/pyvlcb/exceptions.py +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/pyvlcb/tests/run_tests.py +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/pyvlcb/tests/test_canusb4.py +0 -0
- {pyvlcb-0.2.6 → pyvlcb-0.2.8}/src/pyvlcb/utils.py +0 -0
|
@@ -250,9 +250,16 @@ class VLCB:
|
|
|
250
250
|
Returns:
|
|
251
251
|
String: A string for the request
|
|
252
252
|
"""
|
|
253
|
+
|
|
253
254
|
# if ev_id is a string then convert to an int
|
|
254
255
|
# Setting based to 0 will automatically handle base 10 or hex
|
|
255
|
-
|
|
256
|
+
if not isinstance(ev_id, (int, str)):
|
|
257
|
+
raise TypeError(f"Expected int or str, got {type(ev_id).__name__}")
|
|
258
|
+
|
|
259
|
+
# Convert strings (ints are ignored and remain ints)
|
|
260
|
+
if isinstance(ev_id, str):
|
|
261
|
+
ev_id = int(ev_id, 0)
|
|
262
|
+
|
|
256
263
|
# determine if long or short
|
|
257
264
|
if ev_id <= 0xffff:
|
|
258
265
|
return self.accessory_short_command (node_id, ev_id, state)
|
|
@@ -491,4 +498,4 @@ class VLCB:
|
|
|
491
498
|
return f"{self.make_header(opcode='60')}60{num_to_1hexstr(session_id)}{byte1_2[0]}{byte1_2[1]};"
|
|
492
499
|
|
|
493
500
|
|
|
494
|
-
|
|
501
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
from pyvlcb import VLCB, VLCBFormat, VLCBOpcode
|
|
6
|
+
|
|
7
|
+
## Test for VLCB library
|
|
8
|
+
# Test that the OpCodes are formatted correctly (particular the format field)
|
|
9
|
+
class TestOpCodes(unittest.TestCase):
|
|
10
|
+
# Check each of the format entries exist in the field_formats list
|
|
11
|
+
def test_opcode_format(self):
|
|
12
|
+
for thisopcode in VLCBOpcode.opcodes.keys():
|
|
13
|
+
|
|
14
|
+
if VLCBOpcode.opcodes[thisopcode]['format'] == "":
|
|
15
|
+
continue
|
|
16
|
+
field_codes = VLCBOpcode.opcodes[thisopcode]['format'].split(',')
|
|
17
|
+
for this_code in field_codes:
|
|
18
|
+
#print (f"Checking Opcode {thisopcode} format :{this_code}:")
|
|
19
|
+
self.assertTrue(this_code in VLCBOpcode.field_formats.keys())
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == '__main__':
|
|
23
|
+
unittest.main()
|
|
@@ -336,7 +336,7 @@ class VLCBOpcode:
|
|
|
336
336
|
'F9': {'opc': 'ASOF3', 'title': 'Accessory Short OFF', 'format': 'NN,DNHigh_DNLow,Byte1,Byte2,Byte3', 'minpri': 3, 'comment': 'Indicates an OFF event using the short event number of 2 LS bytes with three added data bytes.'},
|
|
337
337
|
'FA': {'opc': 'DDES', 'title': 'Device data event (short mode)', 'format': 'DNHigh_DNLow,Byte1,Byte2,Byte3,Byte4,Byte5', 'minpri': 3, 'comment': 'Function is the same as F6 but uses device addressing so can relate data to a device attached to a node. e.g. one of several RFID readers attached to a single node.'},
|
|
338
338
|
'FB': {'opc': 'DDRS', 'title': 'Device data response (short mode)', 'format': 'DNHigh_DNLow,Byte1,Byte2,Byte3,Byte4,Byte5', 'minpri': 3, 'comment': 'The response to a request for data from a device. (0x5B)'},
|
|
339
|
-
'FC': {'opc': 'DDWS', 'title': 'Write data', 'format': 'DNHigh_DNLow,
|
|
339
|
+
'FC': {'opc': 'DDWS', 'title': 'Write data', 'format': 'DNHigh_DNLow,Byte1,Byte2,Byte3,Byte4,Byte5', 'minpri': 0, 'comment': 'Used to write data to a device such as an RFID tag. For RC522 byte1 should be 0.'},
|
|
340
340
|
'FD': {'opc': 'ARSON3', 'title': 'Accessory Short Response Event', 'format': 'NN,DNHigh_DNLow,Byte1,Byte2,Byte3', 'minpri': 3, 'comment': "Indicates an ON response event with with three added data bytes. A response event is a reply to a status request (ASRQ) without producing an ON or OFF event."},
|
|
341
341
|
'FE': {'opc': 'ARSOF3', 'title': 'Accessory Short Response Event', 'format': 'NN,DNHigh_DNLow,Byte1,Byte2,Byte3', 'minpri': 3, 'comment': "Indicates an OFF response event with with three added data bytes. A response event is a reply to a status request (ASRQ) without producing an ON or OFF event."},
|
|
342
342
|
'FF': {'opc': 'EXTC6', 'title': 'Extended op-code with 6 data bytes', 'format': 'ExtOpc,Byte1,Byte2,Byte3,Byte4,Byte5,Byte6', 'minpri': 3, 'comment': 'Used if the basic set of 32 OPCs is not enough. Allows an additional 256 OPCs'}
|
|
@@ -353,8 +353,9 @@ class VLCBOpcode:
|
|
|
353
353
|
"Consist": [2, "num"], # Consist ID
|
|
354
354
|
"Index": [2, "num"], # Index of loco in consist
|
|
355
355
|
"Status": [2, "hex"],
|
|
356
|
-
"NN": [4, "num"],
|
|
357
|
-
"
|
|
356
|
+
"NN": [4, "num"], # Node number
|
|
357
|
+
"NNIndex": [2, "num"], # Index for the node variable value
|
|
358
|
+
"AllocCode": [2, "num"], # Specific allocation code
|
|
358
359
|
"SpeedDir": [2, "hex"],
|
|
359
360
|
"SpeedFlag": [2, "hex"], # Speed flags DDD-DDDDD
|
|
360
361
|
"Fnum": [2, "num"], # Function number
|
|
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
|