From e18a731a84d4d979c3afdb23f537b9d541a9eda5 Mon Sep 17 00:00:00 2001 From: Alice Date: Wed, 29 Jul 2026 14:20:54 +0200 Subject: [PATCH] fixed spi read and write --- slsDetectorSoftware/src/Module.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 62874e0f8..87180a8d0 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -4020,16 +4020,23 @@ void Module::simulatingActivityinDetector(const std::string &functionType, std::vector Module::readSpi(int chip_id, int register_id, int n_bytes) const { - int args[] = {chip_id, register_id, n_bytes}; - return sendToDetector>(F_SPI_READ, args); + auto client = createDetectorSocket(); + client.sendCommand(F_SPI_READ, &chip_id, sizeof(chip_id)); + client.Send(®ister_id, sizeof(register_id)); + client.Send(&n_bytes, sizeof(n_bytes)); + + std::vector retval(n_bytes); + client.readReply(retval.data(), retval.size()); + return retval; } std::vector Module::writeSpi(int chip_id, int register_id, const std::vector &data) { int count = static_cast(data.size()); - int args[] = {chip_id, register_id, count}; auto client = createDetectorSocket(); - client.sendCommand(F_SPI_WRITE, args, sizeof(args)); + client.sendCommand(F_SPI_WRITE, &chip_id, sizeof(chip_id)); + client.Send(®ister_id, sizeof(register_id)); + client.Send(&count, sizeof(count)); client.Send(data); // Read the output from the SPI write. This contains the data before the // write