diff --git a/DroneClientCpp/DroneClientCpp/x64/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cpp b/DroneClientCpp/DroneClientCpp/x64/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cpp new file mode 100644 index 0000000..62124be --- /dev/null +++ b/DroneClientCpp/DroneClientCpp/x64/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cpp @@ -0,0 +1,2 @@ +#using +[assembly: System::Runtime::Versioning::TargetFrameworkAttribute(L".NETFramework,Version=v4.7.2", FrameworkDisplayName=L".NET Framework 4.7.2")]; diff --git a/DroneClientCpp/DroneClientCpp/x64/Debug/DroneClientCpp.vcxproj.AssemblyReference.cache b/DroneClientCpp/DroneClientCpp/x64/Debug/DroneClientCpp.vcxproj.AssemblyReference.cache new file mode 100644 index 0000000..0cd4393 Binary files /dev/null and b/DroneClientCpp/DroneClientCpp/x64/Debug/DroneClientCpp.vcxproj.AssemblyReference.cache differ diff --git a/TestClientConnection/TestClientConnection.cpp b/TestClientConnection/TestClientConnection.cpp deleted file mode 100644 index 37dc7f9..0000000 --- a/TestClientConnection/TestClientConnection.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#pragma comment(lib, "Ws2_32.lib") - -struct DataIn -{ - float AccX, AccY, AccZ; - float GyrX, GyrY, GyrZ; - float PosX, PosY, LaserRange; -} dataIn; - -struct DataOut -{ - float MotorUL, MotorUR, MotorDL, MotorDR; -} dataOut; - -std::atomic running(true); // Флаг работы потоков -std::mutex dataMutex; // Мьютекс для синхронизации доступа к dataIn и dataOut - -SOCKET ConnectToServer(const char* ip, int port) -{ - WSAData wsaData; - WORD DLLVersion = MAKEWORD(2, 1); - - if (WSAStartup(DLLVersion, &wsaData) != 0) - { - std::cout << "Error: WSAStartup failed\n"; - return INVALID_SOCKET; - } - - SOCKADDR_IN addr; - inet_pton(AF_INET, ip, &addr.sin_addr); - addr.sin_port = htons(port); - addr.sin_family = AF_INET; - - SOCKET Connection = socket(AF_INET, SOCK_STREAM, 0); - if (Connection == INVALID_SOCKET) - { - std::cout << "Error: Failed to create socket\n"; - WSACleanup(); - return INVALID_SOCKET; - } - - if (connect(Connection, (SOCKADDR*)&addr, sizeof(addr)) != 0) - { - std::cout << "Error: Failed to connect to server\n"; - closesocket(Connection); - WSACleanup(); - return INVALID_SOCKET; - } - - return Connection; -} - -void CloseConnection(SOCKET& socket) -{ - if (socket != INVALID_SOCKET) - { - closesocket(socket); - WSACleanup(); - socket = INVALID_SOCKET; - } -} - -// Функция приема данных -void ReceiveHandler(SOCKET socket) -{ - while (running) - { - DataIn tempData; - int result = recv(socket, (char*)&tempData, sizeof(tempData), 0); - - if (result <= 0) - { - std::cout << "Error: Connection lost (recv failed)\n"; - running = false; - break; - } - - // Потокобезопасное обновление данных - std::lock_guard lock(dataMutex); - dataIn = tempData; - } -} - -// Функция отправки данных -void SendHandler(SOCKET socket) -{ - while (running) - { - { - std::lock_guard lock(dataMutex); - send(socket, (char*)&dataOut, sizeof(dataOut), 0); - } - std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Задержка для уменьшения нагрузки - } -} - -int main() -{ - SOCKET Connection = ConnectToServer("127.0.0.1", 1001); - if (Connection == INVALID_SOCKET) - { - return 1; - } - - dataOut.MotorUL = 10; - dataOut.MotorUR = 10; - dataOut.MotorDL = 10; - dataOut.MotorDR = 10; - - // Создание потоков - std::thread recvThread(ReceiveHandler, Connection); - std::thread sendThread(SendHandler, Connection); - - for (int i = 0; i < 1000000; i++) - { - { - std::lock_guard lock(dataMutex); - std::cout << "Laser Range: " << dataIn.LaserRange << std::endl; - } - std::cout << "-----------------------------------------------------------" << std::endl; - std::this_thread::sleep_for(std::chrono::milliseconds(500)); // Задержка вывода - } - - // Завершаем работу потоков - running = false; - recvThread.join(); - sendThread.join(); - - CloseConnection(Connection); - - system("pause"); - return 0; -} diff --git a/TestClientConnection/TestClientConnection.vcxproj b/TestClientConnection/TestClientConnection.vcxproj deleted file mode 100644 index 89baf73..0000000 --- a/TestClientConnection/TestClientConnection.vcxproj +++ /dev/null @@ -1,135 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - Win32Proj - {b7cc5245-b628-40e9-a9a0-a904e2bf25ea} - TestClientConnection - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/TestClientConnection/TestClientConnection.vcxproj.filters b/TestClientConnection/TestClientConnection.vcxproj.filters deleted file mode 100644 index 505cabd..0000000 --- a/TestClientConnection/TestClientConnection.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Исходные файлы - - - \ No newline at end of file