Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
EtherBone Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
EtherBone Core
Commits
83797a1c
Commit
83797a1c
authored
Mar 31, 2020
by
Mathias Kreider
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added findById for single device
parent
26af97f0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
6 deletions
+41
-6
ebtest.py
api/ebPy/ebtest.py
+5
-1
ebwrapper.h
api/ebPy/inc/ebwrapper.h
+1
-0
ebwrapper_impl.h
api/ebPy/inc/ebwrapper_impl.h
+1
-0
ebwrapper.cpp
api/ebPy/src/ebwrapper.cpp
+6
-5
ebwrapper_impl.cpp
api/ebPy/src/ebwrapper_impl.cpp
+28
-0
No files found.
api/ebPy/ebtest.py
View file @
83797a1c
...
...
@@ -2,4 +2,8 @@ import eb
ebobj
=
eb
.
EbWrapper
()
ebobj
.
connect
(
"dev/ttyUSB0"
)
print
(
"0x
%8
x"
%
ebobj
.
read
(
0x4120000
))
\ No newline at end of file
vendorID
=
0x0000000000000651
productID
=
0x10040200
prioAdr
=
ebobj
.
findById
(
vendorID
,
productID
)
print
(
"prioadr 0x
%8
x "
%
(
prioAdr
))
print
(
"1st word ram 0x
%8
x"
%
ebobj
.
read
(
0x4120000
))
api/ebPy/inc/ebwrapper.h
View file @
83797a1c
...
...
@@ -24,6 +24,7 @@ public:
void
write
(
const
unsigned
addr
,
const
unsigned
value
)
const
;
//std::vector<unsigned> readCycle(std::vector<unsigned> vAddr) const;
unsigned
read
(
const
unsigned
addr
)
const
;
unsigned
findById
(
const
unsigned
long
vendor
,
const
unsigned
id
);
};
#endif
\ No newline at end of file
api/ebPy/inc/ebwrapper_impl.h
View file @
83797a1c
...
...
@@ -35,6 +35,7 @@ public:
void
write
(
const
unsigned
addr
,
const
unsigned
value
);
//std::vector<unsigned> readCycle(std::vector<unsigned> vAddr) const;
unsigned
read
(
const
unsigned
addr
);
unsigned
findById
(
const
unsigned
long
vendor
,
const
unsigned
id
);
};
#endif
\ No newline at end of file
api/ebPy/src/ebwrapper.cpp
View file @
83797a1c
...
...
@@ -4,8 +4,9 @@
EbWrapper
::
EbWrapper
()
:
impl_
(
new
EbWrapperImpl
())
{}
EbWrapper
::~
EbWrapper
()
=
default
;
// Etherbone interface
bool
EbWrapper
::
connect
(
const
std
::
string
&
en
)
{
return
impl_
->
connect
(
en
);}
//Open connection to a DM via Etherbone
bool
EbWrapper
::
disconnect
()
{
return
impl_
->
disconnect
();}
//Close connection
void
EbWrapper
::
write
(
const
unsigned
addr
,
const
unsigned
value
)
const
{
return
impl_
->
write
(
addr
,
value
);}
//Open connection to a DM via Etherbone
unsigned
EbWrapper
::
read
(
const
unsigned
addr
)
const
{
return
impl_
->
read
(
addr
);}
//Close connection
\ No newline at end of file
// Etherbone interface
bool
EbWrapper
::
connect
(
const
std
::
string
&
en
)
{
return
impl_
->
connect
(
en
);}
//Open connection to a DM via Etherbone
bool
EbWrapper
::
disconnect
()
{
return
impl_
->
disconnect
();}
//Close connection
void
EbWrapper
::
write
(
const
unsigned
addr
,
const
unsigned
value
)
const
{
return
impl_
->
write
(
addr
,
value
);}
//Open connection to a DM via Etherbone
unsigned
EbWrapper
::
read
(
const
unsigned
addr
)
const
{
return
impl_
->
read
(
addr
);}
//Close connection
unsigned
EbWrapper
::
findById
(
const
unsigned
long
vendor
,
const
unsigned
id
)
{
return
impl_
->
findById
(
vendor
,
id
);}
\ No newline at end of file
api/ebPy/src/ebwrapper_impl.cpp
View file @
83797a1c
...
...
@@ -37,4 +37,32 @@ bool EbWrapper::EbWrapperImpl::connect(const std::string& dev) {
eb_data_t
ret
;
ebd
.
read
((
eb_address_t
)
addr
,
EB_DATAX
|
EB_ADDRX
,
(
eb_data_t
*
)
&
ret
);
return
(
unsigned
)
ret
;
}
/*
void EbWrapper::EbWrapperImpl::write(const std::vector<unsigned> addr&, const std::vector<unsigned> value&) {
Cycle cyc;
cyc.open(ebd);
if addr.size() != value.size() throw std::runtime_error("Address and value vectors must be the same size");
for (auto& [a, v] : zip(addr, value)) {cyc.write((eb_address_t)a, EB_DATAX|EB_ADDRX, (eb_data_t)v);}
cyc.close();
}
//std::vector<unsigned> readCycle(std::vector<unsigned> vAddr) const;
unsigned EbWrapper::EbWrapperImpl::read(const unsigned addr) {
eb_data_t ret;
ebd.read((eb_address_t)addr, EB_DATAX|EB_ADDRX, (eb_data_t*)&ret);
return (unsigned)ret;
}
*/
unsigned
EbWrapper
::
EbWrapperImpl
::
findById
(
const
unsigned
long
vendor
,
const
unsigned
id
)
{
std
::
vector
<
struct
sdb_device
>
devs
;
unsigned
retAdr
=
-
1
;
unsigned
cnt
=
0
;
ebd
.
sdb_find_by_identity
((
uint64_t
)
vendor
,
(
uint32_t
)
id
,
devs
);
cnt
=
devs
.
size
();
if
(
cnt
>
0
)
retAdr
=
devs
[
0
].
sdb_component
.
addr_first
;
return
retAdr
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment