def check_device_id(self, path, id, level): # check vendor_id cmd = "[ \"$(udevadm info --name={} | grep ID_SERIAL= | cut -d'=' -f2)\" = \"{}\" ]".format( path, id) SystemCheck.print_info("short serial id check ...", level) if not sh.exec_cmd(cmd, level + 1): SystemCheck.print_info("invalid serial_id ... ", level + 1) return False return True
def check(self): SystemCheck.print_high("Target alsa name : " + self.name, 1) cmd = "[ $(pacmd list-sources | grep -e '{}' | wc -l) = 1 ]".format(self.name) SystemCheck.print_info("Checking alsa devices... ", 1) if not sh.exec_cmd(cmd, level=1): SystemCheck.print_error("No connected device matches alsa name.", level=1) return False SystemCheck.print_ok("Device is connected.", 1) return True
def check(self): SystemCheck.print_high("Target alsa name : " + self.name, 1) cmd = "[ $(pacmd list-sources | grep -e '{}' | wc -l) = 1 ]".format( self.name) SystemCheck.print_info("Checking alsa devices... ", 1) if not sh.exec_cmd(cmd, level=1): SystemCheck.print_error("No connected device matches alsa name.", level=1) return False SystemCheck.print_ok("Device is connected.", 1) return True
def check(): mic = SystemCheck("Microphone") mic.add_child( MicCheckTask( "alsa_input.usb-M-Audio_Producer_USB-00-USB.analog-stereo")) return mic.check()
def check(self): symlink = self.symlink_base + self.symlink_name SystemCheck.print_high("Target symlink : " + symlink, 1) # path exists and symlink is not broken if sh.file_exists(symlink): SystemCheck.print_info("Pioneer symlink exists ... ", 1) # check vendor_id cmd = "[ $(udevadm info --name={} | grep ID_VENDOR_ID | cut -d'=' -f2) = {} ]".format( symlink, self.vendor_id) SystemCheck.print_info("vendor_id check ...", 1) if sh.exec_cmd(cmd, level=1): # another check? # SystemCheck.print_ok( "The device is connected and working as desired.", 1) return True # invalid vendor id: seek and repair SystemCheck.print_warn( "Path {} exists, but is assigned to an invalid device ...". format(symlink), 1) else: # link not found: seek SystemCheck.print_warn( "Symlink to the device not found or broken ... ", 1) # delete possible invalid symlink if sh.file_exists_strict(symlink): SystemCheck.print_info("Deleting invalid symlink ... ", 2) if not sh.delete_file(symlink, level=2, use_sudo=True): SystemCheck.print_error("Failed to delete symlink.", 2) return False SystemCheck.print_info("Looking for devices on the system ... ", 1) # display available ports devpaths = sh.get_devpath_list("/dev/ttyUSB") if not devpaths: SystemCheck.print_error( "Could not find any /dev/ttyUSB[0-9] port. Is the base connected?", 2) return False # check each /dev/ttyACM[0-9] port SystemCheck.print_info( "Available ports (/dev/ttyUSB[0-9]): " + str(devpaths), 1) for devpath in devpaths: SystemCheck.print_info( "checking device at {} ... ".format(devpath), 2) # check vendor_id cmd = "[ $(udevadm info --name={} | grep ID_VENDOR_ID | cut -d'=' -f2) = {} ]".format( devpath, self.vendor_id) SystemCheck.print_info("vendor_id check ...", 3) if not sh.exec_cmd(cmd, level=4): SystemCheck.print_info("invalid vendor_id ... ", 4) continue # create symlink SystemCheck.print_high( "Devpath {} matches target id {}. Creating symlink to {} ...". format(devpath, self.id, symlink), 3) if not sh.mkdir_p(self.symlink_base, level=3, use_sudo=True): SystemCheck.print_error( "Failed to create directory: {}".format(self.symlink_base), 3) return False if not sh.create_symlink(devpath, symlink, level=3, use_sudo=True): SystemCheck.print_error( "Failed to create symlink {} -> {}".format( devpath, symlink), 3) return False # OK! SystemCheck.print_ok( "Successfully assigned symlink. Device is ready to use.", 3) return True SystemCheck.print_error( "No connected device matches pioneer p3at vendor_id {}. Is the laser connected?" .format(self.vendor_id), 1) return False
def check(): base = SystemCheck("base") base.add_child(BaseCheckTask()) return base.check()
def head_check(): head = SystemCheck("head") head.add_child(FileCheckTask('/dev/bender/r_port')) head.add_child(DynamixelCheck('/dev/bender/r_port', 200000, [30, 31, 35])) return head.check()
def check(self): SystemCheck.print_high("Target device : " + self.device, 1) SystemCheck.print_high("Target baudrate: %d" % self.baud, 1) try: SystemCheck.print_info("Opening serial port... ", 1) dxl = DynamixelIO(self.device, self.baud) except: SystemCheck.print_error( "Error opening: {} [baud {}]\t\t[FAIL]".format( self.device, self.baud)) return False SystemCheck.print_info("Checking ids : %s" % self.ids, 1) result = True found_device = set() required = set(self.ids) for device_id in self.ids: for trial in range(5): try: result = dxl.ping(device_id) except Exception as ex: SystemCheck.print_error( "Exception thrown while pinging device id {}.\t\t[FAIL]" .format(device_id)) SystemCheck.print_error(str(ex)) if result: SystemCheck.print_ok("Motor id: {}".format(device_id), 2) found_device.add(device_id) break if not required.issubset(found_device): not_found = required.difference(found_device) for device_id in not_found: SystemCheck.print_error( "Motor id: {} not found".format(device_id), 2) result = False return result
def check_id_exec(self): if not sh.file_exists(self.get_id_path): SystemCheck.print_warn( "Program '{}' not found.".format(self.get_id_path), 1) return False return True
def check_rear(): laser = SystemCheck("laser_rear") laser.add_child(LaserCheckTask("H0903381")) return laser.check()
def check_front(): laser = SystemCheck("laser_front") laser.add_child(LaserCheckTask("H1311689")) return laser.check()
def check(self): symlink = self.symlink_prefix + self.linkname SystemCheck.print_high("Target symlink : " + symlink, 1) SystemCheck.print_high("Target camera id : " + self.id, 1) # path exists and symlink is not broken if sh.file_exists(symlink): SystemCheck.print_info("Camera symlink exists ... ", 1) # valid vendor id: ok if self.check_vendor_id(symlink, self.vendor_id, 1) and self.check_device_id( symlink, self.id, 1): SystemCheck.print_ok( "The device is connected and working as desired.", 1) return True # invalid id: seek and repair SystemCheck.print_warn( "Path {} exists, but is assigned to an invalid device ...". format(symlink), 1) else: # link not found: seek SystemCheck.print_warn( "Symlink to the device not found or broken ... ", 1) # delete possible invalid symlink if sh.file_exists_strict(symlink): SystemCheck.print_info("Deleting invalid symlink ... ", 2) if not sh.delete_file(symlink, level=2, use_sudo=True): SystemCheck.print_error("Failed to delete symlink.", 2) return False SystemCheck.print_info("Looking for devices on the system ... ", 1) # display available ports devpaths = sh.get_devpath_list("/dev/video") if not devpaths: SystemCheck.print_error( "Could not find any /dev/video[0-9] port. Is the camera connected?", 2) return False # check each /dev/video[0-9] port SystemCheck.print_info( "Available ports (/dev/video[0-9]): " + str(devpaths), 1) for devpath in devpaths: SystemCheck.print_info( "checking device at {} ... ".format(devpath), 2) # valid vendor id: ok if not self.check_vendor_id(devpath, self.vendor_id, 3): continue # valid device serial number if not self.check_device_id(devpath, self.id, 3): continue # create symlink SystemCheck.print_high( "Devpath {} matches target id {}. Creating symlink to {} ...". format(devpath, self.id, symlink), 3) if not sh.mkdir_p(self.symlink_prefix, level=3, use_sudo=True): SystemCheck.print_error( "Failed to create directory: {}".format( self.symlink_prefix), 3) return False if not sh.create_symlink(devpath, symlink, level=3, use_sudo=True): SystemCheck.print_error( "Failed to create symlink {} -> {}".format( devpath, symlink), 3) return False # OK! SystemCheck.print_ok( "Successfully assigned symlink. Device is ready to use.", 3) return True SystemCheck.print_error( "No connected device matches camera id {}. Is the camera connected?" .format(self.id), 1) return False
def check_selfiecam(): cam = SystemCheck("selfie camera") cam.add_child(CameraCheckTask("selfiecam", "046d_0825_271BA220", "046d")) # cam.add_child(CameraCheckTask("selfiecam", "093a_2622", "093a")) return cam.check()
def check(): mic = SystemCheck("Microphone") mic.add_child(MicCheckTask("alsa_input.usb-M-Audio_Producer_USB-00-USB.analog-stereo")) return mic.check()