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

pScheduler: Able to also publish double vars in SEQUENCES #4

Open
wants to merge 4 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Essentials/pAntler/Antler.cpp
Expand Up @@ -659,7 +659,7 @@ bool CAntler::MakeConsoleLaunchParams(std::string sParam,STRING_LIST & LaunchLis

CAntler::MOOSProc* CAntler::CreateMOOSProcess(string sConfiguration)
{
MOOSRemoveChars(sConfiguration," \t\r");

//what tis its name? (if no @ symbol we just get the name and no cmdline)
string sProcName = MOOSChomp(sConfiguration,"@");
Expand Down
5 changes: 5 additions & 0 deletions Essentials/pAntler/CMakeLists.txt
Expand Up @@ -6,6 +6,11 @@ find_package(MOOS 10)
#what files are needed?
SET(SRCS AntlerMain.cpp Antler.cpp)

IF (WIN32)
SET(SRCS ${SRCS} XPCProcess.cpp XPCProcessAttrib.cpp)
ENDIF(WIN32)


include_directories( ${${EXECNAME}_INCLUDE_DIRS} ${MOOS_INCLUDE_DIRS} ${MOOS_DEPEND_INCLUDE_DIRS})
add_executable(${EXECNAME} ${SRCS} )
target_link_libraries(${EXECNAME} ${MOOS_LIBRARIES} ${MOOS_DEPEND_LIBRARIES})
Expand Down
4 changes: 2 additions & 2 deletions Essentials/pLogger/MOOSLogger.cpp
Expand Up @@ -1032,7 +1032,7 @@ bool CMOOSLogger::CreateDirectory(const std::string & sDirectory)
{

#if _WIN32
int bOK = ::CreateDirectory(sDirectory.c_str(),NULL);
int bOK = ::CreateDirectoryA(sDirectory.c_str(),NULL);

if(!bOK)
{
Expand All @@ -1042,7 +1042,7 @@ bool CMOOSLogger::CreateDirectory(const std::string & sDirectory)
{

LPVOID lpMsgBuf;
FormatMessage(
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
Expand Down
5 changes: 5 additions & 0 deletions Essentials/pLogger/MOOSLogger.h
Expand Up @@ -39,6 +39,11 @@
#include <string>
#include "Zipper.h"

#if _WIN32
#include <windows.h>
#include <winbase.h>
#endif // windows

typedef std::vector<std::string> STRING_VECTOR;

class CMOOSLogger : public CMOOSApp
Expand Down
6 changes: 6 additions & 0 deletions Essentials/pMOOSBridge/MOOSCommunity.cpp
Expand Up @@ -30,6 +30,12 @@
// MOOSCommunity.cpp: implementation of the CMOOSCommunity class.
//
//////////////////////////////////////////////////////////////////////

// JLBC: Avoid winsock2 conflict by including it now:
#ifdef _WIN32
#include <winsock2.h>
#endif

#include "MOOSCommunity.h"
#include "MOOS/libMOOS/MOOSLib.h"

Expand Down
20 changes: 19 additions & 1 deletion Essentials/pScheduler/MOOSScheduler.cpp
Expand Up @@ -372,11 +372,29 @@ bool CMOOSScheduler::CEvent::GetOutput(double dfTimeNow, MOOSMSG_LIST &Out)
//set up next fire time
m_dfFireTime+=m_dfPeriod;

CMOOSMsg Msg( MOOS_NOTIFY,
CMOOSMsg *msg = NULL;
double fVal=0;
if ( ::sscanf(m_sVal.c_str(),"%lf",&fVal)==1)
{
// It's a double:
msg = new CMOOSMsg(MOOS_NOTIFY,
m_sName.c_str(),
fVal,
dfTimeNow);
}
else
{
// It's text:
msg = new CMOOSMsg(MOOS_NOTIFY,
m_sName.c_str(),
m_sVal.c_str(),
dfTimeNow);

}

CMOOSMsg Msg = *msg;
delete msg;

Out.push_front(Msg);

return true;
Expand Down
4 changes: 4 additions & 0 deletions Essentials/pShare/CMakeLists.txt
Expand Up @@ -10,6 +10,10 @@ include_directories( ${${EXECNAME}_INCLUDE_DIRS} ${MOOS_INCLUDE_DIRS} ${MOOS_DEP
add_executable(${EXECNAME} ${SRCS} )
target_link_libraries(${EXECNAME} ${MOOS_LIBRARIES} ${MOOS_DEPEND_LIBRARIES})

IF (WIN32)
target_link_libraries(${EXECNAME} Ws2_32.lib)
ENDIF(WIN32)

INSTALL(TARGETS ${EXECNAME}
RUNTIME DESTINATION bin
)
21 changes: 14 additions & 7 deletions Essentials/pShare/Listener.cpp
Expand Up @@ -5,12 +5,19 @@
* Author: pnewman
*/
#ifndef _WIN32
#include "unistd.h"
# include "unistd.h"
# include <sys/socket.h>
# include <arpa/inet.h>
# include <netinet/in.h>
#else
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0600 //will only work with vista and above as XP does not support IPv6
# endif
# include <io.h>
# include <winsock2.h>
# include <Ws2tcpip.h>
#endif

#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string>
#include <cstring>
#include <stdexcept>
Expand Down Expand Up @@ -52,7 +59,7 @@ bool Listener::ListenLoop()

//we want to be able to resuse it (multiple folk are interested)
int reuse = 1;
if (setsockopt(socket_fd, SOL_SOCKET,SO_REUSEADDR/* SO_REUSEPORT*/, &reuse, sizeof(reuse)) == -1)
if (setsockopt(socket_fd, SOL_SOCKET,SO_REUSEADDR/* SO_REUSEPORT*/, (const char*)&reuse, sizeof(reuse)) == -1)
throw std::runtime_error("Listener::ListenLoop::setsockopt::reuse");

/* if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEPORT,
Expand All @@ -63,7 +70,7 @@ bool Listener::ListenLoop()
//give ourselves plenty of receive space
//set aside some space for receiving - just a few multiples of 64K
int rx_buffer_size = 64*1024*28;
if (setsockopt(socket_fd, SOL_SOCKET, SO_RCVBUF, &rx_buffer_size, sizeof(rx_buffer_size)) == -1)
if (setsockopt(socket_fd, SOL_SOCKET, SO_RCVBUF, (const char*)&rx_buffer_size, sizeof(rx_buffer_size)) == -1)
throw std::runtime_error("Listener::ListenLoop()::setsockopt::rcvbuf");


Expand Down Expand Up @@ -91,7 +98,7 @@ bool Listener::ListenLoop()
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(address_.host().c_str());
mreq.imr_interface.s_addr = INADDR_ANY;
if(setsockopt(socket_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))==-1)
if(setsockopt(socket_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char*)&mreq, sizeof(mreq))==-1)
throw std::runtime_error("Listener::ListenLoop()::setsockopt::ADD_MEMBERSHIP");
}

Expand Down
43 changes: 32 additions & 11 deletions Essentials/pShare/Share.cpp
Expand Up @@ -4,9 +4,21 @@
* Created on: Aug 26, 2012
* Author: pnewman
*/
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <netdb.h>
#ifdef _WIN32
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0600 //will only work with vista and above as XP does not support IPv6
# endif
# include <winsock2.h>
# ifdef NTDDI_VERSION
# undef NTDDI_VERSION
# endif
# define NTDDI_VERSION NTDDI_VISTA
# include <Ws2tcpip.h>
#else
# include <ifaddrs.h>
# include <arpa/inet.h>
# include <netdb.h>
#endif

#include <map>
#include <stdexcept>
Expand Down Expand Up @@ -1021,7 +1033,7 @@ bool Share::Impl::ApplyRoutes(CMOOSMsg & msg)
}

//send here
if (sendto(relevant_socket.socket_fd, buffer.data(), buffer.size(), 0,
if (sendto(relevant_socket.socket_fd, (const char*)buffer.data(), buffer.size(), 0,
(struct sockaddr*) (&relevant_socket.sock_addr),
sizeof(relevant_socket.sock_addr)) < 0)
{
Expand Down Expand Up @@ -1066,7 +1078,7 @@ bool Share::Impl::AddOutputRoute(MOOS::IPV4Address address, bool multicast)

int reuse = 1;
if (setsockopt(new_socket.socket_fd, SOL_SOCKET, SO_REUSEADDR,
&reuse, sizeof(reuse)) == -1)
(const char*)&reuse, sizeof(reuse)) == -1)
throw std::runtime_error("failed to set resuse socket option");
/*
if (setsockopt(new_socket.socket_fd, SOL_SOCKET, SO_REUSEPORT,
Expand All @@ -1076,7 +1088,7 @@ bool Share::Impl::AddOutputRoute(MOOS::IPV4Address address, bool multicast)
int send_buffer_size = 4 * 64 * 1024;
if (setsockopt(new_socket.socket_fd,
SOL_SOCKET, SO_SNDBUF,
&send_buffer_size,
(const char*)&send_buffer_size,
sizeof(send_buffer_size)) == -1)
{
throw std::runtime_error("failed to set size of socket send buffer");
Expand All @@ -1101,11 +1113,20 @@ bool Share::Impl::AddOutputRoute(MOOS::IPV4Address address, bool multicast)

std::string dotted_ip = MOOS::IPV4Address::GetNumericAddress(new_socket.address.host());

if(inet_aton(dotted_ip.c_str(), &new_socket.sock_addr.sin_addr)==0)
{
throw std::runtime_error("failed to intepret "
+dotted_ip+" as an ip address");
}
#ifdef UNIX
if(inet_aton(dotted_ip.c_str(), &new_socket.sock_addr.sin_addr)==0)
{
throw std::runtime_error("failed to intepret "
+dotted_ip+" as an ip address");
}
#elif _WIN32
if( InetPtonA(AF_INET,dotted_ip.c_str(), &new_socket.sock_addr.sin_addr)==0)
{
throw std::runtime_error("failed to intepret "
+dotted_ip+" as an ip address");
}
#endif


//new_socket.sock_addr.sin_addr.s_addr = inet_addr(new_socket.address.ip_num.c_str());
new_socket.sock_addr.sin_port = htons(new_socket.address.port());
Expand Down