1

I am trying to read the whole file system on a TI calculator via USB. The program runs successfully until it tries to read the file system with dev.read(). To dev.read(), I give the arguments ep.bEndpointAddress (0x81) as the endpoint address and ep.wMaxPacketSize (0x40, 64 bytes). However, the function times out before it gives anything. I have tried with timeouts up to 20s, without any difference.

I'm planning to get this to work on pretty much any rather recent TI calculator.

If necessary, I am using a Texas Instruments TI-84 Plus CE-T to test.

I just want to copy the whole raw file system to a file, like the backup option in TiLP does.

Python:

import usb.core, usb.util, time

print("Finding devices...")

devices = usb.core.find(find_all=True, idVendor=0x0451) # TI vendor

for dev in devices:
    print("Found a TI calculator!")
    dev.set_configuration()
    ep = usb.util.find_descriptor(dev.get_active_configuration()[(0, 0)], custom_match=lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_IN and usb.util.endpoint_type(e.bmAttributes) == usb.util.ENDPOINT_TYPE_BULK)

    with open("filesystem.img", "wb") as f:
        data = bytearray()
        while True:
            print("Reading packet...")
            try:
                packet = dev.read(ep.bEndpointAddress, ep.wMaxPacketSize, timeout=2000)
                data.extend(packet)
            except usb.core.USBError as e:
                raise e
                break
        f.write(data)

    usb.util.dispose_resources(dev)

ep gives:

      ENDPOINT 0x81: Bulk IN ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0

dev.get_active_configuration() gives:

  CONFIGURATION 1: 500 mA ==================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0x23 (35 bytes)
   bNumInterfaces       :    0x1
   bConfigurationValue  :    0x1
   iConfiguration       :    0x0 
   bmAttributes         :   0x80 Bus Powered
   bMaxPower            :   0xfa (500 mA)
    INTERFACE 0: Vendor Specific ===========================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :   0xff Vendor Specific
     bInterfaceSubClass :    0x1
     bInterfaceProtocol :    0x0
     iInterface         :    0x0 
      ENDPOINT 0x81: Bulk IN ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0
      ENDPOINT 0x2: Bulk OUT ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x2 OUT
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0

Thanks.

0 Answers0