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
691deb57
Unverified
Commit
691deb57
authored
8 years ago
by
Jake Drahos
Browse files
Options
Downloads
Patches
Plain Diff
Added support for using WiFi
parent
96567f5a
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
+5
-0
5 additions, 0 deletions
groundStation/src/config.h
groundStation/src/microcart_cli.c
+52
-12
52 additions, 12 deletions
groundStation/src/microcart_cli.c
with
58 additions
and
13 deletions
groundStation/Makefile
+
1
−
1
View file @
691deb57
...
...
@@ -2,7 +2,7 @@
GCC
=
gcc
GXX
=
g++
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
CXXFLAGS
=
-Wall
-Wno-reorder
-std
=
c++
0x
-g
INCLUDES
=
$(
foreach
dir
,
$(
INCDIR
)
,
-I
$(
dir
))
# Directories
...
...
This diff is collapsed.
Click to expand it.
groundStation/src/config.h
+
5
−
0
View file @
691deb57
...
...
@@ -6,5 +6,10 @@
#define SOCKET_ENV "UCART_SOCKET"
#define NOQUAD_ENV "UCART_NO_QUAD"
#define QUAD_WIFI_ENV "UCART_USE_WIFI"
#define QUAD_IP_ENV "UCART_QUAD_IP"
#define QUAD_IP_DEFAULT "192.168.4.1"
#define QUAD_PORT_ENV "UCART_QUAD_PORT"
#define QUAD_PORT_DEFAULT 8080
#endif
This diff is collapsed.
Click to expand it.
groundStation/src/microcart_cli.c
+
52
−
12
View file @
691deb57
...
...
@@ -4,6 +4,7 @@
*/
#define _GNU_SOURCE
#define _BSD_SOURCE
//system includes
#include
<err.h>
...
...
@@ -13,6 +14,8 @@
#include
<signal.h>
#include
<sys/socket.h>
#include
<sys/un.h>
#include
<netinet/in.h>
#include
<arpa/inet.h>
#include
<sys/select.h>
#include
<bluetooth/bluetooth.h>
#include
<bluetooth/rfcomm.h>
...
...
@@ -366,25 +369,62 @@ void printVrpnData(struct ucart_vrpn_TrackerData * td) {
int
connectToZybo
()
{
int
sock
;
struct
sockaddr_rc
addr
;
int
status
;
// allocate a socket
sock
=
socket
(
AF_BLUETOOTH
,
SOCK_STREAM
,
BTPROTO_RFCOMM
);
/* Use bluetooth by default */
if
(
getenv
(
QUAD_WIFI_ENV
)
==
NULL
)
{
struct
sockaddr_rc
addr
;
//set the connection params ie. who to connect to
addr
.
rc_family
=
AF_BLUETOOTH
;
addr
.
rc_channel
=
(
uint8_t
)
QUAD_BT_CHANNEL
;
str2ba
(
QUAD_BT_ADDR
,
&
addr
.
rc_bdaddr
);
printf
(
"Attempting to connect to zybo. Please be patient...
\n
"
);
// blocking call to connect to socket sock ie. zybo board
int
status
=
connect
(
sock
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
// allocate a socket
sock
=
socket
(
AF_BLUETOOTH
,
SOCK_STREAM
,
BTPROTO_RFCOMM
);
//set the connection params ie. who to connect to
addr
.
rc_family
=
AF_BLUETOOTH
;
addr
.
rc_channel
=
(
uint8_t
)
QUAD_BT_CHANNEL
;
str2ba
(
QUAD_BT_ADDR
,
&
addr
.
rc_bdaddr
);
printf
(
"Attempting to connect to zybo. Please be patient...
\n
"
);
// blocking call to connect to socket sock ie. zybo board
status
=
connect
(
sock
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
}
else
{
struct
sockaddr_in
addr
;
addr
.
sin_family
=
AF_INET
;
/* Quick and Dirty */
if
(
getenv
(
QUAD_IP_ENV
))
{
if
(
!
inet_aton
(
getenv
(
QUAD_IP_ENV
),
&
addr
.
sin_addr
))
{
fprintf
(
stderr
,
"Env var %s invalid IP %s
\n
"
,
QUAD_IP_ENV
,
getenv
(
QUAD_IP_ENV
));
return
-
1
;
}
}
else
{
if
(
!
inet_aton
(
QUAD_IP_DEFAULT
,
&
addr
.
sin_addr
))
{
fprintf
(
stderr
,
"Default IP %s is invalid
\n
"
,
QUAD_IP_DEFAULT
);
return
-
1
;
}
}
if
(
getenv
(
QUAD_PORT_ENV
))
{
/* Quick 'n dirty, oh yeah! */
addr
.
sin_family
=
atoi
(
getenv
(
QUAD_PORT_ENV
));
}
else
{
addr
.
sin_family
=
QUAD_PORT_DEFAULT
;
}
sock
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
sock
<
0
)
{
perror
(
"socket"
);
return
-
1
;
}
}
// connection failed
if
(
status
<
0
)
{
close
(
sock
);
p
rintf
(
"
C
onnect
ion failed!...
\n
"
);
p
error
(
"
c
onnect"
);
return
-
1
;
}
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