Subversion Repositories freemyipod

Rev

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

Rev 675 Rev 774
Line 17... Line 17...
17
#    See the GNU General Public License for more details.
17
#    See the GNU General Public License for more details.
18
#
18
#
19
#    You should have received a copy of the GNU General Public License
19
#    You should have received a copy of the GNU General Public License
20
#    along with emCORE.  If not, see <http://www.gnu.org/licenses/>.
20
#    along with emCORE.  If not, see <http://www.gnu.org/licenses/>.
21
#
21
#
22
#
22
#
23
 
23
 
24
"""
24
"""
25
    Command line interface to communicate with emCORE devices.
25
    Command line interface to communicate with emCORE devices.
26
    Run it without arguments to see usage information.
26
    Run it without arguments to see usage information.
27
"""
27
"""
Line 309... Line 309...
309
                    else: sys.stdout.write(" ")
309
                    else: sys.stdout.write(" ")
310
                sys.stdout.write("|")
310
                sys.stdout.write("|")
311
            sys.stdout.write("\n")
311
            sys.stdout.write("\n")
312
    
312
    
313
    @command
313
    @command
-
 
314
    def uploadbyte(self, addr, byte):
-
 
315
        """
-
 
316
            Uploads a single byte to the device
-
 
317
            <addr>: the address to upload the byte to
-
 
318
            <byte>: the byte to upload
-
 
319
        """
-
 
320
        addr = to_int(addr)
-
 
321
        byte = to_int(byte)
-
 
322
        if byte > 0xFF:
-
 
323
            raise ArgumentError("Specified integer too long")
-
 
324
        data = struct.pack("B", byte)
-
 
325
        self.emcore.write(addr, data)
-
 
326
        self.logger.info("Byte '0x%X' written successfully to 0x%X\n" % (byte, addr))
-
 
327
    
-
 
328
    @command
-
 
329
    def downloadbyte(self, addr):
-
 
330
        """
-
 
331
            Downloads a single byte from the device and prints it to the console window
-
 
332
            <addr>: the address to download the byte from
-
 
333
        """
-
 
334
        addr = to_int(addr)
-
 
335
        data = self.emcore.read(addr, 1)
-
 
336
        byte = struct.unpack("B", data)[0]
-
 
337
        self.logger.info("Read '0x%X' from address 0x%X\n" % (byte, addr))
-
 
338
    
-
 
339
    @command
314
    def uploadint(self, addr, integer):
340
    def uploadint(self, addr, integer):
315
        """
341
        """
316
            Uploads a single integer to the device
342
            Uploads a single integer to the device
317
            <addr>: the address to upload the integer to
343
            <addr>: the address to upload the integer to
318
            <integer>: the integer to upload
344
            <integer>: the integer to upload
Line 381... Line 407...
381
            Reads data from the USB console continuously
407
            Reads data from the USB console continuously
382
        """
408
        """
383
        while True:
409
        while True:
384
            resp = self.emcore.usbcread()
410
            resp = self.emcore.usbcread()
385
            self.logger.write(resp.data, target = "stdout")
411
            self.logger.write(resp.data, target = "stdout")
386
            time.sleep(0.1 / resp.maxsize * (resp.maxsize - len(resp.data)))
412
#            time.sleep(0.1 / resp.maxsize * (resp.maxsize - len(resp.data)))
387
    
413
    
388
    @command
414
    @command
389
    def writeusbconsole(self, *args):
415
    def writeusbconsole(self, *args):
390
        """
416
        """
391
            Writes the string <db1> ... <dbN> to the USB console.
417
            Writes the string <db1> ... <dbN> to the USB console.