major rewrite

This commit is contained in:
2025-09-24 01:32:20 -05:00
parent c332748f44
commit 41413d72fd
21 changed files with 341 additions and 139 deletions

View File

@@ -6,10 +6,11 @@ import binascii
import math
import time
import logging,coloredlogs
from pathlib import Path
# Open the config file and make it accessible via "cfg"
import json
with open("conf.json", "r") as file:
with open("config.json", "r") as file:
cfg = json.load(file)
l = logging.getLogger(__name__)
@@ -34,14 +35,22 @@ def sendFile(files, commands, numSgmts, Pri):
else:
l.critical("Invalid Priority Flag. 0 = Routine Message 1 = High Priority Message\n\nScript will now terminate...")
exit()
#Get the next message ID
with open('./.temp/msgId.txt', "r") as f:
# Create msgId if it doesn't exist
msg_id_file = Path('./.temp/msgId.txt')
if not os.path.exists(msg_id_file):
msg_id_file_p = Path('./.temp/msgId.txt')
msg_id_file_p.parent.mkdir(exist_ok=True, parents=True)
msg_id_file_p.write_text("1")
# Get the next message ID
with open(msg_id_file, "r") as f:
oMsgId = f.read()
msgNum = int(oMsgId)
f.close()
nMsgNum = msgNum + 1
h = open('./.temp/msgId.txt', "w")
h = open(msg_id_file, "w")
h.write(str(nMsgNum))
h.close()
segnmNum = 0
@@ -126,14 +135,22 @@ def sendCommand(command, Pri, msgNum = None):
else:
l.critical("Invalid Priority Flag. 0 = Routine Message 1 = High Priority Message\n\nScript will now terminate...")
exit()
#Get the next message ID
with open('./.temp/msgId.txt', "r") as f:
# Create msgId if it doesn't exist
msg_id_file = Path('./.temp/msgId.txt')
if not os.path.exists(msg_id_file):
msg_id_file_p = Path('./.temp/msgId.txt')
msg_id_file_p.parent.mkdir(exist_ok=True, parents=True)
msg_id_file_p.write_text("1")
# Get the next message ID
with open(msg_id_file, "r") as f:
oMsgId = f.read()
msgNum = int(oMsgId)
f.close()
nMsgNum = msgNum + 1
h = open('./.temp/msgId.txt', "w")
h = open(msg_id_file, "w")
h.write(str(nMsgNum))
h.close()
segnmNum = 0
@@ -174,7 +191,7 @@ def sendCommand(command, Pri, msgNum = None):
p1 = struct.pack(">BHHHIIBBBBBBBIBIBBB", 18, 1, 0 , 16, msgNum, 0, segnmNum, 0, 0, 8, numSegments, 3, 0, 0, 8, packRounded, 0, 0, 0)
conn.sendto(p1, (MCAST_GRP, MCAST_PORT))
startFlag = True
with open('./.temp/Command',"rb") as message:
with open('./.temp/command',"rb") as message:
message.seek(0)
data = message.read(BUF_SIZE)
while data: