Skip to content
Snippets Groups Projects
Commit 0d789b20 authored by Daalen, Tim van's avatar Daalen, Tim van
Browse files

diskspace check debug

parent ab709f36
Branches
No related tags found
No related merge requests found
......@@ -15,7 +15,8 @@ class take_img(Thread):
self._running = True
self.save_IMGS = CONFIG['save-IMGS']
self.save_GPS = CONFIG['save-GPS']
self.usb = USB_class()
self.usb = USB_class(CONFIG['save-every-x'])
# connecting to the first available camera
self.camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
......
......@@ -15,8 +15,8 @@ logging: False
GPS: True
Camera: True
AGENSO: True
save-GPS: False
save-IMGS: False
save-GPS: True
save-IMGS: True
save-every-x: 10 #dont save all imgs & GPS coordinates, its simply to much
#folders
......
......@@ -23,7 +23,8 @@ class USB_class:
self.UUID = None #UUID of the disk
self.reconnect()
self.free_USBGBs = self.check_free_diskspace()
self.writenum = 0 #counter to avoid checking diskspace for every call
self.writeIMg_cnt = 0 #counter to avoid checking diskspace for every call
self.writeGPS_cnt = 0
self.save_frequency = save_frequency
#need sudo rights for these folders...
......@@ -153,15 +154,15 @@ class USB_class:
if not self.reconnect():
return
file_dir = os.path.join(MOUNT_DIR, IMG_folder, subfolder)
self.writenum = self.writenum + 1
self.writeIMg_cnt = self.writeIMg_cnt + 1
try:
#avoid overflowing the disk, we save one/x files and check the diskspace every 50 files.
if self.writenum %(self.save_frequency*50) == 0:
if self.writeIMg_cnt %(self.save_frequency*50) == 0:
self.free_USBGBs = self.check_free_diskspace()
self.writenum = 0
self.writeIMg_cnt = 0
if self.free_USBGBs < 0.1:
return
elif self.writenum % save_frequency:
elif self.writeIMg_cnt % self.save_frequency == 0:
#create subfolder if it not there yet & save image
if not self.check_direxists(file_dir):
raise Exception("disk not connected")
......@@ -179,15 +180,15 @@ class USB_class:
if self.UUID == None:
if not self.reconnect():
return
self.writenum = self.writenum + 1
self.writeGPS_cnt = self.writeGPS_cnt + 1
try:
#avoid overflowing the disk
if self.writenum %(self.save_frequency*50) == 0:
if self.writeGPS_cnt %(self.save_frequency*50) == 0:
self.free_USBGBs = self.check_free_diskspace()
self.writenum = 0
self.writeGPS_cnt = 0
if self.free_USBGBs < 0.1:
return
elif self.writenum % save_frequency:
elif self.writeGPS_cnt % self.save_frequency ==0:
with open(os.path.join(MOUNT_DIR, GPS_folder, (filename + ".txt")), "a") as file:
file.write(data_string)
except Exception as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment