OpenJBOD / software

MIT License
30 stars 2 forks source link

Implement USB Follow Logic #8

Closed TheGuyDanish closed 2 days ago

TheGuyDanish commented 2 months ago

At the moment, enabling the USB follow (or the on boot) option(s) does not do anything.

The main reason for this is because the USB follow function can invoke a race-like condition. If the USB power disappears for a second, it may cause the device to start a power off sequence, when really, the device might already be booting and starting to address the drives.

The solution to this is to implement a simple check using a global variable to decide if the process should go ahead.

For example:

interrupt_operation = False

def usb_power_off(pin):
  if CONFIG['power']['follow_usb_delay']:
    time.sleep(CONFIG['power']['follow_usb_delay'])
  # Wait 1 second, for safety.
  time.sleep(1)
  if interrupt_operation:
    continue
  else:
    psu.off()
chrisallen commented 5 days ago

I am excited for this feature. It will mean that the enclosure can be auto-powered on when the main NAS starts etc.