aj090-hw-tools 0.0.6__tar.gz → 0.0.7__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 aj090-hw-tools might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aj090-hw-tools
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Project-URL: Documentation, https://github.com/Vasencheg/aj090-hw-tools#readme
5
5
  Project-URL: Issues, https://github.com/Vasencheg/aj090-hw-tools/issues
6
6
  Project-URL: Source, https://github.com/Vasencheg/aj090-hw-tools
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2025-present Vasencheg <roman.vasilev@nobitlost.com>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.0.6"
4
+ __version__ = "0.0.7"
@@ -0,0 +1,2 @@
1
+ SERIAL_NUM_PATTERN = r'\w\d{10}'
2
+ SERIAL_INPUT_PATTERN = r'\d{10}'
@@ -58,7 +58,7 @@ async def device_info_get(dut: DUT) -> Optional[DeviceInfo]:
58
58
  # MAC: 64:E8:33:48:EF:C4
59
59
  # serial: XXXXXXXX
60
60
  MATCH_PATTERN = re.compile(
61
- r'DEVICE_INFO:\s+app version:\s+(\w{{7}})\s+compile time:\s+(\d{{2}}:\d{{2}}:\d{{2}})\s+sha256:\s+(\w{{64}})\s+hw version:\s+(\d{{1}}\.\d{{1}})\s+MAC:\s+(\w{{2}}:\w{{2}}:\w{{2}}:\w{{2}}:\w{{2}}:\w{{2}})\s+serial:\s+({SERIAL_NUM_PATTERN})'.format(SERIAL_NUM_PATTERN=SERIAL_NUM_PATTERN)
61
+ r'DEVICE_INFO:\s+app version:\s+(\w{{7}}|\w{{7}}-dirty)\s+compile time:\s+(\d{{2}}:\d{{2}}:\d{{2}})\s+sha256:\s+(\w{{64}})\s+hw version:\s+(\d{{1}}\.\d{{1}})\s+MAC:\s+(\w{{2}}:\w{{2}}:\w{{2}}:\w{{2}}:\w{{2}}:\w{{2}})\s+serial:\s+({SERIAL_NUM_PATTERN})'.format(SERIAL_NUM_PATTERN=SERIAL_NUM_PATTERN)
62
62
  )
63
63
  result = await dut.expect([MATCH_PATTERN, pexpect.TIMEOUT], timeout=5.0, async_=True)
64
64
  if result:
@@ -10,7 +10,7 @@ import time
10
10
  from esptool.cmds import detect_chip
11
11
  from rich.console import Console
12
12
 
13
- from ..common.const import SERIAL_NUM_PATTERN
13
+ from ..common.const import SERIAL_INPUT_PATTERN
14
14
 
15
15
  __all__ = [
16
16
  'serial'
@@ -44,14 +44,24 @@ async def nvs_write(device, bin_file: str, offset: int = 0x11000) -> None:
44
44
  loop = asyncio.get_running_loop()
45
45
  return await loop.run_in_executor(None, _write)
46
46
 
47
- async def serial_write(device, serial: str) -> int:
48
- match = re.search(SERIAL_NUM_PATTERN, serial)
47
+ def check_serial(serial: str) -> int:
48
+ INPUT_SERIAL="""Serial number format: YYWWXXXXXX, where:
49
+ YY - 2 digits of the year of manufacture of the product;
50
+ WW - 2 digits of the product production week number;
51
+ XXXXXX - 6 digits of the serial number of the product.
52
+ """
53
+ match = re.search(SERIAL_INPUT_PATTERN, serial)
49
54
  if match is None:
50
- console.print('Wrong serial number format', style='bold red')
55
+ console.print('Wrong serial number format. Must be: YYWWXXXXXX', style='bold red')
56
+ console.print(f'{INPUT_SERIAL}')
51
57
  return -1
52
- serial = match.group(0)
58
+
59
+ return 0
60
+
61
+ async def serial_write(device, device_type: str, serial: str) -> int:
62
+ type = 'S' if device_type == "shelf" else "C"
53
63
  with tempfile.NamedTemporaryFile(suffix='.csv') as nvs_csv:
54
- data = bytes(nvs_partition_template(True, '1.0', serial).encode())
64
+ data = bytes(nvs_partition_template(True, '1.0', f'{type}{serial}').encode())
55
65
  nvs_csv.write(data)
56
66
  nvs_csv.seek(0)
57
67
  logger.debug(f'CSV file data: {nvs_csv.read()}')
@@ -71,6 +81,8 @@ async def serial_read() -> int:
71
81
  return -1
72
82
 
73
83
  def serial(argv) -> int:
84
+ if check_serial(argv.serial):
85
+ return -1
74
86
  port = argv.port if argv.port is not None else esptool.ESPLoader.DEFAULT_PORT
75
87
  connects = 10 # NOTE: the workaround to the issue "Could not open /dev/tty..., the port is busy or doesn't exist"
76
88
  for _ in range(connects):
@@ -78,7 +90,7 @@ def serial(argv) -> int:
78
90
  with detect_chip(port=port, connect_attempts=0) as device:
79
91
  match argv.operation:
80
92
  case 'write':
81
- return asyncio.run(serial_write(device, argv.serial))
93
+ return asyncio.run(serial_write(device, argv.device, argv.serial))
82
94
  case 'read':
83
95
  return asyncio.run(serial_read(device))
84
96
  case _:
@@ -1 +0,0 @@
1
- SERIAL_NUM_PATTERN = r'\d\d{2}\d{2}\d\d{4}'
File without changes