pyevt - A Python API for the Event-Exchanger EVT-2 USB hardware
1. About
This repository contains the API to communicate with EVT-2 USB-devices (+derivatives) developed by the Research Support group of the faculty of Behavioral and Social Science from the University of Groningen. The EVT-2 is a TTL event marking/TTL triggering device intended for computer-based psychology experiments.
2. Dependencies
The pyevt API uses HIDAPI, a cython module to communicate with HID-class USB devices.
3. Install
Install pyevt (and hidapi) with:
pip install pyevt or
pip install --user pyevt on managed computers.
4. Device Permission for Linux
Permission for using EVT (HID) devices should be given by adding the next lines to a file, for example named:
99-evt-devices.rules in /etc/udev/rules.d:
# /etc/udev/rules.d/99-evt-devices.rules
# All EVT devices
SUBSYSTEM=="usb", ATTR{idVendor}=="0004", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0008", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0009", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0114", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0208", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0308", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0408", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0508", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0604", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0808", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0909", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="1803", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="1807", MODE="0660", GROUP="plugdev"
The user should be a member of the plugdev -group.
Check with:
$ groups username
If this is not the case, add the user to the plugdev group by typing:
$ sudo usermod -a -G plugdev username
5. EventExchanger Class — API Summary
Device Management
| Method | Description |
|---|---|
scan(matching_key="EventExchanger") |
Lists connected HID devices whose product name contains matching_key. Returns a list of device info dicts. |
attach_name(matching_key="EventExchanger") |
Attaches the first device whose product name contains matching_key. |
attach_id(path) |
Attaches a device using its unique HID path. |
close() |
Closes the currently attached device. |
reset() |
Sends a reset command to the device and disconnects it from USB. |
Event & Data Retrieval
| Method | Description |
|---|---|
wait_for_event(allowed_event_lines, timeout_ms) |
Waits for digital input events matching the given bit mask. Returns (event_code, elapsed_ms), or (-1, elapsed_ms) on timeout. |
get_axis() |
Reads the current axis position value from the device. |
Digital Output Control
| Method | Description |
|---|---|
write_lines(value) |
Sets digital output lines to the specified bit pattern (0–255). |
pulse_lines(value, duration_ms) |
Pulses output lines for the given duration in milliseconds (0-65535). |
clear_lines() |
Clears (sets low) all output lines. |
Analog & Encoder Control
| Method | Description |
|---|---|
set_analog_event_step_size(samples_per_step) |
Configures analog event step size. |
renc_init(encoder_range, min_value, position, input_change, pulse_divider) |
Initializes rotary encoder parameters. |
renc_set_pos(position) |
Sets the current rotary encoder position. |
LED Control
| Method | Description |
|---|---|
set_led_rgb(red, green, blue, led_number, mode) |
Sets RGB color for a specific LED. |
send_led_rgb(num_leds, mode) |
Sends LED color data to the device. |
6. Python coding examples
from pyevt import EventExchanger
myevt = EventExchanger()
# Get list of devices containing the partial string 'partial_device_name'
myevt.scan('partial_device_name') # The default is 'EventExchanger'.
# Create a device handle:
myevt.attach_name('partial_device_name') # Example: 'EVT02', 'SHOCKER' or 'RSP-12', etc. The default is 'EventExchanger'.
myevt.write_lines(0) # clear outputs
myevt.pulse_lines(170, 1000) # value=170, duration=1000ms
# remove device handle
myevt.close()
# connect RSP-12 button response box
myevt.attach_name('RSP-12')
myevt.wait_for_event(3, None) # wait for button 1 OR 2, timeout is infinite.
myevt.close() # remove device handle
7. License
The pyevt API is distributed under the terms of the GNU General Public License 3. The full license should be included in the file COPYING, or can be obtained from
http://www.gnu.org/licenses/gpl.txt
The pyevt API contains the work of others.
8. Other documentation
Information about EVT-devices and OpenSesame plugins:
Metadata
Release files for pyevt 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyevt-0.2.1.tar.gz | 17.6 kB | Without provenance | Details for pyevt-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyevt-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for pyevt-0.2.1-py3-none-any.whl |
Total release size: 35.9 kB
Release files / pyevt-0.2.1.tar.gz
| Download URL | pyevt-0.2.1.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fcad8fbdce4677b8400740de21597392fffda82b0cbbf11748ea3c5586d896c2
|
|
BLAKE2b-256 checksum How to use checksums |
052bbe01210bbc0744fa468ce73a0261d24599533bf4b4104f2d8e8b23a9b1f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.12.3 Linux/6.8.0-71-generic
|
Release files / pyevt-0.2.1-py3-none-any.whl
| Download URL | pyevt-0.2.1-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb73905df4cb7f44cf1407a7b220add49f987882905d759a2bb287454bf24071
|
|
BLAKE2b-256 checksum How to use checksums |
71614d16a232b15dacd8737f50cdd5aa0ffa8c882c7ca2ea98b057aaf8e2a6a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.12.3 Linux/6.8.0-71-generic
|
Security for pyevt 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.