Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EtherBone Core
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
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
Projects
EtherBone Core
Commits
0c06f17a
Commit
0c06f17a
authored
13 years ago
by
Wesley W. Terpstra
Browse files
Options
Downloads
Patches
Plain Diff
Better example using a full cycle.
parent
8fca61ae
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/demo/eb-read.c
+9
-1
9 additions, 1 deletion
api/demo/eb-read.c
api/demo/eb-write.c
+10
-4
10 additions, 4 deletions
api/demo/eb-write.c
with
19 additions
and
5 deletions
api/demo/eb-read.c
+
9
−
1
View file @
0c06f17a
...
@@ -47,6 +47,7 @@ int main(int argc, const char** argv) {
...
@@ -47,6 +47,7 @@ int main(int argc, const char** argv) {
eb_socket_t
socket
;
eb_socket_t
socket
;
eb_status_t
status
;
eb_status_t
status
;
eb_device_t
device
;
eb_device_t
device
;
eb_cycle_t
cycle
;
eb_address_t
address
;
eb_address_t
address
;
const
char
*
netaddress
;
const
char
*
netaddress
;
int
stop
;
int
stop
;
...
@@ -73,7 +74,14 @@ int main(int argc, const char** argv) {
...
@@ -73,7 +74,14 @@ int main(int argc, const char** argv) {
fprintf
(
stdout
,
"Reading from device %s at %08"
EB_ADDR_FMT
": "
,
netaddress
,
address
);
fprintf
(
stdout
,
"Reading from device %s at %08"
EB_ADDR_FMT
": "
,
netaddress
,
address
);
fflush
(
stdout
);
fflush
(
stdout
);
eb_device_read
(
device
,
address
,
0
,
&
stop
,
&
set_stop
);
/* A simple cycle */
if
((
cycle
=
eb_cycle_open
(
device
,
&
stop
,
&
set_stop
))
==
EB_NULL
)
{
fprintf
(
stderr
,
"out of memory
\n
"
);
return
1
;
}
eb_cycle_read
(
cycle
,
address
,
0
);
eb_cycle_close
(
cycle
);
eb_device_flush
(
device
);
eb_device_flush
(
device
);
while
(
!
stop
)
{
while
(
!
stop
)
{
...
...
This diff is collapsed.
Click to expand it.
api/demo/eb-write.c
+
10
−
4
View file @
0c06f17a
...
@@ -33,6 +33,7 @@ int main(int argc, const char** argv) {
...
@@ -33,6 +33,7 @@ int main(int argc, const char** argv) {
eb_socket_t
socket
;
eb_socket_t
socket
;
eb_status_t
status
;
eb_status_t
status
;
eb_device_t
device
;
eb_device_t
device
;
eb_cycle_t
cycle
;
eb_address_t
address
;
eb_address_t
address
;
eb_data_t
data
;
eb_data_t
data
;
const
char
*
netaddress
;
const
char
*
netaddress
;
...
@@ -59,10 +60,15 @@ int main(int argc, const char** argv) {
...
@@ -59,10 +60,15 @@ int main(int argc, const char** argv) {
fprintf
(
stdout
,
"Writing to device %s at %08"
EB_ADDR_FMT
": %08"
EB_DATA_FMT
": "
,
netaddress
,
address
,
data
);
fprintf
(
stdout
,
"Writing to device %s at %08"
EB_ADDR_FMT
": %08"
EB_DATA_FMT
": "
,
netaddress
,
address
,
data
);
fflush
(
stdout
);
fflush
(
stdout
);
status
=
eb_device_write
(
device
,
address
,
data
,
0
,
0
);
if
((
cycle
=
eb_cycle_open
(
device
,
0
,
0
))
==
EB_NULL
)
{
fprintf
(
stdout
,
"%s
\n
"
,
eb_status
(
status
));
fprintf
(
stdout
,
"out of memory
\n
"
);
return
1
;
eb_device_flush
(
device
);
}
eb_cycle_read
(
cycle
,
address
,
0
);
eb_cycle_close_silently
(
cycle
);
/* silently means we don't care about the ERR flag */
eb_device_flush
(
device
);
/* flush queued data out the device */
fprintf
(
stdout
,
"ok
\n
"
);
if
((
status
=
eb_device_close
(
device
))
!=
EB_OK
)
{
if
((
status
=
eb_device_close
(
device
))
!=
EB_OK
)
{
fprintf
(
stderr
,
"Failed to close Etherbone device: %s
\n
"
,
eb_status
(
status
));
fprintf
(
stderr
,
"Failed to close Etherbone device: %s
\n
"
,
eb_status
(
status
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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