Prevented dictionary overwrite during data collection

This commit is contained in:
madrigal 2025-09-17 23:11:40 -04:00
parent dd8f47ca05
commit 31520e6176

View File

@ -47,10 +47,10 @@ def get_modem_cops(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
dictionary["cops encoded"] = str(item)
print(f"Could not decode COPS item:\t{str(item)}\n{e}")
return dictionary
except Exception as e:
return {"COPS error": f"{e}"}
dictionary["cops error"] = f"{e}"
return dictionary
# Fetch network registration status (5.2)
@ -77,10 +77,10 @@ def get_modem_creg(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
dictionary["creg encoded"] = decoded_item
print(f"Could not decode CREG item:\t{decoded_item}\n{e}")
return dictionary
except Exception as e:
return {"CREG error": f"{e}"}
dictionary["creg error"] = f"{e}"
return dictionary
# Fetch modem csq stats (5.9)
@ -108,10 +108,10 @@ def get_modem_csq(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
dictionary["csq encoded"] = decoded_item
print(f"Could not decode CSQ item:\t{decoded_item}\n{e}")
return dictionary
except Exception as e:
return {"CSQ error": f"{e}"}
dictionary["csq error"] = f"{e}"
return dictionary
# Fetch RSRP (5.10)
@ -148,10 +148,10 @@ def get_modem_rsrp(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
dictionary["qrsrp encoded"] = decoded_item
print(f"Could not decode QRSRP item:\t{decoded_item}\n{e}")
return dictionary
except Exception as e:
return {"QRSRP error": f"{e}"}
dictionary["qrsrp error"] = f"{e}"
return dictionary
# Fetch RSRQ (5.11)
@ -188,10 +188,10 @@ def get_modem_rsrq(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
dictionary["qrsrq encoded"] = decoded_item
print(f"Could not decode QRSRQ item:\t{decoded_item}\n{e}")
return dictionary
except Exception as e:
return {"QRSRQ error": f"{e}"}
dictionary["qrsrq error"] = f"{e}"
return dictionary
# Fetch SINR of the current service network (5.12)
@ -227,10 +227,10 @@ def get_modem_sinr(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
dictionary["qsinr encoded"] = decoded_item
print(f"Could not decode QSINR item:\t{decoded_item}\n{e}")
return dictionary
except Exception as e:
return {"QSINR error": f"{e}"}
dictionary["qsinr error"] = f"{e}"
return dictionary
# Fetch the list of preferred operators (5.13)
@ -269,10 +269,10 @@ def get_modem_cpol(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
dictionary["cpol encoded"] = decoded_item
print(f"Could not decode CPOL item:\t{decoded_item}\n{e}")
return dictionary
except Exception as e:
return {"CPOL error": f"{e}"}
dictionary["cpol error"] = f"{e}"
return dictionary
# Fetch network parameters (5.21.4)
@ -308,10 +308,10 @@ def get_modem_qnwcfg(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
dictionary["qnwcfg encoded"] = decoded_item
print(f"Could not decode QNWCFG item:\t{decoded_item}\n{e}")
return dictionary
except Exception as e:
return {"QNWCFG error": f"{e}"}
dictionary["qnwcfg error"] = f"{e}"
return dictionary
# Fetch network information (5.18)
@ -335,10 +335,11 @@ def get_modem_qnwinfo(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
except Exception as e:
dictionary["qnwinfo encoded"] = str(item)
print(f"Could not decode QNWINFO item:\t{str(item)}\n{e}")
return dictionary
except Exception as e:
return {"QNWINFO error": f"{e}"}
dictionary["qnwinfo error"] = f"{e}"
return dictionary
# Fetch servie provider name (5.19)
@ -362,7 +363,8 @@ def get_modem_qspn(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
except Exception as e:
dictionary["qspn encoded"] = str(item)
print(f"Could not decode QSPN item:\t{str(item)}\n{e}")
return dictionary
except Exception as e:
return {"QSPN error": f"{e}"}
dictionary["qspn error"] = f"{e}"
return dictionary