Subversion Repositories freemyipod

Rev

Rev 774 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 774 Rev 778
Line 29... Line 29...
29
import sys
29
import sys
30
import struct
30
import struct
31
import ctypes
31
import ctypes
32
import usb.core
32
import usb.core
33
import base64
33
import base64
-
 
34
import datetime
34
 
35
 
35
from libemcoredata import *
36
from libemcoredata import *
36
from misc import Logger, Bunch, remote_pointer, Error, ArgumentError, getthread, gethwname
37
from misc import Logger, Bunch, remote_pointer, Error, ArgumentError, getthread, gethwname
37
from functools import wraps
38
from functools import wraps
38
 
39
 
Line 950... Line 951...
950
    @command()
951
    @command()
951
    def free_all(self):
952
    def free_all(self):
952
        """ Frees all memory allocations created by the monitor thread """
953
        """ Frees all memory allocations created by the monitor thread """
953
        self.logger.debug("Freeing all memory allocations created by the monitor thread\n")
954
        self.logger.debug("Freeing all memory allocations created by the monitor thread\n")
954
        return self.lib.monitorcommand(struct.pack("<IIII", 57, 0, 0, 0), "III", (None, None, None))
955
        return self.lib.monitorcommand(struct.pack("<IIII", 57, 0, 0, 0), "III", (None, None, None))
-
 
956
    
-
 
957
    @command()
-
 
958
    def rtcread(self):
-
 
959
        """ Reads the real time clock on the device """
-
 
960
        self.logger.debug("Reading the clock\n")
-
 
961
        date = self.lib.monitorcommand(struct.pack("<IIII", 60, 0, 0, 0), "BBBBBBBBI", ("second", "minute", "hour", "weekday", "day", "month", "year", None, None))
-
 
962
        dt = datetime.datetime(date.year + 2000, date.month, date.day, date.hour, date.minute, date.second)
-
 
963
        self.logger.debug("Read date '%s' from device", (dt.ctime()))
-
 
964
        return dt
-
 
965
    
-
 
966
    @command()
-
 
967
    def rtcwrite(self, dt):
-
 
968
        """ Sets the real time clock on the device to the datetime object 'dt' """
-
 
969
        self.logger.debug("Setting the clock to: %s\n" % (dt.ctime()))
-
 
970
        if dt.year < 2000 or dt.year > 2255:
-
 
971
            raise ArgumentError("The Year must be between 2000 and 2255")
-
 
972
        return self.lib.monitorcommand(struct.pack("<IBBBBBBBBI", 61, dt.second, dt.minute, dt.hour, dt.weekday(), dt.day, dt.month, dt.year - 2000, 0, 0), "III", (None, None, None))
955
 
973
 
956
 
974
 
957
class Lib(object):
975
class Lib(object):
958
    def __init__(self, logger):
976
    def __init__(self, logger):
959
        self.logger = logger
977
        self.logger = logger