| Line 691... |
Line 691... |
| 691 |
def storage_read_sectors_md(self, volume, sector, count, addr):
|
691 |
def storage_read_sectors_md(self, volume, sector, count, addr):
|
| 692 |
""" Read sectors from as storage device """
|
692 |
""" Read sectors from as storage device """
|
| 693 |
self.logger.debug("Reading %d sectors from disk at volume %d, sector %d to memory at 0x%X\n" % (count, volume, sector, addr))
|
693 |
self.logger.debug("Reading %d sectors from disk at volume %d, sector %d to memory at 0x%X\n" % (count, volume, sector, addr))
|
| 694 |
result = self.lib.monitorcommand(struct.pack("<IIQIIII", 28, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
694 |
result = self.lib.monitorcommand(struct.pack("<IIQIIII", 28, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
| 695 |
self.logger.debug("Read sectors, result: 0x%X\n" % result.rc)
|
695 |
self.logger.debug("Read sectors, result: 0x%X\n" % result.rc)
|
| - |
|
696 |
self.logger.info(".");
|
| 696 |
if result.rc > 0x80000000:
|
697 |
# if result.rc > 0x80000000:
|
| 697 |
raise DeviceError("storage_read_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, rc))
|
698 |
# raise DeviceError("storage_read_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, result.rc))
|
| 698 |
|
699 |
|
| 699 |
@command(timeout = 50000)
|
700 |
@command(timeout = 50000)
|
| 700 |
def storage_write_sectors_md(self, volume, sector, count, addr):
|
701 |
def storage_write_sectors_md(self, volume, sector, count, addr):
|
| 701 |
""" Read sectors from as storage device """
|
702 |
""" Read sectors from as storage device """
|
| 702 |
self.logger.debug("Writing %d sectors from memory at 0x%X to disk at volume %d, sector %d\n" % (count, addr, volume, sector))
|
703 |
self.logger.debug("Writing %d sectors from memory at 0x%X to disk at volume %d, sector %d\n" % (count, addr, volume, sector))
|
| 703 |
result = self.lib.monitorcommand(struct.pack("<IIQIIII", 29, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
704 |
result = self.lib.monitorcommand(struct.pack("<IIQIIII", 29, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
| 704 |
self.logger.debug("Wrote sectors, result: 0x%X\n" % result.rc)
|
705 |
self.logger.debug("Wrote sectors, result: 0x%X\n" % result.rc)
|
| - |
|
706 |
self.logger.info(".");
|
| 705 |
if result.rc > 0x80000000:
|
707 |
# if result.rc > 0x80000000:
|
| 706 |
raise DeviceError("storage_write_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, rc))
|
708 |
# raise DeviceError("storage_write_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, result.rc))
|
| 707 |
|
709 |
|
| 708 |
@command(timeout = 30000)
|
710 |
@command(timeout = 30000)
|
| 709 |
def fat_enable_flushing(self, state):
|
711 |
def fat_enable_flushing(self, state):
|
| 710 |
""" Enables/disables flushing the FAT cache after every transaction """
|
712 |
""" Enables/disables flushing the FAT cache after every transaction """
|
| 711 |
if state != 0: self.logger.debug("Enabling FAT flushing\n")
|
713 |
if state != 0: self.logger.debug("Enabling FAT flushing\n")
|
| Line 715... |
Line 717... |
| 715 |
else: self.logger.debug("Disabled FAT flushing\n")
|
717 |
else: self.logger.debug("Disabled FAT flushing\n")
|
| 716 |
|
718 |
|
| 717 |
@command(timeout = 30000)
|
719 |
@command(timeout = 30000)
|
| 718 |
def file_open(self, filename, mode):
|
720 |
def file_open(self, filename, mode):
|
| 719 |
""" Opens a file and returns the handle """
|
721 |
""" Opens a file and returns the handle """
|
| - |
|
722 |
fn = filename.encode("utf_8")
|
| 720 |
self.logger.debug("Opening remote file %s with mode %d\n" % (filename, mode))
|
723 |
self.logger.debug("Opening remote file %s with mode %d\n" % (filename, mode))
|
| 721 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(filename), 30, mode, 0, 0, filename, 0), "III", ("fd", None, None))
|
724 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(fn), 30, mode, 0, 0, fn, 0), "III", ("fd", None, None))
|
| 722 |
if result.fd > 0x80000000:
|
725 |
if result.fd > 0x80000000:
|
| 723 |
raise DeviceError("file_open(filename=\"%s\", mode=0x%X) failed with RC=0x%08X, errno=%d" % (filename, mode, result.fd, self.errno()))
|
726 |
raise DeviceError("file_open(filename=\"%s\", mode=0x%X) failed with RC=0x%08X, errno=%d" % (filename, mode, result.fd, self.errno()))
|
| 724 |
self.logger.debug("Opened file as handle 0x%X\n" % result.fd)
|
727 |
self.logger.debug("Opened file as handle 0x%X\n" % result.fd)
|
| 725 |
return result.fd
|
728 |
return result.fd
|
| 726 |
|
729 |
|
| Line 825... |
Line 828... |
| 825 |
return result.rc
|
828 |
return result.rc
|
| 826 |
|
829 |
|
| 827 |
@command(timeout = 30000)
|
830 |
@command(timeout = 30000)
|
| 828 |
def file_unlink(self, filename):
|
831 |
def file_unlink(self, filename):
|
| 829 |
""" Removes a file """
|
832 |
""" Removes a file """
|
| - |
|
833 |
fn = filename.encode("utf_8")
|
| 830 |
self.logger.debug("Deleting file %s\n" % (filename))
|
834 |
self.logger.debug("Deleting file %s\n" % (filename))
|
| 831 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(filename), 40, 0, 0, 0, filename, 0), "III", ("rc", None, None))
|
835 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(fn), 40, 0, 0, 0, fn, 0), "III", ("rc", None, None))
|
| 832 |
if result.rc > 0x80000000:
|
836 |
if result.rc > 0x80000000:
|
| 833 |
raise DeviceError("file_unlink(filename=\"%s\") failed with RC=0x%08X, errno=%d" % (filename, result.rc, self.errno()))
|
837 |
raise DeviceError("file_unlink(filename=\"%s\") failed with RC=0x%08X, errno=%d" % (filename, result.rc, self.errno()))
|
| 834 |
self.logger.debug("Delete file result: 0x%X\n" % (result.rc))
|
838 |
self.logger.debug("Delete file result: 0x%X\n" % (result.rc))
|
| 835 |
return result.rc
|
839 |
return result.rc
|
| 836 |
|
840 |
|
| 837 |
@command(timeout = 30000)
|
841 |
@command(timeout = 30000)
|
| 838 |
def file_rename(self, oldname, newname):
|
842 |
def file_rename(self, oldname, newname):
|
| 839 |
""" Renames a file """
|
843 |
""" Renames a file """
|
| - |
|
844 |
on = oldname.encode("utf_8")
|
| - |
|
845 |
nn = newname.encode("utf_8")
|
| 840 |
self.logger.debug("Renaming file %s to %s\n" % (oldname, newname))
|
846 |
self.logger.debug("Renaming file %s to %s\n" % (on, nn))
|
| 841 |
result = self.lib.monitorcommand(struct.pack("<IIII248s%dsB" % min(247, len(newname)), 41, 0, 0, 0, oldname, newname, 0), "III", ("rc", None, None))
|
847 |
result = self.lib.monitorcommand(struct.pack("<IIII248s%dsB" % min(247, len(nn)), 41, 0, 0, 0, on, nn, 0), "III", ("rc", None, None))
|
| 842 |
if result.rc > 0x80000000:
|
848 |
if result.rc > 0x80000000:
|
| 843 |
raise DeviceError("file_rename(oldname=\"%s\", newname=\"%s\") failed with RC=0x%08X, errno=%d" % (oldname, newname, result.rc, self.errno()))
|
849 |
raise DeviceError("file_rename(oldname=\"%s\", newname=\"%s\") failed with RC=0x%08X, errno=%d" % (oldname, newname, result.rc, self.errno()))
|
| 844 |
self.logger.debug("Rename file result: 0x%X\n" % (result.rc))
|
850 |
self.logger.debug("Rename file result: 0x%X\n" % (result.rc))
|
| 845 |
return result.rc
|
851 |
return result.rc
|
| 846 |
|
852 |
|
| 847 |
@command(timeout = 30000)
|
853 |
@command(timeout = 30000)
|
| 848 |
def dir_open(self, dirname):
|
854 |
def dir_open(self, dirname):
|
| 849 |
""" Opens a directory and returns the handle """
|
855 |
""" Opens a directory and returns the handle """
|
| - |
|
856 |
dn = dirname.encode("utf_8")
|
| 850 |
self.logger.debug("Opening directory %s\n" % (dirname))
|
857 |
self.logger.debug("Opening directory %s\n" % (dirname))
|
| 851 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(dirname), 42, 0, 0, 0, dirname, 0), "III", ("handle", None, None))
|
858 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(dn), 42, 0, 0, 0, dn, 0), "III", ("handle", None, None))
|
| 852 |
if result.handle == 0:
|
859 |
if result.handle == 0:
|
| 853 |
raise DeviceError("dir_open(dirname=\"%s\") failed with RC=0x%08X, errno=%d" % (dirname, result.handle, self.errno()))
|
860 |
raise DeviceError("dir_open(dirname=\"%s\") failed with RC=0x%08X, errno=%d" % (dirname, result.handle, self.errno()))
|
| 854 |
self.logger.debug("Opened directory as handle 0x%X\n" % (result.handle))
|
861 |
self.logger.debug("Opened directory as handle 0x%X\n" % (result.handle))
|
| 855 |
return result.handle
|
862 |
return result.handle
|
| 856 |
|
863 |
|
| Line 907... |
Line 914... |
| 907 |
return result.rc
|
914 |
return result.rc
|
| 908 |
|
915 |
|
| 909 |
@command(timeout = 30000)
|
916 |
@command(timeout = 30000)
|
| 910 |
def dir_create(self, dirname):
|
917 |
def dir_create(self, dirname):
|
| 911 |
""" Creates a directory """
|
918 |
""" Creates a directory """
|
| - |
|
919 |
dn = dirname.encode("utf_8")
|
| 912 |
self.logger.debug("Creating directory %s\n" % (dirname))
|
920 |
self.logger.debug("Creating directory %s\n" % (dirname))
|
| 913 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(dirname), 47, 0, 0, 0, dirname, 0), "III", ("rc", None, None))
|
921 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(dn), 47, 0, 0, 0, dn, 0), "III", ("rc", None, None))
|
| 914 |
if result.rc > 0x80000000:
|
922 |
if result.rc > 0x80000000:
|
| 915 |
raise DeviceError("dir_create(dirname=\"%s\") failed with RC=0x%08X, errno=%d" % (dirname, result.rc, self.errno()))
|
923 |
raise DeviceError("dir_create(dirname=\"%s\") failed with RC=0x%08X, errno=%d" % (dirname, result.rc, self.errno()))
|
| 916 |
self.logger.debug("Create directory result: 0x%X\n" % (result.rc))
|
924 |
self.logger.debug("Create directory result: 0x%X\n" % (result.rc))
|
| 917 |
return result.rc
|
925 |
return result.rc
|
| 918 |
|
926 |
|
| 919 |
@command(timeout = 30000)
|
927 |
@command(timeout = 30000)
|
| 920 |
def dir_remove(self, dirname):
|
928 |
def dir_remove(self, dirname):
|
| 921 |
""" Removes an (empty) directory """
|
929 |
""" Removes an (empty) directory """
|
| - |
|
930 |
dn = dirname.encode("utf_8")
|
| 922 |
self.logger.debug("Removing directory %s\n" % (dirname))
|
931 |
self.logger.debug("Removing directory %s\n" % (dirname))
|
| 923 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(dirname), 48, 0, 0, 0, dirname, 0), "III", ("rc", None, None))
|
932 |
result = self.lib.monitorcommand(struct.pack("<IIII%dsB" % len(dn), 48, 0, 0, 0, dn, 0), "III", ("rc", None, None))
|
| 924 |
if result.rc > 0x80000000:
|
933 |
if result.rc > 0x80000000:
|
| 925 |
raise DeviceError("dir_remove(dirname=\"%s\") failed with RC=0x%08X, errno=%d" % (dirname, result.rc, self.errno()))
|
934 |
raise DeviceError("dir_remove(dirname=\"%s\") failed with RC=0x%08X, errno=%d" % (dirname, result.rc, self.errno()))
|
| 926 |
self.logger.debug("Remove directory result: 0x%X\n" % (result.rc))
|
935 |
self.logger.debug("Remove directory result: 0x%X\n" % (result.rc))
|
| 927 |
return result.rc
|
936 |
return result.rc
|
| 928 |
|
937 |
|