How to Send Markers via the LAN Port
We are a manufacturer of fnirs devices, and previously, we used eprime to send markers. It supports sending marker information through the LAN port, while our devices only accept markers through the LAN port. Now, we would like to explore the possibility of using Psychopy to send markers via the LAN port. Is there any way to achieve this functionality through the builder or coder interface?
You can use standard Python socket programming in coder to communicate via LAN port using either TCP or UDP protocols. Lots of tutorials out there to do so:
- Socket Programming in Python (Guide) – Real Python
- Socket Programming HOWTO — Python 3.12.0 documentation
Once you have a module build, the user side of things is pretty simple. You can either build components to embed into a routine or you can use code modules like we do here for EEG: Sending triggers via EGI NetStation — PsychoPy v2023.2.3
1 Like
Thank you very much for your suggestion, I have already written the code for python to transfer messages through the lan port, next I will try code modules to include in my program.
import socket
host = 'ip'
port = 6
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((host, port))
data_to_send = "1"
client_socket.send(data_to_send.encode('utf-8'))