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

Installing ZMQ packages for MATLAB #50

Open
Zahra-on-Github opened this issue Jan 14, 2021 · 8 comments
Open

Installing ZMQ packages for MATLAB #50

Zahra-on-Github opened this issue Jan 14, 2021 · 8 comments

Comments

@Zahra-on-Github
Copy link

I am totally new to ZMQ. To provide an interaction between my eye tracking device (Pupil Core) and MATLAB (R2020b), I have to install two packages:

https://github.com/fagg/matlab-zmq
https://github.com/bastibe/matlab-msgpack

They cannot be installed correctly and I keep getting errors.
I need to know what is missing on my laptop (Windows 10 Pro), for them to be correctly installed.

@fagg
Copy link
Owner

fagg commented Jan 14, 2021 via email

@Zahra-on-Github
Copy link
Author

Sorry for the miscommunication.

Windows 10 Pro
MATLAB R2020b
ZMQ libzmq-v141-mt-4_3_2

I am trying to interact with my eye tracking device, and as I run the script that uses ZMQ, I get this error:

Error using zmq.core.ctx_new
Attempt to execute SCRIPT ctx_new as a function:
C:...\matlab-zmq-master\lib+zmq+core\ctx_new.m

Error in pupil_remote_control (line 13)
ctx = zmq.core.ctx_new();

@Zahra-on-Github
Copy link
Author

Zahra-on-Github commented Jan 16, 2021

Have I explained the error clearly? Do I need to mention more information about the problem?

@Zahra-on-Github
Copy link
Author

I'd appreciate your guidance as soon as it is possible for you, since I'm on a clock here. I need to figure out what I'm doing wrong.

@fagg
Copy link
Owner

fagg commented Jan 18, 2021

  1. Download the ZMQ zip file (as you have done).
  2. Unzip it, noting the path where you unzipped it.
  3. In config_win.m, set the following:

ZMQ_COMPILED_LIB = 'libzmq-v141-mt-4_3_2.lib';
ZMQ_LIB_PATH = 'C:\Path\To\Where\You\Unzipped';
ZMQ_INC_PATH = 'C:\Path\To\Where\You\Unzipped';

  1. Run make.m.
  2. If that doesn't solve you problem, please post a code snippet.

Please also note that this project is not a full-time endeavor for me and I am not compensated for my time spent working on this. There is no guarantee of any support or warranty at all, let alone on a timeline specified by you or anyone else. I have a demanding full time job and other priorities that take precedence over answering Github tickets. As such, the service-level agreement is that I will endeavor to answer when I am able to. Please be understanding of this.

@Zahra-on-Github
Copy link
Author

Zahra-on-Github commented Jan 18, 2021

make.m ran successfully, as shown here:

...
... 
...
Building with 'MinGW64 Compiler (C)'.
MEX completed successfully.

Succesful build for:
	ZMQ_INCLUDE_PATH = C:\...\libzmq
	ZMQ_LIB_PATH = C:\...\libzmq
	ZMQ_COMPILED_LIB = libzmq-v141-mt-4_3_2.lib


ans =

  logical

   1

but the script where I try to communicate with my device still gives an error.
Here's the script:

% pupil_remote_control.m

% (*)~----------------------------------------------------------------------------------
%  Pupil Helpers
%  Copyright (C) 2012-2016  Pupil Labs
% 
%  Distributed under the terms of the GNU Lesser General Public License (LGPL v3.0).
%  License details are in the file license.txt, distributed as part of this software.
% ----------------------------------------------------------------------------------~(*)
% Pupil Remote address
endpoint =  'tcp://127.0.0.1:50020';
% Setup zmq context and remote helper
ctx = zmq.core.ctx_new();
socket = zmq.core.socket(ctx, 'ZMQ_REQ');
% set timeout to 1000ms in order to not get stuck in a blocking
% mex-call if server is not reachable, see
% http://api.zeromq.org/4-0:zmq-setsockopt#toc19
zmq.core.setsockopt(socket, 'ZMQ_RCVTIMEO', 1000);
fprintf('Connecting to %s\n', endpoint);
zmq.core.connect(socket, endpoint);
tic; % Measure round trip delay
zmq.core.send(socket, uint8('t'));
result = zmq.core.recv(socket);
fprintf('%s\n', char(result));
fprintf('Round trip command delay: %s\n', toc);
% set current Pupil time to 0.0
zmq.core.send(socket, uint8('T 0.0'));
result = zmq.core.recv(socket);
fprintf('%s\n', char(result));
% start recording
pause(1.0);
zmq.core.send(socket, uint8('R'));
result = zmq.core.recv(socket);
fprintf('Recording should start: %s\n', char(result));
pause(5.0);
zmq.core.send(socket, uint8('r'));
result = zmq.core.recv(socket);
fprintf('Recording stopped: %s\n', char(result));
% test notification, note that you need to listen on the IPC to receive notifications!
send_notification(socket, containers.Map({'subject'}, {'calibration.should_start'}))
result = zmq.core.recv(socket);
fprintf('Notification received: %s\n', char(result));
send_notification(socket, containers.Map({'subject'}, {'calibration.should_stop'}))
result = zmq.core.recv(socket);
fprintf('Notification received: %s\n', char(result));
zmq.core.disconnect(socket, endpoint);
zmq.core.close(socket);
zmq.core.ctx_shutdown(ctx);
zmq.core.ctx_term(ctx);

and the error is:

Error using zmq.core.ctx_new
Invalid MEX-file 'C:\...\matlab-zmq-master\lib\+zmq\+core\ctx_new.mexw64': The specified module could not be found.

Error in practice_run (line 23)
ctx = zmq.core.ctx_new();
 

while the module exists exactly where it's looking for it.

@Zahra-on-Github
Copy link
Author

I understand the service-level agreement, but if you know how this problem can be solved, or you know someone who knows, pleeease let me know.

@Zahra-on-Github
Copy link
Author

Zahra-on-Github commented Jan 26, 2021

Ok I got it to work!
Now, when I make test , 16 of the tests pass, and 2 fail:

>> make test
Running test (1/18): test_context_cleanup...[PASS]
Running test (2/18): test_context_get...[PASS]
Running test (3/18): test_socket_bind...[PASS]
Running test (4/18): test_socket_connect...[PASS]
Running test (5/18): test_socket_get...[FAIL]
Running test (6/18): test_socket_send_recv...[PASS]
Running test (7/18): test_socket_send_recv_multipart...[PASS]
Running test (8/18): test_socket_send_recv_string...[PASS]
Running test (9/18): test_socket_set...[PASS]
Running test (10/18): test_zmq_bind...[PASS]
Running test (11/18): test_zmq_connect...[PASS]
Running test (12/18): test_zmq_ctx_get...[PASS]
Running test (13/18): test_zmq_getsockopt...[FAIL]
Running test (14/18): test_zmq_req_rep...[PASS]
Running test (15/18): test_zmq_req_rep_multipart...[PASS]
Running test (16/18): test_zmq_setsockopt...[PASS]
Running test (17/18): test_zmq_socket...[PASS]
Running test (18/18): test_zmq_version...[PASS]
Elapsed time is 3.490147 seconds.
Error using runner (line 67)
Tests: 16 passed, 2 failed.

test_socket_get (line 61):
	rcvbuf should be 0, -1 given.

test_zmq_getsockopt (line 59):
	ZMQ_RCVBUF should be 0, -1 given.



Error in make>run_tests (line 96)
  success = runner(varargin{:});

Error in make (line 33)
        success = run_tests(varargin{2:end});

Any idea how to solve this?

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

2 participants