Failed to get Command with Raw HID

Tanaji

Member
Hello Team,
I am using Teensy 4.0, with Windows system.

My Teensy is programmed with attached sketch and I am sending a command through a python script (attached) from the Windows command prompt:
C:\Users\110611\data\projects>python teensyTestApp.py
Sending RawHID command: [52, 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]

On Teensy side through Serial Monitor:
Teensy is ready to receive RawHID commands.
Received RawHID command: 0x0 with parameter: 0x0
 

Attachments

  • sketch_jun27a.ino
    1.2 KB · Views: 31
  • teensyTestApp_.py.txt
    872 bytes · Views: 29
The problem is at the Python side.
When I execute rawhid_test.exe found here, and uploaded your sketch to a Teensy 4.0, I see this on the serial monitor:

1719732787457.png


I entered the characters 'a', 'b' & 'c' so that matches the receiving end:

1719732846421.png


I tried to run your Python script, using Thonny, but that didn't succeed:

1719733097526.png


I'm guessing the error is related to the Python HID library I used. What exact library did you use?
PS: had to change the PRODUCT_ID to 0x0483 to the Teensy 4.0.

Paul
 
Thank you, Sir, for your quick reply. Please find below python & HID library details.
[1]
C:\Windows\System32>pip install hidapi
Requirement already satisfied: hidapi in c:\users\110615\appdata\local\programs\python\python39\lib\site-packages (0.14.0)
Requirement already satisfied: setuptools>=19.0 in c:\users\110615\appdata\local\programs\python\python39\lib\site-packages (from hidapi) (57.4.0)
[2]
I changed my Teensy from 4.1 to 4.0, still I need to use
VENDOR_ID = 0x16C0
PRODUCT_ID = 0x0486
If I use 0x0483, it gives me -
$ python teensyTestApp.py
Error: open failed

[3]
Note: I am using Git Bash or CMD Prompt to send commands from Windows to Teensy.
If I need to use rawhid_test.exe, Do I need to recompile it for Windows from the source code -RawHid Test C source code?
Could you please share your code that sent/received command successfully that mentioned in 1st snippet?
I am looking for any method that unblocks me for this sending the commands (0x33, 0x34, etc..) to Teensy.
 
Put a 0 at the front of the array that you send, like this: buffer_out = [0, command_byte, parameter_byte] + [0] * 62
 
Heyyy, its working now. You saved my lot of time. Thanks.
Will appreciate if I could get to know the reason?
 
Back
Top