Skip to content

USB HOST implementation on teensy 4.1 #6527

@fadh3r

Description

@fadh3r

I can't get data through endpoint of usb host implementation
Where is my mistake?

this is my code:

import usb_host
import usb.core
import sys
import board
import digitalio
import microcontroller
import time
import array

#INIT USB WITH POSITIVE AND NEGATIVE PINS
if hasattr(board, "USB_HOST_POWER"):
    d = digitalio.DigitalInOut(board.USB_HOST_POWER)
    d.switch_to_output(value=True)
    print("USB power on")


h = usb_host.Port(board.USB_HOST_DP, board.USB_HOST_DM)

#FIND VMETER
vmeter = usb.core.find(idVendor=0x16d0, idProduct=0x0668)
print(vmeter.manufacturer, vmeter.product)

if vmeter.is_kernel_driver_active(0):
    vmeter.detach_kernel_driver(0)


buf = array.array('b', [0] * 64)

while True:
    try:
        count = vmeter.read(0x82, buf)
        # bEndpointAddress 0x82 IN Endpoint 2
        # bEndpointAddress 0x01 OUT Endpoint 1
    except usb.core.USBTimeoutError:
        continue

    print(buf)
    print(count)
    time.sleep(.01)

I'm getting right device manufacturer and product names,
but my "buf" is always empty and "count" of read bytes is always 14...

array("b", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
14

I also tried 7 and 8 version of CircuitPython and different usb devices...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions