Skip to content

Commit 9cbc3b1

Browse files
committed
Merge pull request #287 from cstawarz/network_events_fixes
Network events fixes
2 parents 4f1dca2 + 6fec299 commit 9cbc3b1

4 files changed

Lines changed: 36 additions & 5 deletions

File tree

Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,7 @@
28792879
GCC_PREPROCESSOR_DEFINITIONS = (
28802880
"_DEBUG=1",
28812881
"DEBUG=1",
2882+
"ZEROMQ",
28822883
"JUCER_XCODE_MAC_F6D2F4CF=1",
28832884
"JUCE_APP_VERSION=0.3.5",
28842885
"JUCE_APP_VERSION_HEX=0x305", );
@@ -2888,7 +2889,7 @@
28882889
INSTALL_PATH = "$(HOME)/Applications";
28892890
LIBRARY_SEARCH_PATHS = ("$(inherited)", "\"/opt/local/lib\"", "\"/usr/local/lib\"");
28902891
MACOSX_DEPLOYMENT_TARGET_ppc = 10.4;
2891-
OTHER_LDFLAGS = "-lhdf5 -lhdf5_cpp";
2892+
OTHER_LDFLAGS = "-lhdf5 -lhdf5_cpp -lzmq";
28922893
SDKROOT_ppc = macosx10.5; }; name = Debug; };
28932894
7A6F9B742B69F66DC3E29FA8 = {isa = XCBuildConfiguration; buildSettings = {
28942895
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
@@ -2901,6 +2902,7 @@
29012902
GCC_PREPROCESSOR_DEFINITIONS = (
29022903
"_NDEBUG=1",
29032904
"NDEBUG=1",
2905+
"ZEROMQ",
29042906
"JUCER_XCODE_MAC_F6D2F4CF=1",
29052907
"JUCE_APP_VERSION=0.3.5",
29062908
"JUCE_APP_VERSION_HEX=0x305", );
@@ -2911,7 +2913,7 @@
29112913
INSTALL_PATH = "$(HOME)/Applications";
29122914
LIBRARY_SEARCH_PATHS = ("$(inherited)", "\"/opt/local/lib\"", "\"/usr/local/lib\"");
29132915
MACOSX_DEPLOYMENT_TARGET_ppc = 10.4;
2914-
OTHER_LDFLAGS = "-lhdf5 -lhdf5_cpp";
2916+
OTHER_LDFLAGS = "-lhdf5 -lhdf5_cpp -lzmq";
29152917
SDKROOT_ppc = macosx10.5; }; name = Release; };
29162918
C8018C9A4DA633CA60663294 = {isa = XCBuildConfiguration; buildSettings = {
29172919
ALWAYS_SEARCH_USER_PATHS = NO;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from __future__ import print_function, unicode_literals
2+
3+
import zmq
4+
5+
try:
6+
raw_input
7+
except NameError:
8+
# Python 3
9+
raw_input = input
10+
11+
12+
def run(hostname='localhost', port=5556):
13+
with zmq.Context() as ctx:
14+
with ctx.socket(zmq.REQ) as sock:
15+
sock.connect('tcp://%s:%d' % (hostname, port))
16+
while True:
17+
try:
18+
req = raw_input('> ')
19+
sock.send_string(req)
20+
rep = sock.recv_string()
21+
print(rep)
22+
except EOFError:
23+
print() # Add final newline
24+
break
25+
26+
27+
if __name__ == '__main__':
28+
run()

Source/Processors/NetworkEvents/NetworkEvents.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ void NetworkEvents::run()
449449
if (rc != 0)
450450
{
451451
// failed to open socket?
452-
std::cout << "Failed to open socket." << std::endl;
452+
std::cout << "Failed to open socket: " << zmq_strerror(zmq_errno()) << std::endl;
453453
return;
454454
}
455455

@@ -562,7 +562,7 @@ void NetworkEvents::loadCustomParametersFromXml()
562562
void NetworkEvents::createZmqContext()
563563
{
564564
#ifdef ZEROMQ
565-
if (zmqcontext != nullptr)
565+
if (zmqcontext == nullptr)
566566
zmqcontext = zmq_ctx_new(); //<-- this is only available in version 3+
567567
#endif
568568
}

open-ephys.jucer

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
includeBinaryInAppConfig="1">
1313
<EXPORTFORMATS>
1414
<XCODE_MAC targetFolder="Builds/MacOSX" vstFolder="~/SDKs/vstsdk2.4" rtasFolder="~/SDKs/PT_80_SDK"
15-
extraLinkerFlags="-lhdf5 -lhdf5_cpp" objCExtraSuffix="fea2mT">
15+
extraLinkerFlags="-lhdf5 -lhdf5_cpp -lzmq" objCExtraSuffix="fea2mT"
16+
extraDefs="ZEROMQ">
1617
<CONFIGURATIONS>
1718
<CONFIGURATION name="Debug" isDebug="1" optimisation="3" targetName="open-ephys"
1819
osxSDK="default" osxCompatibility="default" osxArchitecture="default"

0 commit comments

Comments
 (0)