Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
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
Distributed Autonomous Networked Control Lab
MicroCART
Commits
f6854896
Commit
f6854896
authored
8 years ago
by
Jake Drahos
Browse files
Options
Downloads
Patches
Plain Diff
Still kinda broken
parent
a309c835
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
groundStation/Makefile
+1
-1
1 addition, 1 deletion
groundStation/Makefile
groundStation/src/config.h
+1
-0
1 addition, 0 deletions
groundStation/src/config.h
groundStation/src/microcart_cli.c
+25
-9
25 additions, 9 deletions
groundStation/src/microcart_cli.c
with
27 additions
and
10 deletions
groundStation/Makefile
+
1
−
1
View file @
f6854896
# Declaration of variables
GCC
=
gcc
GXX
=
g++
CFLAGS
=
-Wall
-Wpedantic
-Wextra
-Werror
-std
=
c99
-g
-Wno-unused-parameter
-Wno-unused-variable
-Wno-unused-function
CFLAGS
=
-Wall
-Wpedantic
-Wextra
-Werror
-std
=
c99
-g
-Wno-unused-parameter
-Wno-unused-variable
-Wno-unused-function
-Wno-unused-but-set-variable
CXXFLAGS
=
-Wall
-Wno-reorder
-std
=
c++11
-g
INCLUDES
=
$(
foreach
dir
,
$(
INCDIR
)
,
-I
$(
dir
))
...
...
This diff is collapsed.
Click to expand it.
groundStation/src/config.h
+
1
−
0
View file @
f6854896
...
...
@@ -4,6 +4,7 @@
#define DEFAULT_SOCKET "/var/run/ucart.socket"
#define SOCKET_ENV "UCART_SOCKET"
#define NOQUAD_ENV "UCART_NO_QUAD"
#endif
This diff is collapsed.
Click to expand it.
groundStation/src/microcart_cli.c
+
25
−
9
View file @
f6854896
...
...
@@ -110,10 +110,10 @@ static void cb(struct ucart_vrpn_TrackerData * td)
int
main
(
int
argc
,
char
**
argv
)
{
// pthread_t quadResponse, cliInput;
fd_set
rfds
;
fd_set
rfds
_master
;
int
activity
;
int
max_fd
=
0
;
FD_ZERO
(
&
rfds
);
FD_ZERO
(
&
rfds
_master
);
/*
* Create backend listening socket
...
...
@@ -147,7 +147,7 @@ int main(int argc, char **argv)
}
/* Add to socket set */
safe_fd_set
(
backendSocket
,
&
rfds
,
&
max_fd
);
safe_fd_set
(
backendSocket
,
&
rfds
_master
,
&
max_fd
);
/* Initialize client buffers */
...
...
@@ -185,11 +185,10 @@ int main(int argc, char **argv)
}
// writeStringToLog(logHeader);
// watch for input from stdin (fd 0) to see when it has input
safe_fd_set
(
fileno
(
stdin
),
&
rfds
,
&
max_fd
);
safe_fd_set
(
fileno
(
stdin
),
&
rfds
_master
,
&
max_fd
);
// watch for input from the zybo socket
//safe_fd_set(zyboSocket, &rfds, &max_fd);
//safe_fd_set(zyboSocket, &rfds
_master
, &max_fd);
//printf("zyboSocket = %d, max_fd = %d\n", zyboSocket, max_fd);
...
...
@@ -203,14 +202,23 @@ int main(int argc, char **argv)
// start the prompt
fprintf
(
stdout
,
"$microcart> "
);
struct
timeval
timeout
=
{
.
tv_sec
=
1
,
.
tv_usec
=
0
};
while
(
keepRunning
)
{
fd_set
rfds
;
rfds
=
rfds_master
;
activity
=
select
(
max_fd
+
1
,
&
rfds
,
NULL
,
NULL
,
NULL
);
if
(
activity
==
-
1
)
{
perror
(
"select() "
);
}
else
if
(
activity
)
{
fprintf
(
stderr
,
"Select activity = %d
\n
"
,
activity
);
for
(
int
fd
=
0
;
fd
<=
max_fd
;
++
fd
)
{
if
(
FD_ISSET
(
fd
,
&
rfds
))
{
fprintf
(
stderr
,
"Select woke for fd %d
\n
"
,
fd
);
if
(
fd
==
fileno
(
stdin
))
{
unsigned
char
userCommand
[
CMD_MAX_LENGTH
];
read
(
fileno
(
stdin
),
(
char
*
)
userCommand
,
sizeof
(
userCommand
));
...
...
@@ -247,8 +255,10 @@ int main(int argc, char **argv)
if
(
new_fd
<
0
)
{
warn
(
"accept"
);
}
else
{
if
(
new_client
(
fd
))
{
safe_fd_set
(
fd
,
&
rfds
,
&
max_fd
);
fprintf
(
stderr
,
"Connection
\n
"
);
if
(
new_client
(
new_fd
))
{
fprintf
(
stderr
,
"Added client
\n
"
);
safe_fd_set
(
new_fd
,
&
rfds_master
,
&
max_fd
);
}
}
}
else
if
(
get_client_index
(
fd
)
>
-
1
)
{
...
...
@@ -264,6 +274,8 @@ int main(int argc, char **argv)
remove_client
(
client_fds
[
i
]);
}
}
timeout
.
tv_sec
=
1
;
timeout
.
tv_usec
=
0
;
}
}
...
...
@@ -431,6 +443,9 @@ int safe_fd_clr(int fd, fd_set* fds, int* max_fd) {
static
ssize_t
writeQuad
(
const
char
*
buf
,
size_t
count
)
{
ssize_t
retval
;
if
(
getenv
(
NOQUAD_ENV
))
{
return
count
;
}
if
(
pthread_mutex_lock
(
&
quadSocketMutex
))
{
err
(
-
2
,
"pthrtead_mutex_lock (%s:%d):"
,
__FILE__
,
__LINE__
);
}
...
...
@@ -542,8 +557,9 @@ static void client_recv(int fd)
buffer
[
newline
]
=
'\0'
;
unsigned
char
*
packet
;
fprintf
(
stderr
,
"Client sent: %s
\n
"
,
buffer
);
formatCommand
((
unsigned
char
*
)
buffer
,
&
packet
);
writeQuad
((
char
*
)
packet
,
packet
[
6
]
<<
8
);
writeQuad
((
char
*
)
packet
,
4
);
free
(
packet
);
char
*
rest
=
&
buffer
[
newline
]
+
1
;
...
...
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