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

Help needed: "Failed to initialize EyeTribe object in the Server" #9

Open
HannaHMK opened this issue Mar 6, 2016 · 15 comments
Open

Comments

@HannaHMK
Copy link

HannaHMK commented Mar 6, 2016

Hi EyeTribe for Matlab writer and users,

first of all: Thank you Edwin for posting this script!
I am trying to set up an EyeTribe experiment, but the initialization is not working out for me. Python is running, I call (for example) the script 'EXAMPLE.m' or 'EXAMPLE_PTB.m' and get this message printed in the command window in Matlab:

Opening new connection.
Sending socket initialization message.
success
Server says: success
Sending socket initialization message.
Server says: ERROR in Initialize EyeTribe: could not initialize new EyeTribe object.
Failed to initialize EyeTribe object in the Server.
Error using fwrite
Operation is not implemented for requested file identifier.

Error in eyetribe_send_command (line 17)

and this printed in the Terminal:

Starting new socket connection (ip=localhost, port=5667).
Listening for connections...
Found new connection (127.0.0.1, 49659)
Client says: Hi, this is Matlab!
ERROR in Initialize EyeTribe: could not initialize new EyeTribe object.

Has anyone had this problem? And/Or does anyone have suggestions on what to do?
Help is vastly appreciated!
Hannah
PS: I use a Mac (OS X El Capitan), Matlab 2014b with the latest PTB and also the latest version of Python.

@esdalmaijer
Copy link
Owner

Hi Hannah,

Thanks for the clear report! I'm not entirely sure what is happening, but some quick suggestions:

  1. What is the filename you pass?

  2. Did you change anything to the port number for your EyeTribe? It's assumed to be the default number of 6555. (NOTE: This is different from the port number in the EyeTribe for Matlab library!)

Some more information could come from the EyeTribe's log. Could you access it, and copy the relevant entries in here?

Cheers,
Edwin

@HannaHMK
Copy link
Author

HannaHMK commented Mar 8, 2016

Hi Edwin,

thank you for your super speedy reply.

  1. I've tried a few filenames. The default 'test' does the same as others.
  2. I have changed the port number in the python file and the init_eyetribe.m to '6555'. With this localhost/ portnumber I do not get an error anymore, but the program seems to get stuck in an attempt to send a socket initialization.

Matlab Command Window:

EXAMPLE
Opening new connection.
Sending socket initialization message.
success
Server says: success
Sending socket initialization message.

Terminal:

python EyeTribe_Matlab_server.py
Starting new socket connection (ip=localhost, port=6555).
Listening for connections...
Found new connection (127.0.0.1, 51875)
Client says: Hi, this is Matlab!

The log fie (you mean the file that I pass through matlab when calling init-eyetribe(), right?) contains the title line:
timestamp time fix state rawx rawy avgx avgy psize Lrawx Lrawy Lavgx Lavgy Lpsize Lpupilx Lpupily Rrawx Rrawy Ravgx Ravgy Rpsize Rpupilx Rpupily

Any clue what could be going on?

Thank you!!

Hannah

@HannaHMK
Copy link
Author

HannaHMK commented Mar 8, 2016

So, the program gets stuck in eyetribe_send_command in the while loop at the bottom because the BytesAvailable doesn't get larger than 0.

This is what connection contains:
K>> connection

TCPIP Object : TCPIP-localhost

Communication Settings
RemotePort: 6555
RemoteHost: localhost
Terminator: 'LF'
NetworkRole: client

Communication State
Status: open
RecordStatus: off

Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 7
ValuesSent: 56

@esdalmaijer
Copy link
Owner

Hi Hannah,

Sorry, my bad about explaining the port number badly. There are two port numbers. One is for the connection between Python and the EyeTribe. This is 6555, as is the default for the EyeTribe. If you haven't changed that setting, you should be good. (You can find this default value in pytribe.py, and you shouldn't change it without also changing the actual EyeTribe!).

The other port number is for the connection between Python and Matlab. This defaults to 5666, but the actual value doesn't really matter. As long as you make sure it's the same between the Python source and eyetribe_init.m.

