Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to teensy.write/read in python. #13

Open
mousemain opened this issue Jul 8, 2022 · 0 comments
Open

Not able to teensy.write/read in python. #13

mousemain opened this issue Jul 8, 2022 · 0 comments

Comments

@mousemain
Copy link

Default Code:

import hid
from urllib import request
import json

hidInterfaces = hid.enumerate()          # get all hid interfaces
t_it = filter(lambda t:                  # filter by vid and usagepage/usage
  t['vendor_id']  == 0x16c0 and
  t['usage_page'] == 0xFFAB and
  t['usage']      == 0x0200, hidInterfaces)

rawHID_interface = next(t_it, None)      # 'firstOrDefault'

if rawHID_interface != None:
   teensy = hid.Device(path = rawHID_interface["path"])

   for i in range(10):
     jsonurl = request.urlopen("https://api.adviceslip.com/advice")
     slip = '\0' + json.loads(jsonurl.read())['slip']['advice']  # the sent report must always start with \0
     teensy.write(slip.encode()[:64])                            # rawHID report is 64 bytes long

Error:

  File "hid.pyx", line 164, in hid.device.write
ValueError: not open

Does anyone know what error is this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant