mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-05-15 08:35:34 +02:00
Read and write SPI for Xilinx CTB (#1381)
Build on RHEL9 / build (push) Successful in 3m25s
Build on RHEL8 / build (push) Successful in 4m37s
Run Simulator Tests on local RHEL9 / build (push) Successful in 14m42s
Build on local RHEL9 / build (push) Successful in 1m26s
Run Simulator Tests on local RHEL8 / build (push) Successful in 17m0s
Build on local RHEL8 / build (push) Successful in 3m32s
Build on RHEL9 / build (push) Successful in 3m25s
Build on RHEL8 / build (push) Successful in 4m37s
Run Simulator Tests on local RHEL9 / build (push) Successful in 14m42s
Build on local RHEL9 / build (push) Successful in 1m26s
Run Simulator Tests on local RHEL8 / build (push) Successful in 17m0s
Build on local RHEL8 / build (push) Successful in 3m32s
-readSpi and writeSpi in C++ and Python API
This commit is contained in:
@@ -4074,4 +4074,45 @@ void Module::simulatingActivityinDetector(const std::string &functionType,
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Module::readSpi(int chip_id, int register_id,
|
||||
int n_bytes) const{
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(F_SPI_READ);
|
||||
client.setFnum(F_SPI_READ);
|
||||
client.Send(chip_id);
|
||||
client.Send(register_id);
|
||||
client.Send(n_bytes);
|
||||
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw DetectorError(os.str());
|
||||
}
|
||||
|
||||
std::vector<uint8_t> data(n_bytes);
|
||||
client.Receive(data);
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
void Module::writeSpi(int chip_id, int register_id,
|
||||
const std::vector<uint8_t> &data){
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(F_SPI_WRITE);
|
||||
client.setFnum(F_SPI_WRITE);
|
||||
client.Send(chip_id);
|
||||
client.Send(register_id);
|
||||
client.Send(static_cast<int>(data.size()));
|
||||
client.Send(data);
|
||||
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw DetectorError(os.str());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
|
||||
Reference in New Issue
Block a user