Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
d78c5f40
Commit
d78c5f40
authored
6 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Minor code tidy
parent
3d95a28e
No related branches found
No related tags found
No related merge requests found
Pipeline
#9625
failed
6 years ago
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cv-node/src/main.cpp
+11
-16
11 additions, 16 deletions
cv-node/src/main.cpp
net/cpp/src/socket.cpp
+13
-7
13 additions, 7 deletions
net/cpp/src/socket.cpp
with
24 additions
and
23 deletions
cv-node/src/main.cpp
+
11
−
16
View file @
d78c5f40
/*
* Copyright 2019 Nicolas Pope
* Copyright 2019 Nicolas Pope. All rights reserved.
*
* See LICENSE.
*/
#include
<glog/logging.h>
...
...
@@ -45,18 +47,11 @@ static json config;
static
bool
findConfiguration
(
const
string
&
file
)
{
ifstream
i
;
if
(
file
!=
""
)
{
i
.
open
(
file
);
}
if
(
!
i
.
is_open
())
{
i
.
open
(
"./config.json"
);
}
if
(
!
i
.
is_open
())
{
i
.
open
(
FTL_LOCAL_CONFIG_ROOT
"/config.json"
);
}
if
(
!
i
.
is_open
())
{
i
.
open
(
FTL_GLOBAL_CONFIG_ROOT
"/config.json"
);
}
if
(
file
!=
""
)
i
.
open
(
file
);
if
(
!
i
.
is_open
())
i
.
open
(
"./config.json"
);
if
(
!
i
.
is_open
())
i
.
open
(
FTL_LOCAL_CONFIG_ROOT
"/config.json"
);
if
(
!
i
.
is_open
())
i
.
open
(
FTL_GLOBAL_CONFIG_ROOT
"/config.json"
);
if
(
!
i
.
is_open
())
return
false
;
i
>>
config
;
return
true
;
}
...
...
@@ -140,7 +135,7 @@ static void run(const string &file) {
// Choose and configure disparity algorithm
auto
disparity
=
Disparity
::
create
(
config
[
"disparity"
]);
Mat
l
,
r
,
disparity
32F
,
depth32F
,
lbw
,
rbw
;
Mat
l
,
r
,
disparity
;
Display
display
(
calibrate
,
config
[
"display"
]);
...
...
@@ -156,10 +151,10 @@ static void run(const string &file) {
sync
->
get
(
ftl
::
LEFT
,
l
);
sync
->
get
(
ftl
::
RIGHT
,
r
);
disparity
->
compute
(
l
,
r
,
disparity
32F
);
disparity
->
compute
(
l
,
r
,
disparity
);
// Send RGB+Depth images for local rendering
display
.
render
(
l
,
disparity
32F
);
display
.
render
(
l
,
disparity
);
// streamer.send(l, disparity32F);
}
...
...
This diff is collapsed.
Click to expand it.
net/cpp/src/socket.cpp
+
13
−
7
View file @
d78c5f40
...
...
@@ -49,16 +49,15 @@ using namespace std;
int
Socket
::
rpcid__
=
0
;
// TODO(nick) Move to tcp_internal.cpp
static
int
tcpConnect
(
URI
&
uri
)
{
int
rc
;
sockaddr_in
destAddr
;
//std::cerr << "TCP Connect: " << uri.getHost() << " : " << uri.getPort() << std::endl;
#ifdef WIN32
WSAData
wsaData
;
if
(
WSAStartup
(
MAKEWORD
(
1
,
1
),
&
wsaData
)
!=
0
)
{
//
ERROR
LOG
(
ERROR
)
<<
"Could not initiate sockets"
;
return
INVALID_SOCKET
;
}
#endif
...
...
@@ -67,6 +66,7 @@ static int tcpConnect(URI &uri) {
int
csocket
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
csocket
==
INVALID_SOCKET
)
{
LOG
(
ERROR
)
<<
"Unable to create TCP socket"
;
return
INVALID_SOCKET
;
}
...
...
@@ -84,7 +84,6 @@ static int tcpConnect(URI &uri) {
#endif
LOG
(
ERROR
)
<<
"Address not found : "
<<
uri
.
getHost
()
<<
std
::
endl
;
return
INVALID_SOCKET
;
}
...
...
@@ -120,8 +119,6 @@ static int tcpConnect(URI &uri) {
arg &= (~O_NONBLOCK);
fcntl(csocket, F_SETFL, arg) < 0)*/
// Handshake??
return
csocket
;
}
...
...
@@ -386,6 +383,7 @@ void Socket::_dispatchReturn(const std::string &d) {
Dispatcher
::
response_t
the_result
;
unpacked
.
get
().
convert
(
the_result
);
// Msgpack stipulates that 1 means return message
if
(
std
::
get
<
0
>
(
the_result
)
!=
1
)
{
LOG
(
ERROR
)
<<
"Bad RPC return message"
;
return
;
...
...
@@ -399,6 +397,8 @@ void Socket::_dispatchReturn(const std::string &d) {
if
(
callbacks_
.
count
(
id
)
>
0
)
{
LOG
(
INFO
)
<<
"Received return RPC value"
;
// Call the callback with unpacked return value
(
*
callbacks_
[
id
])(
res
);
callbacks_
.
erase
(
id
);
}
else
{
...
...
@@ -428,17 +428,23 @@ int Socket::_send() {
// Create a websocket header as well.
size_t
len
=
0
;
char
buf
[
20
];
// TODO(nick) Should not be a stack buffer.
// Calculate total size of message
for
(
auto
v
:
send_vec_
)
{
len
+=
v
.
iov_len
;
}
// Pack correct websocket header into buffer
int
rc
=
ws_prepare
(
wsheader_type
::
BINARY_FRAME
,
false
,
len
,
buf
,
20
);
if
(
rc
==
-
1
)
return
-
1
;
// Patch the first io vector to be ws header
send_vec_
[
0
].
iov_base
=
buf
;
send_vec_
[
0
].
iov_len
=
rc
;
}
#ifdef WIN32
// TODO(nick) Use WSASend instead
// TODO(nick) Use WSASend instead
as equivalent to writev
int
c
=
0
;
for
(
auto
v
:
send_vec_
)
{
c
+=
ftl
::
net
::
internal
::
send
(
sock_
,
(
char
*
)
v
.
iov_base
,
v
.
iov_len
,
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment