Commit 83797a1c authored by Mathias Kreider's avatar Mathias Kreider

Added findById for single device

parent 26af97f0
......@@ -2,4 +2,8 @@ import eb
ebobj = eb.EbWrapper()
ebobj.connect("dev/ttyUSB0")
print("0x%8x" % ebobj.read(0x4120000))
\ No newline at end of file
vendorID = 0x0000000000000651
productID = 0x10040200
prioAdr = ebobj.findById(vendorID, productID)
print("prioadr 0x%8x " % (prioAdr))
print("1st word ram 0x%8x" % ebobj.read(0x4120000))
......@@ -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
......@@ -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
......@@ -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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment