mirror of
https://github.com/g4klx/MMDVMHost.git
synced 2025-12-06 05:32:00 +01:00
Begin getting it to compile on Windows again.
This commit is contained in:
parent
0e8788bdbe
commit
ca2bff7e9e
|
|
@ -22,7 +22,6 @@
|
|||
#include "ModemSerialPort.h"
|
||||
#include "NullDisplay.h"
|
||||
#include "TFTSurenoo.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "LCDproc.h"
|
||||
#include "Nextion.h"
|
||||
#include "CASTInfo.h"
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "Timer.h"
|
||||
#include "UserDBentry.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "Modem.h"
|
||||
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020,2021,2023 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020,2021,2023,2024 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -28,7 +28,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const unsigned int MMDVM_SAMPLERATE = 8000U;
|
||||
|
||||
|
|
@ -48,7 +47,7 @@ m_buffer(2000U, "FM Network"),
|
|||
m_seqNo(0U),
|
||||
m_resampler(NULL),
|
||||
m_error(0),
|
||||
m_fd(-1)
|
||||
m_fp(NULL)
|
||||
{
|
||||
assert(!callsign.empty());
|
||||
assert(gatewayPort > 0U);
|
||||
|
|
@ -86,9 +85,13 @@ bool CFMNetwork::open()
|
|||
LogMessage("Opening FM network connection");
|
||||
|
||||
if (!m_squelchFile.empty()) {
|
||||
m_fd = ::open(m_squelchFile.c_str(), O_WRONLY | O_SYNC);
|
||||
if (m_fd == -1) {
|
||||
m_fp = ::fopen(m_squelchFile.c_str(), "wb");
|
||||
if (m_fp == NULL) {
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
LogError("Cannot open the squelch file: %s, errno=%d", m_squelchFile.c_str(), errno);
|
||||
#else
|
||||
LogError("Cannot open the squelch file: %s, errno=%lu", m_squelchFile.c_str(), ::GetLastError());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -316,12 +319,18 @@ bool CFMNetwork::writeRawEnd()
|
|||
{
|
||||
m_seqNo = 0U;
|
||||
|
||||
if (m_fd != -1) {
|
||||
size_t n = ::write(m_fd, "Z", 1);
|
||||
if (m_fp != NULL) {
|
||||
size_t n = ::fwrite("Z", 1, 1, m_fp);
|
||||
if (n != 1) {
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
LogError("Cannot write to the squelch file: %s, errno=%d", m_squelchFile.c_str(), errno);
|
||||
#else
|
||||
LogError("Cannot write to the squelch file: %s, errno=%lu", m_squelchFile.c_str(), ::GetLastError());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
::fflush(m_fp);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -442,9 +451,9 @@ void CFMNetwork::close()
|
|||
{
|
||||
m_socket.close();
|
||||
|
||||
if (m_fd != -1) {
|
||||
::close(m_fd);
|
||||
m_fd = -1;
|
||||
if (m_fp != NULL) {
|
||||
::fclose(m_fp);
|
||||
m_fp = NULL;
|
||||
}
|
||||
|
||||
LogMessage("Closing FM network connection");
|
||||
|
|
@ -559,12 +568,18 @@ bool CFMNetwork::writeUSRPStart()
|
|||
|
||||
bool CFMNetwork::writeRawStart()
|
||||
{
|
||||
if (m_fd != -1) {
|
||||
size_t n = ::write(m_fd, "O", 1);
|
||||
if (m_fp != NULL) {
|
||||
size_t n = ::fwrite("O", 1, 1, m_fp);
|
||||
if (n != 1) {
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
LogError("Cannot write to the squelch file: %s, errno=%d", m_squelchFile.c_str(), errno);
|
||||
#else
|
||||
LogError("Cannot write to the squelch file: %s, errno=%lu", m_squelchFile.c_str(), ::GetLastError());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
::fflush(m_fp);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ private:
|
|||
unsigned int m_seqNo;
|
||||
SRC_STATE* m_resampler;
|
||||
int m_error;
|
||||
int m_fd;
|
||||
FILE* m_fp;
|
||||
|
||||
bool writeUSRPStart();
|
||||
bool writeRawStart();
|
||||
|
|
|
|||
11
LCDproc.cpp
11
LCDproc.cpp
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2016,2017,2018 by Tony Corbett G0WFV
|
||||
* Copyright (C) 2018,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2018,2020,2024 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -73,6 +73,7 @@
|
|||
#include <stdarg.h>
|
||||
#else
|
||||
#include <ws2tcpip.h>
|
||||
#include <WinSock2.h>
|
||||
#endif
|
||||
|
||||
#define BUFFER_MAX_LEN 128
|
||||
|
|
@ -670,15 +671,19 @@ void CLCDproc::clockInt(unsigned int ms)
|
|||
* exceptfds = we are not waiting for exception fds
|
||||
*/
|
||||
|
||||
if (select(m_socketfd + 1, &m_readfds, NULL, NULL, &m_timeout) == -1)
|
||||
if (select(m_socketfd + 1, &m_readfds, NULL, NULL, &m_timeout) == -1) {
|
||||
LogError("LCDproc, error on select");
|
||||
return;
|
||||
}
|
||||
|
||||
// If something was received from the server...
|
||||
if (FD_ISSET(m_socketfd, &m_readfds)) {
|
||||
m_recvsize = recv(m_socketfd, m_buffer, BUFFER_MAX_LEN, 0);
|
||||
|
||||
if (m_recvsize == -1)
|
||||
if (m_recvsize == -1) {
|
||||
LogError("LCDproc, cannot receive information");
|
||||
return;
|
||||
}
|
||||
|
||||
m_buffer[m_recvsize] = '\0';
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#if !defined(LCDproc_H)
|
||||
#define LCDproc_H
|
||||
|
||||
#include "UDPSocket.h"
|
||||
#include "Display.h"
|
||||
#include "Timer.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>HAVE_LOG_H;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\libsamplerate-0.1.9\src</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
|
@ -102,6 +103,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>HAVE_LOG_H;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\libsamplerate-0.1.9\src</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
|
@ -124,6 +126,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>HAVE_LOG_H;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\libsamplerate-0.1.9\src</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
|
@ -142,6 +145,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>HAVE_LOG_H;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\libsamplerate-0.1.9\src</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@
|
|||
#include <net/route.h>
|
||||
#endif
|
||||
#elif defined(_WIN32) || defined(_WIN64)
|
||||
#include <ws2tcpip.h>
|
||||
// #include <ws2tcpip.h>
|
||||
// #include <WinSock2.h>
|
||||
#include <iphlpapi.h>
|
||||
#pragma comment(lib, "iphlpapi.lib")
|
||||
#ifndef NO_ERROR
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
#if !defined(NETWORKINFO_H)
|
||||
#define NETWORKINFO_H
|
||||
|
||||
#include "UDPSocket.h"
|
||||
|
||||
class CNetworkInfo {
|
||||
public:
|
||||
CNetworkInfo();
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include <errno.h>
|
||||
#else
|
||||
#include <ws2tcpip.h>
|
||||
#include <Winsock2.h>
|
||||
#endif
|
||||
|
||||
enum IPMATCHTYPE {
|
||||
|
|
@ -69,10 +70,11 @@ private:
|
|||
unsigned short m_localPort;
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
SOCKET m_fd;
|
||||
int m_af;
|
||||
#else
|
||||
int m_fd;
|
||||
#endif
|
||||
sa_family_t m_af;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue