Tici hardware abstraction layer (#2183)
* rename android hardware
* add tici class
* elif
* read correct serial number
* Update release files
* Get IMEI
* Refactor AT command
* move get_cmdline into base class
* Remove unused import
* Small cleanup
old-commit-hash: c90cb1b529
commatwo_master
parent
398796a010
commit
d455516765
5 changed files with 71 additions and 2 deletions
@ -0,0 +1,58 @@ |
|||||||
|
import serial |
||||||
|
|
||||||
|
from common.hardware_base import HardwareBase |
||||||
|
from cereal import log |
||||||
|
|
||||||
|
|
||||||
|
NetworkType = log.ThermalData.NetworkType |
||||||
|
NetworkStrength = log.ThermalData.NetworkStrength |
||||||
|
|
||||||
|
|
||||||
|
def run_at_command(cmd, timeout=0.1): |
||||||
|
with serial.Serial("/dev/ttyUSB2", timeout=timeout) as ser: |
||||||
|
ser.write(cmd + b"\r\n") |
||||||
|
ser.readline() # Modem echos request |
||||||
|
return ser.readline().decode().rstrip() |
||||||
|
|
||||||
|
|
||||||
|
class Tici(HardwareBase): |
||||||
|
def get_sound_card_online(self): |
||||||
|
return True |
||||||
|
|
||||||
|
def get_imei(self, slot): |
||||||
|
if slot != 0: |
||||||
|
return "" |
||||||
|
|
||||||
|
for _ in range(10): |
||||||
|
try: |
||||||
|
imei = run_at_command(b"AT+CGSN") |
||||||
|
if len(imei) == 15: |
||||||
|
return imei |
||||||
|
except serial.SerialException: |
||||||
|
pass |
||||||
|
|
||||||
|
raise RuntimeError("Error getting IMEI") |
||||||
|
|
||||||
|
def get_serial(self): |
||||||
|
return self.get_cmdline()['androidboot.serialno'] |
||||||
|
|
||||||
|
def get_subscriber_info(self): |
||||||
|
return "" |
||||||
|
|
||||||
|
def reboot(self, reason=None): |
||||||
|
print("REBOOT!") |
||||||
|
|
||||||
|
def get_network_type(self): |
||||||
|
return NetworkType.wifi |
||||||
|
|
||||||
|
def get_sim_info(self): |
||||||
|
return { |
||||||
|
'sim_id': '', |
||||||
|
'mcc_mnc': None, |
||||||
|
'network_type': ["Unknown"], |
||||||
|
'sim_state': ["ABSENT"], |
||||||
|
'data_connected': False |
||||||
|
} |
||||||
|
|
||||||
|
def get_network_strength(self, network_type): |
||||||
|
return NetworkStrength.unknown |
Loading…
Reference in new issue