Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have CI build under windows #168

Merged
merged 11 commits into from
Nov 20, 2024
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build LibMultiSense

on:
push:
branches:
- master
release:
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref_name }}-build
cancel-in-progress: ${{ github.ref_name != 'main' }}
steps:
- id: setup
run: |
sudo apt-get install libgtest-dev -y
- uses: actions/checkout@v4
- id: build-release
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=install-release
cmake --build build -j "$(nproc)"
make -C build test
cmake --install build
- id: build-debug
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=install-debug
cmake --build build -j "$(nproc)"
make -C build test
cmake --install build

buildwindows:
name: build for windows
runs-on: windows-2022

steps:
- uses: actions/checkout@v4
- id: build-release
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release
cmake --build ${{github.workspace}}/build --config Release --target install -- /m:10
- id: build-debug
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug
cmake --build ${{github.workspace}}/build --config Debug --target install -- /m:10
15 changes: 13 additions & 2 deletions source/LibMultiSense/details/channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*
* Significant history (date, user, job code, action):
* 2013-04-25, [email protected], PR1044, Created file.
* 2024-04-12, [email protected], IRAD.2033.1, support mingw64
**/

#include "MultiSense/details/channel.hh"
Expand Down Expand Up @@ -314,7 +315,11 @@ void impl::bind(const std::string& ifName)
// Create the socket.

m_serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#if defined(__MINGW64__)
if (m_serverSocket == INVALID_SOCKET)
#else
if (m_serverSocket < 0)
#endif
CRL_EXCEPTION("failed to create the UDP socket: %s",
strerror(errno));

Expand Down Expand Up @@ -426,14 +431,14 @@ void impl::publish(const utility::BufferStreamWriter& stream)
// Send the packet along

// disable MSVC warning for narrowing conversion.
#ifdef WIN32
#if defined(WIN32) && !defined(__MINGW64__)
#pragma warning (push)
#pragma warning (disable : 4267)
#endif
const int32_t ret = sendto(m_serverSocket, (char*)stream.data(), stream.tell(), 0,
(struct sockaddr *) &m_sensorAddress,
sizeof(m_sensorAddress));
#ifdef WIN32
#if defined(WIN32) && !defined(__MINGW64__)
#pragma warning (pop)
#endif

Expand Down Expand Up @@ -557,6 +562,7 @@ uint32_t impl::hardwareApiToWire(uint32_t a)
case system::DeviceInfo::HARDWARE_REV_MONO: return wire::SysDeviceInfo::HARDWARE_REV_MONO;
case system::DeviceInfo::HARDWARE_REV_MULTISENSE_KS21_SILVER: return wire::SysDeviceInfo::HARDWARE_REV_MULTISENSE_KS21_SILVER;
case system::DeviceInfo::HARDWARE_REV_MULTISENSE_ST25: return wire::SysDeviceInfo::HARDWARE_REV_MULTISENSE_ST25;
case system::DeviceInfo::HARDWARE_REV_MULTISENSE_KS21i: return wire::SysDeviceInfo::HARDWARE_REV_MULTISENSE_KS21i;
default:
CRL_DEBUG("unknown API hardware type \"%d\"\n", a);
return a; // pass through
Expand All @@ -583,6 +589,7 @@ uint32_t impl::hardwareWireToApi(uint32_t w)
case wire::SysDeviceInfo::HARDWARE_REV_MONO: return system::DeviceInfo::HARDWARE_REV_MONO;
case wire::SysDeviceInfo::HARDWARE_REV_MULTISENSE_KS21_SILVER: return system::DeviceInfo::HARDWARE_REV_MULTISENSE_KS21_SILVER;
case wire::SysDeviceInfo::HARDWARE_REV_MULTISENSE_ST25: return system::DeviceInfo::HARDWARE_REV_MULTISENSE_ST25;
case wire::SysDeviceInfo::HARDWARE_REV_MULTISENSE_KS21i: return system::DeviceInfo::HARDWARE_REV_MULTISENSE_KS21i;
default:
CRL_DEBUG("unknown WIRE hardware type \"%d\"\n", w);
return w; // pass through
Expand Down Expand Up @@ -799,7 +806,11 @@ void *impl::statusThread(void *userDataP)
usleep(static_cast<unsigned int> (1e6));
}

#if defined(__MINGW64__)
return 0;
#else
return NULL;
#endif
}

} // namespace details
Expand Down
13 changes: 9 additions & 4 deletions source/LibMultiSense/details/dispatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*
* Significant history (date, user, job code, action):
* 2013-05-15, [email protected], PR1044, Created file.
* 2024-04-12, [email protected], IRAD.2033.1, support mingw64
**/

#include "MultiSense/details/channel.hh"
Expand Down Expand Up @@ -857,15 +858,15 @@ void impl::handle()
// Receive the packet

