usb

The CE’s USB port, with TIpy’s own driver: no LibLoad and no CE C libraries. The calculator is a USB device. Plugged into a computer, it is a serial port, which serial reads and writes. This library reports the USB state.

from ti84 import usb

usb.begin()
while not usb.connected():
    usb.poll()
print("Set up by the computer")
usb.end()
  • poll() handles USB events. Call it often, or one of the serial methods, which do the same.

  • connected() is True once a computer has set the calculator up.

  • role() gives usb.HOST or usb.DEVICE, plus usb.PLUG_B when the B end of a cable is in.

  • last_event() gives the latest event, such as usb.HOST_CONFIGURE.

Host mode

USB host mode is not supported yet: the calculator cannot talk to keyboards, drives, or other devices on an OTG cable. Until it is, find() finds nothing, and the device and transfer methods report failure. The 256-byte buffer (buffer_get() and buffer_set()) is still there for programs that plan for it.

Methods

begin() → int

Start TIpy’s USB driver as a device (no clibs needed); 0 on success.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.begin()
end()

Stop the USB driver. A program that started it also stops it when it exits.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

usb.end()
poll() → int

Handle USB events; call it often. 0, a USB error, or -1 before begin().

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.poll()
role() → int

usb.HOST or usb.DEVICE, plus usb.PLUG_B when the B end of the cable is in.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.role()
last_event() → int

The latest USB event, such as usb.DEVICE_ENABLED; -1 before any.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.last_event()
find(previous=0) → int

Host mode is not supported yet, so this is always 0.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.find(x)
connected() → bool

Whether a computer has set the calculator up.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.connected()
vendor_id(device) → int

Host mode is not supported yet: -1.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.vendor_id(x)
product_id(device) → int

Host mode is not supported yet: -1.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.product_id(x)
address(device) → int

Host mode is not supported yet: -1.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.address(x)
speed(device) → int

Host mode is not supported yet: -1.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.speed(x)
configure(device) → int

Host mode is not supported yet: 6, the not-supported error.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.configure(x)
transfer(device, endpoint, name, offset, length) → int

Host mode is not supported yet: -1.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.transfer(x, 0x81, 'BUF', 0, y)
control(device, request_type, request, value, index, length) → int

Host mode is not supported yet: -1.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.control(x, 0x80, 6, 0x100, 0, 18)
buffer_get(index) → int

Byte index (0-255) of the USB buffer.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

z = usb.buffer_get(x)
buffer_set(index, value)

Set byte index (0-255) of the USB buffer.

Targets:

CE

Note:

USB is the CE’s; on classic, ti84.serial talks over the link port.

usb.buffer_set(x, y)