File: serial.rst

package info (click to toggle)
psychopy 2023.2.4%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 124,456 kB
  • sloc: python: 126,213; javascript: 11,982; makefile: 152; sh: 120; xml: 9
file content (15 lines) | stat: -rw-r--r-- 892 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
:mod:`psychopy.serial` - functions for interacting with the serial port
=================================================================================

|PsychoPy| is compatible with Chris Liechti's `pyserial <https://github.com/pyserial/pyserial>`_ package. You can use it like this::
    
    import serial
    ser = serial.Serial(0, 19200, timeout=1)  # open first serial port
    #ser = serial.Serial('/dev/ttyS1', 19200, timeout=1)#or something like this for Mac/Linux machines
    ser.write('someCommand')
    line = ser.readline()   # read a '\n' terminated line
    ser.close()
    
Ports are fully configurable with all the options you would expect of RS232 communications. See https://pyserial.readthedocs.io for further details and documentation.

pyserial is packaged in the Standalone (Windows and Mac distributions), for manual installations you should install this yourself.