You should also make sure that all port numbers are available on your machine, otherwise you get the error you had after you changed the port numbers (Matlab listening/taling via the same connection as the EyeTribe, meaning that Python couldn't understand what Matlab was saying.) Usually, the default numbers are free and allowed.

For debugging, I actually meant the EyeTribe's log. You can find this in the AppData folder on Windows (e.g. C:\Users\Edwin\AppData\Local\EyeTribe\Logs). Not sure what the equivalent is on OS X. (Sorry, not a Mac user!) That folder contains logs of the EyeTribe connection, which might give us some more info on what went wrong.

Cheers,
Edwin

@HannaHMK
Copy link
Author

HannaHMK commented Mar 8, 2016

Hi Edwin,

okay, it is solved! I did not initiate the EyeTribe unix executable from the EyeTribe SDK. When I open this in Terminal it opens the connection to the EyeTribe, I then start the python script followed by the Matlab script and ....tadaaaaa! It is running!

It was probably obvious to most other people that this is the way it should be done... For those who did not, I hope my description helps.

Thank you for your speedy replies Edwin!

Cheers,
Hannah

@HannaHMK HannaHMK closed this as completed Mar 8, 2016
@HannaHMK
Copy link
Author

Hi Edwin,

I met a few people this week who are also using your scripts to get their EyeTribes running and indeed they ran into the same problem (Mac users). Can I add this part about starting the EyeTribe executable over terminal in MacOS to your documentation? I think it would make it very simple for many users to get started.
Or maybe it is easier if you add it? Here is an example text:

  1. Go to the EyeTribe folder from the EyeTribe SDK and start the EyeTribe executable simply by double clicking on it. It will open up a Terminal window. (Or you can open it directly in Terminal via /Applications/EyeTribe/EyeTribe)
  2. Open a new, additional tab in Terminal.
  3. Use the cd function to go to your python_source folder. An example:
cd /home/python_source
  1. Use Python to run the source. Python should be installed on any Linux system, and I think OS X usually comes with it as well. Type the following command in the Terminal:
python EyeTribe_Matlab_server.py
  1. Now run your Matlab script (but do it within two minutes of starting the Python script, because it will time out after that).

Hannah

@Beuks
Copy link

Beuks commented Dec 12, 2019

@HannaHMK I am having this exact same issue but I'm not using any python scripts. Do you know the cause of the fwrite error? My script worked fine on an older laptop, but it is no longer reliable and I'm trying to transfer the code to a more stable machine.

@esdalmaijer
Copy link
Owner

@Beuks: Did you follow the instructions here and elsewhere? I.e. start the EyeTribe Server in a terminal; run the Python script as mentioned above in an additional server (this is the additional server that bridges Matlab and the EyeTribe server); then run your Matlab script.

@Beuks
Copy link

Beuks commented Jan 5, 2020

@esdalmaijer I have followed the instructions both here and under another commit with a similar issue that was solved using the instructions in this thread. So far I either still get the fwrite error, or Matlab gets stuck on busy. Admittedly, I don't have much experience using terminal commands, so it's possible I'm setting it up incorrectly

@esdalmaijer
Copy link
Owner

@Beuks, would you be able to share what the different terminals say? That is:

  1. Text in the Terminal that runs the EyeTribe Server (running /Applications/EyeTribe/EyeTribe)
  2. Text in the Terminal that runs Python (running the file EyeTribe_Matlab_server.py)
  3. Text in the Matlab window (running your script)

@esdalmaijer esdalmaijer reopened this Jan 8, 2020
@Beuks
Copy link

Beuks commented Jan 8, 2020

@esdalmaijer I've got a different issue now so potentially progress?

1. Text in the Terminal that runs the EyeTribe Server

[13:37:49.263] INF: Initializing environment
[13:37:49.279] INF: Constructing logfile:
C:\Users\steve\AppData\Local\EyeTribe\Logs\20200108133749_1314212180.log


** The EYE TRIBE TRACKER Server **


Version: 0.9.77

Settings applied:
TCP port: 6555
Connections: local only
Framerate: 30

Initializing the Eye Tribe Server
The Eye Tribe Tracker firmware revision is 293
Accessing Tracker device

The Eye Tribe Tracker stands ready!

[13:37:52.403] INF: Default calibration profile loaded!

2. Text in the Terminal that runs Python

C:\Users\steve\Documents\MATLAB\EyeTribe-Toolbox-for-Matlab-master\python_source>python EyeTribe_Matlab_server.py

Starting new socket connection (ip=localhost, port=5666).
Listening for connections...
Found new connection (127.0.0.1, 60142)
Client says: b'Hi, this is Matlab!'
Traceback (most recent call last):
File "EyeTribe_Matlab_server.py", line 38, in
conn, addr = sock.accept()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\socket.py", line 212, in accept
fd, addr = self._accept()
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "EyeTribe_Matlab_server.py", line 41, in
raise Exception("ERROR: socket timed out, no connections available.")
Exception: ERROR: socket timed out, no connections available.

3. Text in the Matlab window

There is no text this time, it gets stuck on Busy. I used to open the EyeTribe_Matlab_server.exe within the EyeTribe_for_Matlab folder without issue. Doing that now gives the fwrite error discussed in this thread. Following these new steps gives the above output. If I Ctrl+C the Matlab script to force cancel, I get this output (full text from opening Matlab and cancelling script):

PsychStartup: Adding path of installed GStreamer runtime to library path. [D:\gstreamer\1.0\x86_64\bin]

SYMMETRY_EyeTribe
Observer initials : STEVE
block number : 1

ans =

 0

Opening new connection.
Sending socket initialization message.
Operation terminated by user during instrument/isvalid (line 37)

In instrument/get (line 49)
if ~all(isvalid(obj))

In instrument/subsref (line 117)
result = get(indexObj, prop1);

In eyetribe_send_command (line 22)
if connection.BytesAvailable > 0

In eyetribe_init (line 23)
message = eyetribe_send_command(connection, 'Hi, this is Matlab!');

In SYMMETRY_EyeTribe (line 42)
[success, connection] = eyetribe_init(rawDataPath);

@esdalmaijer
Copy link
Owner

Ahhhh, yes! Try running the Python script using Python 2 rather than 3. I realise Python 2 is no longer supported (as of 1 Jan), but this is an older project, and the long-term stable should be fine for now.

@Beuks
Copy link

Beuks commented Jan 9, 2020

@esdalmaijer Okay I'm back to getting the same fwrite error with python 2.7.16 (should I downgrade python even further?).

As above, here are the outputs of each terminal:

1. Text in the Terminal that runs the EyeTribe Server

[14:34:28.137] INF: Initializing environment
[14:34:28.141] INF: Constructing logfile:
C:\Users\steve\AppData\Local\EyeTribe\Logs\20200109143428_3009290759.log


** The EYE TRIBE TRACKER Server **


Version: 0.9.77

Settings applied:
TCP port: 6555
Connections: local only
Framerate: 60

Initializing the Eye Tribe Server
The Eye Tribe Tracker firmware revision is 293
Accessing Tracker device

The Eye Tribe Tracker stands ready!

[14:34:30.125] INF: Default calibration profile loaded!

2. Text in the Terminal that runs Python

C:\Users\steve\Documents\MATLAB\EyeTribe-Toolbox-for-Matlab-master\python_source>python EyeTribe_Matlab_server.py
Starting new socket connection (ip=localhost, port=5666).
Listening for connections...
Found new connection (127.0.0.1, 65299)
Client says: Hi, this is Matlab!
ERROR in Initialize EyeTribe: could not initialize new EyeTribe object.

3. Text in the Matlab window

SYMMETRY_EyeTribe
Observer initials : sb
block number : 1

ans =

 0

Opening new connection.
Sending socket initialization message.
success
Server says: success
Sending socket initialization message.
Server says: ERROR in Initialize EyeTribe: could not initialize new EyeTribe object.
Failed to initialize EyeTribe object in the Server.

a bunch of PTB-INFO lines appear here but that's normal

Starting calibration.
Error using fwrite
Operation is not implemented for requested file identifier.

Error in eyetribe_send_command (line 17)
fwrite(connection, command);

Error in eyetribe_calibrate (line 44)
message = eyetribe_send_command(connection, 'Calibration start');

Error in SYMMETRY_EyeTribe (line 52)
success = eyetribe_calibrate(connection, window);

@Beuks
Copy link

Beuks commented Jan 13, 2020

@esdalmaijer solved! It turns out I forgot to pre-create a raw data folder for the eyetribe to store the gaze data inside. Because the errors were similar to the ones in this thread, I thought it was the same problem. I mistakenly assumed matlab would generate the folder itself on the fly. Rookie mistake!

@esdalmaijer
Copy link
Owner

Ohhhh, that makes sense now! I guess the error message for the initial connection should be more specific about what prevented the EyeTribe instance to be initialised in the Python server.

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

3 participants