Skip to content

Commit

Permalink
windows/serialInterface: Implemented serialInterface_t::writePacket()
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmux committed Oct 31, 2023
1 parent c539d21 commit b2baeff
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/windows/serialInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ void serialInterface_t::swap(serialInterface_t &interface) noexcept

void serialInterface_t::writePacket(const std::string_view &packet) const
{
console.debug("Remote write: "sv, packet);
DWORD written{0};
for (size_t offset{0}; offset < packet.length(); offset += written)
{
if (!WriteFile(device, packet.data() + offset, static_cast<DWORD>(packet.length() - offset), &written, nullptr))
{
console.error("Write to device failed ("sv, GetLastError(), "), written "sv, offset, " bytes");
throw bmpCommsError_t{};
}
}
}

std::string serialInterface_t::readPacket() const
Expand Down

0 comments on commit b2baeff

Please sign in to comment.