| 672 | // Members of namespace CanInterface, and associated local functions |
| 673 | |
| 674 | template<class T> static GCodeResult SetRemoteDriverValues(const CanDriversData<T>& data, const StringRef& reply, CanMessageType mt) noexcept |
| 675 | { |
| 676 | GCodeResult rslt = GCodeResult::ok; |
| 677 | size_t start = 0; |
| 678 | for (;;) |
| 679 | { |
| 680 | CanDriversBitmap driverBits; |
| 681 | const size_t savedStart = start; |
| 682 | const CanAddress boardAddress = data.GetNextBoardDriverBitmap(start, driverBits); |
| 683 | if (boardAddress == CanId::NoAddress) |
| 684 | { |
| 685 | break; |
| 686 | } |
| 687 | CanMessageBuffer * const buf = CanMessageBuffer::Allocate(); |
| 688 | if (buf == nullptr) |
| 689 | { |
| 690 | return GCodeResult::noCanBuffer; |
| 691 | } |
| 692 | const CanRequestId rid = CanInterface::AllocateRequestId(boardAddress, buf); |
| 693 | CanMessageMultipleDrivesRequest<T> * const msg = buf->SetupRequestMessage<CanMessageMultipleDrivesRequest<T>>(rid, CanInterface::GetCanAddress(), boardAddress, mt); |
| 694 | msg->driversToUpdate = driverBits.GetRaw(); |
| 695 | const size_t numDrivers = driverBits.CountSetBits(); |
| 696 | for (size_t i = 0; i < numDrivers; ++i) |
| 697 | { |
| 698 | msg->values[i] = data.GetElement(savedStart + i); |
| 699 | } |
| 700 | buf->dataLength = msg->GetActualDataLength(numDrivers); |
| 701 | rslt = max(rslt, CanInterface::SendRequestAndGetStandardReply(buf, rid, reply)); |
| 702 | } |
| 703 | return rslt; |
| 704 | } |
| 705 | |
| 706 | // Set remote drivers to enabled, disabled, or idle |
| 707 | // This function is called by both the main task and the Move task. |
no test coverage detected