Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
raven2_sim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
DEPEND
raven2_sim
Commits
473d9e1c
Commit
473d9e1c
authored
10 years ago
by
Homa Alemzadeh
Browse files
Options
Downloads
Patches
Plain Diff
The new Write_USB_packets function logs the USB packets
parent
3cf2f767
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/raven/put_USB_packet.cpp
+43
-1
43 additions, 1 deletion
src/raven/put_USB_packet.cpp
with
43 additions
and
1 deletion
src/raven/put_USB_packet.cpp
+
43
−
1
View file @
473d9e1c
...
...
@@ -30,7 +30,7 @@
extern
unsigned
long
int
gTime
;
extern
USBStruct
USBBoards
;
extern
char
*
raven_path
;
/**\fn void putUSBPackets(struct device *device0)
\brief Takes data from robot to send to USB board(s)
\struct device
...
...
@@ -97,3 +97,45 @@ int putUSBPacket(int id, struct mechanism *mech)
return
0
;
}
#ifdef log_USB
void
writeUSBPackets
(
struct
device
*
device0
)
{
for
(
int
j
=
0
;
j
<
2
;
j
++
)
{
struct
mechanism
*
mech
=
&
(
device0
->
mech
[
j
]);
int
i
=
0
;
unsigned
char
buffer_out
[
MAX_OUT_LENGTH
];
buffer_out
[
0
]
=
DAC
;
//Type of USB packet
buffer_out
[
1
]
=
MAX_DOF_PER_MECH
;
//Number of DAC channels
for
(
i
=
0
;
i
<
MAX_DOF_PER_MECH
;
i
++
)
{
//Factor in offset since we are in midrange operation
mech
->
joint
[
i
].
current_cmd
+=
DAC_OFFSET
;
buffer_out
[
2
*
i
+
2
]
=
(
char
)(
mech
->
joint
[
i
].
current_cmd
);
buffer_out
[
2
*
i
+
3
]
=
(
char
)(
mech
->
joint
[
i
].
current_cmd
>>
8
);
//Remove offset
mech
->
joint
[
i
].
current_cmd
-=
DAC_OFFSET
;
}
// Set PortF outputs
buffer_out
[
OUT_LENGTH
-
1
]
=
mech
->
outputs
;
char
buff
[
50
];
sprintf
(
buff
,
"%s/USB%d_log.txt"
,
raven_path
,
j
);
std
::
ofstream
USBlogfile
;
USBlogfile
.
open
(
buff
,
std
::
ofstream
::
out
|
std
::
ofstream
::
app
);
for
(
int
k
=
0
;
k
<
OUT_LENGTH
;
k
++
)
{
USBlogfile
<<
std
::
hex
<<
(
unsigned
)
buffer_out
[
k
]
<<
" "
;
}
USBlogfile
<<
"
\n
"
;
USBlogfile
.
close
();
}
}
#endif
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