mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-25 18:38:30 +01:00
added linux support for rtl_tcp
This commit is contained in:
parent
14a8e81662
commit
ace1fe1e5e
@ -20,4 +20,4 @@ else()
|
|||||||
add_custom_target(do_always ALL cp \"$<TARGET_FILE_DIR:sdrpp_core>/sdrpp_core.so\" \"$<TARGET_FILE_DIR:sdrpp>\")
|
add_custom_target(do_always ALL cp \"$<TARGET_FILE_DIR:sdrpp_core>/sdrpp_core.so\" \"$<TARGET_FILE_DIR:sdrpp>\")
|
||||||
endif (MSVC)
|
endif (MSVC)
|
||||||
|
|
||||||
# cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Alex/vcpkg/scripts/buildsystems/vcpkg.cmake" -G "Visual Studio 15 2017 Win64"
|
# cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Alex/vcpkg/scripts/buildsystems/vcpkg.cmake" -G "Visual Studio 15 2017 Win64"
|
||||||
|
@ -3,17 +3,24 @@
|
|||||||
"bandPlan": "General",
|
"bandPlan": "General",
|
||||||
"bandPlanEnabled": true,
|
"bandPlanEnabled": true,
|
||||||
"fftHeight": 300,
|
"fftHeight": 300,
|
||||||
"frequency": 96570096,
|
"frequency": 96571704,
|
||||||
"max": 0.0,
|
"max": 0.0,
|
||||||
"maximized": false,
|
"maximized": false,
|
||||||
|
"menuOrder": [
|
||||||
|
"Source",
|
||||||
|
"Radio",
|
||||||
|
"Recorder",
|
||||||
|
"Audio",
|
||||||
|
"Band Plan",
|
||||||
|
"Display"
|
||||||
|
],
|
||||||
"menuWidth": 300,
|
"menuWidth": 300,
|
||||||
"min": -51.47058868408203,
|
"min": -51.47058868408203,
|
||||||
"showWaterfall": true,
|
"showWaterfall": true,
|
||||||
"source": "",
|
"source": "",
|
||||||
"sourceSettings": {},
|
"sourceSettings": {},
|
||||||
"windowSize": {
|
"windowSize": {
|
||||||
"h": 720,
|
"h": 1053,
|
||||||
"w": 1280
|
"w": 1920
|
||||||
},
|
}
|
||||||
"menuOrder": ["Source", "Radio", "Recorder", "Audio", "Band Plan", "Display"]
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Radio": "./radio/Release/radio.dll",
|
"Radio": "./radio/radio.so",
|
||||||
"Recorder": "./recorder/Release/recorder.dll",
|
"Recorder": "./recorder/recorder.so",
|
||||||
"Soapy": "./soapy/Release/soapy.dll",
|
"Soapy": "./soapy/soapy.so",
|
||||||
"FileSource": "./file_source/Release/file_source.dll",
|
"FileSource": "./file_source/file_source.so",
|
||||||
"RTLTCPSource": "./rtl_tcp_source/Release/rtl_tcp_source.dll"
|
"RTLTCPSource": "./rtl_tcp_source/rtl_tcp_source.so"
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
{
|
{
|
||||||
"device": "HackRF One #0 901868dc282c8f8b",
|
"device": "HackRF One #0 901868dc282c8f8b",
|
||||||
"devices": {
|
"devices": {
|
||||||
"Generic RTL2832U OEM :: 00000001": {
|
"Generic RTL2832U OEM :: 00000001": {
|
||||||
"gains": {
|
"gains": {
|
||||||
"TUNER": 12.817999839782715
|
"TUNER": 12.817999839782715
|
||||||
},
|
},
|
||||||
"sampleRate": 2560000.0
|
"sampleRate": 2560000.0
|
||||||
},
|
},
|
||||||
"HackRF One #0 901868dc282c8f8b": {
|
"HackRF One #0 901868dc282c8f8b": {
|
||||||
"gains": {
|
"gains": {
|
||||||
"AMP": 0.0,
|
"AMP": 0.0,
|
||||||
"LNA": 24.711999893188477,
|
"LNA": 24.711999893188477,
|
||||||
"VGA": 15.906000137329102
|
"VGA": 15.906000137329102
|
||||||
},
|
},
|
||||||
"sampleRate": 8000000.0
|
"sampleRate": 8000000.0
|
||||||
}
|
},
|
||||||
}
|
"PulseAudio": {
|
||||||
|
"sampleRate": 96000.0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,8 +2,18 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
#include <WS2tcpip.h>
|
#include <WS2tcpip.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define __attribute__(x)
|
#define __attribute__(x)
|
||||||
@ -28,6 +38,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
struct addrinfo *result = NULL;
|
struct addrinfo *result = NULL;
|
||||||
struct addrinfo *ptr = NULL;
|
struct addrinfo *ptr = NULL;
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
@ -65,6 +76,23 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
|
#else
|
||||||
|
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
if (sockfd < 0) {
|
||||||
|
// TODO: Log error
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
struct hostent *server = gethostbyname(host);
|
||||||
|
struct sockaddr_in serv_addr;
|
||||||
|
bzero(&serv_addr, sizeof(struct sockaddr_in));
|
||||||
|
serv_addr.sin_family = AF_INET;
|
||||||
|
bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
|
||||||
|
serv_addr.sin_port = port;
|
||||||
|
if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0) {
|
||||||
|
// TODO: log error
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
connected = true;
|
connected = true;
|
||||||
|
|
||||||
@ -75,8 +103,12 @@ public:
|
|||||||
if (!connected) {
|
if (!connected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
#else
|
||||||
|
close(sockfd);
|
||||||
|
#endif
|
||||||
connected = false;
|
connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +121,19 @@ public:
|
|||||||
command_t cmd;
|
command_t cmd;
|
||||||
cmd.cmd = command;
|
cmd.cmd = command;
|
||||||
cmd.param = htonl(param);
|
cmd.param = htonl(param);
|
||||||
send(sock, (char*)&cmd, sizeof(command_t), 0);
|
#ifdef _WIN32
|
||||||
|
send(sock, (char*)&cmd, sizeof(command_t), 0);
|
||||||
|
#else
|
||||||
|
write(sockfd, &cmd, sizeof(command_t));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void receiveData(uint8_t* buf, size_t count) {
|
void receiveData(uint8_t* buf, size_t count) {
|
||||||
|
#ifdef _WIN32
|
||||||
recv(sock, (char*)buf, count, 0);
|
recv(sock, (char*)buf, count, 0);
|
||||||
|
#else
|
||||||
|
read(sockfd, buf, count);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFrequency(double freq) {
|
void setFrequency(double freq) {
|
||||||
@ -125,7 +165,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifdef _WIN32
|
||||||
SOCKET sock;
|
SOCKET sock;
|
||||||
|
#else
|
||||||
|
int sockfd;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user