| Index: emcore/trunk/tools/emcore.py | 
| — | — | @@ -1322,6 +1322,23 @@ | 
| 1323 | 1323 | self.logger.info("Freeing all memory allocations created by the monitor thread\n") | 
| 1324 | 1324 | self.emcore.free_all() | 
| 1325 | 1325 | self.logger.info("Successfully freed all memory allocations created by the monitor thread\n") | 
|  | 1326 | + | 
|  | 1327 | +    @command | 
|  | 1328 | +    def rtcread(self): | 
|  | 1329 | +        """ Reads the real time clock on the device """ | 
|  | 1330 | +        import datetime | 
|  | 1331 | +        self.logger.info("Reading the clock\n") | 
|  | 1332 | +        dt = self.emcore.rtcread() | 
|  | 1333 | +        self.logger.info("Successfully read the clock: %s\n" % (dt.ctime())) | 
|  | 1334 | + | 
|  | 1335 | +    @command | 
|  | 1336 | +    def rtcwrite(self): | 
|  | 1337 | +        """ Sets the real time clock on the device to the current local time """ | 
|  | 1338 | +        import datetime | 
|  | 1339 | +        dt = datetime.datetime.now() | 
|  | 1340 | +        self.logger.info("Setting the clock to: %s\n" % (dt.ctime())) | 
|  | 1341 | +        self.emcore.rtcwrite(dt) | 
|  | 1342 | +        self.logger.info("Successfully set the clock\n") | 
| 1326 | 1343 |  | 
| 1327 | 1344 |  | 
| 1328 | 1345 | if __name__ == "__main__": | 
| — | — | @@ -1331,4 +1348,4 @@ | 
| 1332 | 1349 | interface = Commandline() | 
| 1333 | 1350 | interface._parsecommand(sys.argv[1], sys.argv[2:]) | 
| 1334 | 1351 | except KeyboardInterrupt: | 
| 1335 |  | -        sys.exit() | 
| \ No newline at end of file | 
|  | 1352 | +        sys.exit() | 
| Index: emcore/trunk/tools/libemcore.py | 
| — | — | @@ -31,6 +31,7 @@ | 
| 32 | 32 | import ctypes | 
| 33 | 33 | import usb.core | 
| 34 | 34 | import base64 | 
|  | 35 | +import datetime | 
| 35 | 36 |  | 
| 36 | 37 | from libemcoredata import * | 
| 37 | 38 | from misc import Logger, Bunch, remote_pointer, Error, ArgumentError, getthread, gethwname | 
| — | — | @@ -952,6 +953,23 @@ | 
| 953 | 954 | """ Frees all memory allocations created by the monitor thread """ | 
| 954 | 955 | self.logger.debug("Freeing all memory allocations created by the monitor thread\n") | 
| 955 | 956 | return self.lib.monitorcommand(struct.pack("<IIII", 57, 0, 0, 0), "III", (None, None, None)) | 
|  | 957 | + | 
|  | 958 | +    @command() | 
|  | 959 | +    def rtcread(self): | 
|  | 960 | +        """ Reads the real time clock on the device """ | 
|  | 961 | +        self.logger.debug("Reading the clock\n") | 
|  | 962 | +        date = self.lib.monitorcommand(struct.pack("<IIII", 60, 0, 0, 0), "BBBBBBBBI", ("second", "minute", "hour", "weekday", "day", "month", "year", None, None)) | 
|  | 963 | +        dt = datetime.datetime(date.year + 2000, date.month, date.day, date.hour, date.minute, date.second) | 
|  | 964 | +        self.logger.debug("Read date '%s' from device", (dt.ctime())) | 
|  | 965 | +        return dt | 
|  | 966 | + | 
|  | 967 | +    @command() | 
|  | 968 | +    def rtcwrite(self, dt): | 
|  | 969 | +        """ Sets the real time clock on the device to the datetime object 'dt' """ | 
|  | 970 | +        self.logger.debug("Setting the clock to: %s\n" % (dt.ctime())) | 
|  | 971 | +        if dt.year < 2000 or dt.year > 2255: | 
|  | 972 | +            raise ArgumentError("The Year must be between 2000 and 2255") | 
|  | 973 | +        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)) | 
| 956 | 974 |  | 
| 957 | 975 |  | 
| 958 | 976 | class Lib(object): |