Skip to content

Commit

Permalink
serial: check for known incorrect rockpi serials
Browse files Browse the repository at this point in the history
- check for known incorrect rockpi serials
- add more tests for serial number determination

Relates-to: #507 
Relates-to: #632 
Relates-to: #630
  • Loading branch information
shawaj committed Jun 30, 2023
1 parent 16b483c commit eeb3f95
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion hw_diag/utilities/hardware.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dbus
import os
import psutil
import string
from typing import Union
from urllib.parse import urlparse
from hm_pyhelper.logger import get_logger
Expand Down Expand Up @@ -78,6 +79,19 @@
DTPARAM_CONFIG_VAR_NAMES = ['BALENA_HOST_CONFIG_dtparam', 'RESIN_HOST_CONFIG_dtparam']
EXT_ANT_DTPARAM = '"ant2"'

INCORRECT_ROCKPI_SERIALS = [
'W1EP3DN9PU',
'0UQMAKIBII',
'PN06893W5V',
'KLOFHWLY95',
'3IT1I4E9TG',
'CKHZ4CHI1P',
'I4YE1UGF5N',
'PERTSKMCT0',
'S63QCF54CJ',
'YYMSYLJWG8'
]


def should_display_lte(diagnostics):
variant = diagnostics.get('VA')
Expand Down Expand Up @@ -275,11 +289,22 @@ def has_valid_serial(cpuinfo: dict) -> bool:
if CPUINFO_SERIAL_KEY not in cpuinfo:
return False

# Check if serial number is all 0s...
serial_number = cpuinfo[CPUINFO_SERIAL_KEY]

# Check if serial number is all 0s...
if all(c in '0' for c in str(serial_number)):
return False

# Check if serial number is a known incorrect ROCKPi serial
# in INCORRECT_ROCKPI_SERIALS...
if str(serial_number) in INCORRECT_ROCKPI_SERIALS:
return False

# Check if serial number is 10 characters and non-hexadecimal...
if len(str(serial_number)) == 10 and not all(
c in string.hexdigits for c in str(serial_number)):
return False

return True


Expand Down

0 comments on commit eeb3f95

Please sign in to comment.