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
84dd0658
Unverified
Commit
84dd0658
authored
8 years ago
by
Jake Drahos
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of git.ece.iastate.edu:danc/MicroCART_17-18
parents
bd916f39
4b5772bb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
groundStation/src/cli/cli.c
+7
-43
7 additions, 43 deletions
groundStation/src/cli/cli.c
groundStation/src/cli/cli.h
+2
-2
2 additions, 2 deletions
groundStation/src/cli/cli.h
with
9 additions
and
45 deletions
groundStation/src/cli/cli.c
+
7
−
43
View file @
84dd0658
#include
<stdio.h>
#include
<stdlib.h>
#include
<errno.h>
#include
<string.h>
#include
<sys/types.h>
#include
<sys/socket.h>
#include
<sys/un.h>
#include
<unistd.h>
#include
<string.h>
#include
<err.h>
#include
"cli.h"
#include
"frontend_common.h"
int
connectToBackEnd
();
...
...
@@ -18,7 +12,8 @@ int main(int argc, char **argv)
{
int
cmdID
=
-
1
;
char
*
command
;
int
i
,
s
,
useSymlink
=
0
;
int
i
,
useSymlink
=
0
;
struct
backend_conn
*
conn
;
command
=
argv
[
0
];
for
(
i
=
0
;
i
<
MAX_COMMANDS
;
++
i
)
{
...
...
@@ -26,7 +21,7 @@ int main(int argc, char **argv)
{
cmdID
=
i
;
useSymlink
=
1
;
}
}
}
if
(
cmdID
==
-
1
)
{
...
...
@@ -45,47 +40,16 @@ int main(int argc, char **argv)
}
printf
(
"Parsed Command : %s
\n
"
,
commandNames
[
cmdID
]);
if
((
s
=
connectToBackEnd
())
==
-
1
)
{
err
(
-
1
,
"connectToBackEnd"
);
}
conn
=
ucart_backendConnect
();
printf
(
"connection to backend Successful
\n
"
);
if
(
useSymlink
)
{
//TODO Call correct command function pointer with (argv[1] ... argc[argc])
}
else
{
//TODO Call correct command function pointer with (argv[2] ... argv[argc])
}
close
(
s
);
ucart_backendDisconnect
(
conn
);
return
0
;
}
int
connectToBackEnd
()
{
int
s
,
t
,
len
;
struct
sockaddr_un
remote
;
char
str
[
100
];
if
((
s
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
0
))
==
-
1
)
{
perror
(
"socket"
);
exit
(
1
);
}
printf
(
"Trying to connect...
\n
"
);
remote
.
sun_family
=
AF_UNIX
;
strcpy
(
remote
.
sun_path
,
SOCK_PATH
);
len
=
strlen
(
remote
.
sun_path
)
+
sizeof
(
remote
.
sun_family
);
if
(
connect
(
s
,
(
struct
sockaddr
*
)
&
remote
,
sizeof
(
remote
))
==
-
1
)
{
perror
(
"connect"
);
exit
(
1
);
}
else
{
printf
(
"Connected.
\n
"
);
return
s
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
groundStation/src/cli/cli.h
+
2
−
2
View file @
84dd0658
#ifndef __CLI_H
#define __CLI_H
#define SOCK_PATH "/var/run/ucart.socket"
enum
CommandNameIds
{
CMD_MONITOR
,
CMD_SETPID
,
...
...
@@ -18,4 +16,6 @@ static char* commandNames[MAX_COMMANDS] = {
"getImu"
};
static
#endif
\ No newline at end of file
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