Merge with develop

This commit is contained in:
Uwe Seimet 2023-11-16 16:52:43 +01:00
parent 6aa8b93975
commit 78979e49d7
3 changed files with 16 additions and 17 deletions

View File

@ -20,7 +20,6 @@
#include "devices/storage_device.h"
#include "hal/gpiobus_factory.h"
#include "hal/gpiobus.h"
#include "hal/systimer.h"
#include "piscsi/piscsi_core.h"
#include <spdlog/spdlog.h>
#include <netinet/in.h>
@ -29,6 +28,7 @@
#include <iostream>
#include <fstream>
#include <vector>
#include <chrono>
using namespace std;
using namespace filesystem;
@ -684,21 +684,19 @@ bool Piscsi::ShutDown(AbstractController::piscsi_shutdown_mode shutdown_mode)
bool Piscsi::IsNotBusy() const
{
// Wait until BSY is released as there is a possibility for the
// initiator to assert it while setting the ID (for up to 3 seconds)
if (bus->GetBSY()) {
const uint32_t now = SysTimer::GetTimerLow();
// initiator to assert it while setting the ID (for up to 3 seconds)
if (bus->GetBSY()) {
const auto now = chrono::steady_clock::now();
while ((chrono::duration_cast<chrono::seconds>(chrono::steady_clock::now() - now).count()) < 3) {
bus->Acquire();
// Wait for 3s
while ((SysTimer::GetTimerLow() - now) < 3'000'000) {
bus->Acquire();
if (!bus->GetBSY()) {
return true;
}
}
if (!bus->GetBSY()) {
return true;
}
}
return false;
}
return false;
}
return true;
return true;
}

View File

@ -25,7 +25,7 @@ class PiscsiResponse
{
public:
PiscsiResponse() = default;
PiscsiResponse() { }
~PiscsiResponse() = default;
bool GetImageFile(PbImageFile&, const string&, const string&) const;

View File

@ -42,7 +42,8 @@ string PiscsiService::Init(const callback& cb, int port)
server.sin_family = PF_INET;
server.sin_port = htons((uint16_t)port);
server.sin_addr.s_addr = INADDR_ANY;
if (bind(service_socket, reinterpret_cast<const sockaddr *>(&server), sizeof(sockaddr_in)) < 0) { //NOSONAR bit_cast is not supported by the bullseye compiler
if (bind(service_socket, reinterpret_cast<const sockaddr*>(&server), //NOSONAR bit_cast is not supported by the bullseye compiler
static_cast<socklen_t>(sizeof(sockaddr_in))) < 0) {
Stop();
return "Port " + to_string(port) + " is in use, is piscsi already running?";
}