Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART_17-18
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
bbartels
MicroCART_17-18
Commits
0c731a40
Unverified
Commit
0c731a40
authored
8 years ago
by
Jake Drahos
Browse files
Options
Downloads
Patches
Plain Diff
Began backend socket
parent
dcb58d3d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
groundStation/src/config.h
+9
-0
9 additions, 0 deletions
groundStation/src/config.h
groundStation/src/microcart_cli.c
+46
-3
46 additions, 3 deletions
groundStation/src/microcart_cli.c
with
55 additions
and
3 deletions
groundStation/src/config.h
0 → 100644
+
9
−
0
View file @
0c731a40
#ifndef __BACKEND_H
#define __BACKEND_H
#define DEFAULT_SOCKET "/var/run/ucart.socket"
#define SOCKET_ENV "UCART_SOCKET"
#endif
This diff is collapsed.
Click to expand it.
groundStation/src/microcart_cli.c
+
46
−
3
View file @
0c731a40
...
...
@@ -9,6 +9,7 @@
#include
<unistd.h>
#include
<signal.h>
#include
<sys/socket.h>
#include
<sys/un.h>
#include
<sys/select.h>
#include
<bluetooth/bluetooth.h>
#include
<bluetooth/rfcomm.h>
...
...
@@ -21,6 +22,7 @@
#include
"vrpn_tracker.hpp"
#include
"type_def.h"
#include
"logger.h"
#include
"config.h"
#define QUAD_BT_ADDR "00:06:66:64:61:D6"
#define QUAD_BT_CHANNEL 0x01
...
...
@@ -52,6 +54,7 @@ static ssize_t writeQuad(const char * buf, size_t count);
static
volatile
int
keepRunning
=
1
;
const
char
*
TRACKER_IP
=
"UAV@192.168.0.120:3883"
;
static
int
zyboSocket
;
static
int
backendSocket
;
struct
ucart_vrpn_tracker
*
tracker
=
NULL
;
const
char
*
logHeader
=
""
;
//"#\n#\tDefault log header\n#\tEverything after '#'`s will be printed as is in the processed logs.\n#\n\0";
...
...
@@ -92,6 +95,41 @@ int main(int argc, char **argv)
fd_set
rfds
;
int
activity
;
int
max_fd
=
0
;
FD_ZERO
(
&
rfds
);
/*
* Create backend listening socket
*/
/* Determine socket path */
char
*
backend_socket_path
=
DEFAULT_SOCKET
;
if
(
getenv
(
SOCKET_ENV
))
{
backend_socket_path
=
getenv
(
SOCKET_ENV
);
}
/* Unlink if it exists */
unlink
(
backend_socket_path
);
/* Create socket */
backendSocket
=
socket
(
AF_UNIX
,
SOCK_STREAM
|
SOCK_NONBLOCK
,
0
);
if
(
backendSocket
<
0
)
{
err
(
-
1
,
"socket"
);
}
/* Create sockaddr and bind */
struct
sockaddr_un
sa
;
sa
.
sun_family
=
AF_UNIX
;
strncpy
(
sa
.
sun_path
,
backend_socket_path
,
107
);
sa
.
sun_path
[
107
]
=
'\0'
;
if
(
bind
(
backendSocket
,
(
struct
sockaddr
*
)
&
sa
,
sizeof
(
sa
)))
{
err
(
-
1
,
"bind"
);
}
/* Listen */
if
(
listen
(
backendSocket
,
16
))
{
err
(
-
1
,
"listen"
);
}
/* Add to socket set */
safe_fd_set
(
backendSocket
,
&
rfds
,
&
max_fd
);
signal
(
SIGINT
,
killHandler
);
...
...
@@ -123,8 +161,6 @@ int main(int argc, char **argv)
// writeStringToLog(logHeader);
// clear the fd set
FD_ZERO
(
&
rfds
);
// watch for input from stdin (fd 0) to see when it has input
safe_fd_set
(
fileno
(
stdin
),
&
rfds
,
&
max_fd
);
// watch for input from the zybo socket
...
...
@@ -148,7 +184,7 @@ int main(int argc, char **argv)
if
(
activity
==
-
1
)
{
perror
(
"select() "
);
}
else
if
(
activity
)
{
for
(
unsigned
int
fd
=
0
;
fd
<=
max_fd
;
++
fd
)
{
for
(
int
fd
=
0
;
fd
<=
max_fd
;
++
fd
)
{
if
(
FD_ISSET
(
fd
,
&
rfds
))
{
if
(
fd
==
fileno
(
stdin
))
{
unsigned
char
userCommand
[
CMD_MAX_LENGTH
]
=
{};
...
...
@@ -180,6 +216,13 @@ int main(int argc, char **argv)
memset
(
userCommand
,
0
,
cmdLen
);
}
else
if
(
fd
==
zyboSocket
)
{
}
else
if
(
fd
==
backendSocket
)
{
int
new_fd
=
0
;
new_fd
=
accept
(
backendSocket
,
NULL
,
NULL
);
if
(
new_fd
<
0
)
{
warn
(
"accept"
);
}
else
{
}
}
}
}
...
...
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