Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Jan 12, 2024
1 parent ee2fc59 commit 6591449
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
38 changes: 19 additions & 19 deletions spf/grbl_sdr_collect_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,22 @@ def read_forever(self):


def grbl_thread_runner(gm, routine):
direction = None
global run_collection
while run_collection:
logging.info("GRBL thread runner")
try:
if routine in gm.routines:
logging.info(f"RUNNING ROUTINE {routine}")
gm.routines[routine]()
else:
raise ValueError(f"Unknown grbl routine f{routine}")
except Exception as e:
logging.error(e)
if routine is None:
logging.info("No routine to run, just spining")
while run_collection:
time.sleep(0.5)
else:
try:
if routine in gm.routines:
logging.info(f"RUNNING ROUTINE {routine}")
gm.routines[routine]()
else:
raise ValueError(f"Unknown grbl routine f{routine}")
except Exception as e:
logging.error(e)
if not run_collection:
break
logging.info("GRBL thread runner loop")
Expand All @@ -174,11 +178,7 @@ def grbl_thread_runner(gm, routine):
required=False,
)
parser.add_argument(
"-r",
"--routine",
type=str,
help="GRBL routine",
required=True,
"-r", "--routine", type=str, help="GRBL routine", required=False, default=None
)
parser.add_argument(
"-s",
Expand All @@ -198,14 +198,14 @@ def grbl_thread_runner(gm, routine):
)
args = parser.parse_args()


run_started_at = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
# read YAML
with open(args.yaml_config, "r") as stream:
yaml_config = yaml.safe_load(stream)

# add in our current config
yaml_config['routine']=args.routine
if args.routine is not None:
yaml_config["routine"] = args.routine

output_files_prefix = f"wallarrayv2_{run_started_at}_nRX{len(yaml_config['receivers'])}_{yaml_config['routine']}"

Expand All @@ -218,7 +218,7 @@ def grbl_thread_runner(gm, routine):
format="%(asctime)s:%(levelname)s:%(message)s",
level=getattr(logging, args.logging_level.upper(), None),
)
if args.grbl_serial==None:
if args.grbl_serial is None:
logging.info("Running without GRBL SERIAL!!")
for x in range(50):
if not run_collection:
Expand Down Expand Up @@ -292,7 +292,7 @@ def grbl_thread_runner(gm, routine):
)
if pplus_rx is None or pplus_tx is None:
logging.info("Failed to bring RXTX online, shuttingdown")
run_collection=False
run_collection = False
break
else:
logging.debug("RX online!")
Expand Down Expand Up @@ -349,7 +349,7 @@ def grbl_thread_runner(gm, routine):
time_offset = time.time()
if run_collection:
for pplus_rx in receiver_pplus:
if pplus_rx == None:
if pplus_rx is None:
continue
read_thread = ThreadedRX(
pplus_rx, time_offset, nthetas=yaml_config["n-thetas"]
Expand Down
1 change: 1 addition & 0 deletions spf/v2_configs/wall_array_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ n-thetas: 65
n-records-per-receiver: 300000
width: 4000
calibration-frames: 800
routine: null
2 changes: 1 addition & 1 deletion spf/v2_configs/wall_array_v2_noserial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ output-file: wallarrayv2___DATE__.npy
n-thetas: 65
n-records-per-receiver: 300000
width: 4000
routine: v1_calibrate
routine: null

0 comments on commit 6591449

Please sign in to comment.