// disable MSVC warning for narrowing conversion.
#ifdef WIN32
#if defined(WIN32) && !defined(__MINGW64__)
#pragma warning (push)
#pragma warning (disable : 4267)
#endif
const int bytesRead = recvfrom(m_serverSocket,
(char*)m_incomingBuffer.data(),
m_incomingBuffer.size(),
0, NULL, NULL);
#ifdef WIN32
#if defined(WIN32) && !defined(__MINGW64__)
#pragma warning (pop)
#endif

Expand Down Expand Up @@ -925,7 +926,7 @@ void impl::handle()
#endif
m_lastUnexpectedSequenceId = sequence;

utility::ScopedLock lock(m_statisticsLock);
utility::ScopedLock lock2(m_statisticsLock);
m_channelStatistics.numDroppedAssemblers += 1;
}
continue;
Expand Down Expand Up @@ -974,7 +975,7 @@ void impl::handle()
#ifdef UDP_ASSEMBLER_DEBUG
CRL_DEBUG("UDP Assembler dropping sequence=%" PRId64 "\n", willBeDropped.second);
#endif
utility::ScopedLock lock(m_statisticsLock);
utility::ScopedLock lock2(m_statisticsLock);
m_channelStatistics.numDroppedAssemblers += 1;
}
m_udpTrackerCache.insert(sequence, trP);
Expand Down Expand Up @@ -1036,7 +1037,11 @@ void *impl::rxThread(void *userDataP)
}
}

#if defined(__MINGW64__)
return 0;
#else
return NULL;
#endif
}

}}} // namespaces
45 changes: 45 additions & 0 deletions source/LibMultiSense/details/public.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,51 @@ Status impl::getMtu(int32_t& mtu)
return status;
}

Status impl::setBestMtu()
{
uint32_t cur_mtu = MAX_MTU_SIZE;
uint32_t max_mtu = MAX_MTU_SIZE;
uint32_t min_mtu = MIN_MTU_SIZE;
uint32_t bisections = 0;
Status status = Status_Ok;

//
// v2.2 and older do not support testing MTU

if (m_sensorVersion.firmwareVersion <= 0x0202)
return Status_Unsupported;

while (bisections < 7){
wire::SysTestMtuResponse resp;
status = waitData(wire::SysTestMtu(cur_mtu), resp, 0.1, 1);
if ((Status_Ok == status) && (cur_mtu == MAX_MTU_SIZE))
break;

bisections++;

if (Status_Ok != status){
max_mtu = cur_mtu;
cur_mtu -= (cur_mtu - min_mtu) / 2;
} else if (bisections < 7){
min_mtu = cur_mtu;
cur_mtu += (max_mtu - cur_mtu) / 2;
}

if ((Status_Ok != status) && (bisections == 7)){
cur_mtu = min_mtu;
status = waitData(wire::SysTestMtu(cur_mtu), resp, 0.1, 1);
}
}

if (Status_Ok == status)
status = waitAck(wire::SysMtu(cur_mtu));
if (Status_Ok == status)
m_sensorMtu = cur_mtu;

return status;

}

Status impl::getMotorPos(int32_t& pos)
{
wire::MotorPoll resp;
Expand Down
7 changes: 6 additions & 1 deletion source/LibMultiSense/details/utility/Exception.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*
* Significant history (date, user, job code, action):
* 2012-05-07, [email protected], IRAD, Created file.
* 2024-04-12, [email protected], IRAD.2033.1, support mingw64
**/

#include "MultiSense/details/utility/Exception.hh"
Expand Down Expand Up @@ -92,7 +93,11 @@ Exception::Exception(const char *failureReason, ...)
int returnValue;

va_start(ap, failureReason);
returnValue = vasprintf(&stringP, failureReason, ap);
#if defined(__MINGW64__)
returnValue = __mingw_vasprintf(&stringP, failureReason, ap);
#else
returnValue = vasprintf(&stringP, failureReason, ap);
#endif
va_end(ap);

if ((NULL != stringP) && (returnValue != -1)) {
Expand Down
4 changes: 3 additions & 1 deletion source/LibMultiSense/details/utility/TimeStamp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ namespace crl {
namespace multisense {
namespace details {
namespace utility {

#if defined (WIN32)
ULARGE_INTEGER TimeStamp::offsetSecondsSince1970;
#endif
/*
* Constructor. Empty. We rely on the getter methods to do
* things that are more useful.
Expand Down
10 changes: 10 additions & 0 deletions source/LibMultiSense/include/MultiSense/MultiSenseChannel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,16 @@ public:

virtual Status setMtu (int32_t mtu) = 0;

/**
* Binary search for best path MTU (within ~118B).
*
*
* @return A crl::multisense::Status indicating if the mtu configuration
* was successfully received
*/

virtual Status setBestMtu () = 0;

/**
* Query the current sensor's network configuration.
*
Expand Down
Loading