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
2c648c1f
Commit
2c648c1f
authored
13 years ago
by
Wesley W. Terpstra
Browse files
Options
Downloads
Patches
Plain Diff
Make the demos test for segfault and report remote device properties.
parent
478cd2d3
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/demo/eb-read.c
+8
-5
8 additions, 5 deletions
api/demo/eb-read.c
api/demo/eb-snoop.c
+2
-2
2 additions, 2 deletions
api/demo/eb-snoop.c
api/demo/eb-write.c
+29
-5
29 additions, 5 deletions
api/demo/eb-write.c
with
39 additions
and
12 deletions
api/demo/eb-read.c
+
8
−
5
View file @
2c648c1f
...
...
@@ -47,6 +47,7 @@ int main(int argc, const char** argv) {
eb_socket_t
socket
;
eb_status_t
status
;
eb_device_t
device
;
eb_width_t
width
;
eb_cycle_t
cycle
;
eb_address_t
address
;
const
char
*
netaddress
;
...
...
@@ -65,16 +66,17 @@ int main(int argc, const char** argv) {
return
1
;
}
if
((
status
=
eb_device_open
(
socket
,
netaddress
,
EB_ADDR
32
|
EB_DATA
16
,
3
,
&
device
))
!=
EB_OK
)
{
if
((
status
=
eb_device_open
(
socket
,
netaddress
,
EB_ADDR
X
|
EB_DATA
X
,
3
,
&
device
))
!=
EB_OK
)
{
fprintf
(
stderr
,
"Failed to open Etherbone device: %s
\n
"
,
eb_status
(
status
));
return
1
;
}
stop
=
0
;
fprintf
(
stdout
,
"Reading from device %s at %08"
EB_ADDR_FMT
": "
,
netaddress
,
address
);
width
=
eb_device_width
(
device
);
fprintf
(
stdout
,
"Connected to %s with %d/%d-bit address/port widths
\n\n
"
,
netaddress
,
(
width
>>
4
)
*
8
,
(
width
&
EB_DATAX
)
*
8
);
fprintf
(
stdout
,
"Reading at %016"
EB_ADDR_FMT
": "
,
address
);
fflush
(
stdout
);
/* A simple cycle */
if
((
cycle
=
eb_cycle_open
(
device
,
&
stop
,
&
set_stop
))
==
EB_NULL
)
{
fprintf
(
stderr
,
"out of memory
\n
"
);
return
1
;
...
...
@@ -82,8 +84,9 @@ int main(int argc, const char** argv) {
eb_cycle_read
(
cycle
,
address
,
EB_DATAX
,
0
);
eb_cycle_close
(
cycle
);
stop
=
0
;
eb_device_flush
(
device
);
while
(
!
stop
)
{
eb_socket_block
(
socket
,
0
);
eb_socket_poll
(
socket
);
...
...
This diff is collapsed.
Click to expand it.
api/demo/eb-snoop.c
+
2
−
2
View file @
2c648c1f
...
...
@@ -32,12 +32,12 @@
static
eb_status_t
my_read
(
eb_user_data_t
user
,
eb_address_t
address
,
eb_width_t
width
,
eb_data_t
*
data
)
{
fprintf
(
stdout
,
"Received read to address %016"
EB_ADDR_FMT
" of %d bits
\n
"
,
address
,
(
width
&
EB_DATAX
)
*
8
);
*
data
=
UINT64_C
(
0x1234567890abcdef
);
return
EB_OK
;
return
(
address
==
0
)
?
EB_FAIL
:
EB_OK
;
}
static
eb_status_t
my_write
(
eb_user_data_t
user
,
eb_address_t
address
,
eb_width_t
width
,
eb_data_t
data
)
{
fprintf
(
stdout
,
"Received write to address %016"
EB_ADDR_FMT
" of %d bits: %016"
EB_DATA_FMT
"
\n
"
,
address
,
(
width
&
EB_DATAX
)
*
8
,
data
);
return
EB_OK
;
return
(
address
==
0
)
?
EB_FAIL
:
EB_OK
;
}
int
main
(
int
argc
,
const
char
**
argv
)
{
...
...
This diff is collapsed.
Click to expand it.
api/demo/eb-write.c
+
29
−
5
View file @
2c648c1f
...
...
@@ -29,14 +29,30 @@
#include
<stdlib.h>
#include
"../etherbone.h"
static
void
set_stop
(
eb_user_data_t
user
,
eb_operation_t
op
,
eb_status_t
status
)
{
int
*
stop
=
(
int
*
)
user
;
*
stop
=
1
;
if
(
status
!=
EB_OK
)
{
fprintf
(
stdout
,
"%s
\n
"
,
eb_status
(
status
));
}
else
{
if
(
eb_operation_had_error
(
op
))
fprintf
(
stdout
,
" <<-- wishbone segfault -->>
\n
"
);
else
fprintf
(
stdout
,
"done
\n
"
);
}
}
int
main
(
int
argc
,
const
char
**
argv
)
{
eb_socket_t
socket
;
eb_status_t
status
;
eb_device_t
device
;
eb_width_t
width
;
eb_cycle_t
cycle
;
eb_address_t
address
;
eb_data_t
data
;
const
char
*
netaddress
;
int
stop
;
if
(
argc
!=
4
)
{
fprintf
(
stderr
,
"Syntax: %s <protocol/host/port> <address> <data>
\n
"
,
argv
[
0
]);
...
...
@@ -57,18 +73,26 @@ int main(int argc, const char** argv) {
return
1
;
}
fprintf
(
stdout
,
"Writing to device %s at %08"
EB_ADDR_FMT
": %08"
EB_DATA_FMT
": "
,
netaddress
,
address
,
data
);
width
=
eb_device_width
(
device
);
fprintf
(
stdout
,
"Connected to %s with %d/%d-bit address/port widths
\n\n
"
,
netaddress
,
(
width
>>
4
)
*
8
,
(
width
&
EB_DATAX
)
*
8
);
fprintf
(
stdout
,
"Writing at %016"
EB_ADDR_FMT
": %016"
EB_DATA_FMT
": "
,
address
,
data
);
fflush
(
stdout
);
if
((
cycle
=
eb_cycle_open
(
device
,
0
,
0
))
==
EB_NULL
)
{
if
((
cycle
=
eb_cycle_open
(
device
,
&
stop
,
&
set_stop
))
==
EB_NULL
)
{
fprintf
(
stdout
,
"out of memory
\n
"
);
return
1
;
}
eb_cycle_write
(
cycle
,
address
,
EB_DATAX
,
data
);
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
"
);
eb_cycle_close
(
cycle
);
stop
=
0
;
eb_device_flush
(
device
);
while
(
!
stop
)
{
eb_socket_block
(
socket
,
-
1
);
eb_socket_poll
(
socket
);
}
if
((
status
=
eb_device_close
(
device
))
!=
EB_OK
)
{
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