wu_xinjun
2022-02-16 dfe24d63ccca74c1093349e8b9e9977ac0d82278
auto setting env and getting udp data
7个文件已修改
4个文件已添加
164 ■■■■■ 已修改文件
env/JustDoubleClickMe.bat 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Microwave/demo/AutoGetUDP.bat 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Microwave/demo/AutoGetUDPtest.bat 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Microwave/demo/AutoSendAndGetTest.bat 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Microwave/demo/AutoSendUDPtest.bat 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Microwave/demo/MicroWaveReceiverTest.py 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Microwave/demo/MicroWaveUDPServerTest.py 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Microwave/demo/udp_test_get.py 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Microwave/demo/udp_test_send.py 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/__init__.py 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/protos/compile.bat 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
env/JustDoubleClickMe.bat
@@ -1,4 +1,14 @@
@echo off
cd %~dp0
SettingEnv.bat
echo ========== Setting Env ==============
call SettingEnv.bat
echo setting done!
echo ========== Testing Env ==============
echo test it with hello word...
set aerialpython=%cd%/aerial_deploy/python.exe
%aerialpython% -c "import cv2, pika, flask, pika; print('hello world!')"
echo =========== ALL DONE ================
echo Press any key to exit this windiow.
pause
src/Microwave/demo/AutoGetUDP.bat
New file
@@ -0,0 +1,22 @@
@echo off
@REM change to the filepath
cd %~dp0
echo change to path: %cd%
set aerialpython=%cd%/../../../env/aerial_deploy/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    %envsetting%
)
echo All data will be save in '%cd%/saveUDPData/' folder
%aerialpython% udp_test_get.py test
echo =========== ALL DONE ================
echo Press any key to exit this windiow.
pause
src/Microwave/demo/AutoGetUDPtest.bat
New file
@@ -0,0 +1,22 @@
@echo off
@REM change to the filepath
cd %~dp0
echo change to path: %cd%
set aerialpython=%cd%/../../../env/aerial_deploy/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    %envsetting%
)
echo All data will be saved in '%cd%/saveUDPData/' folder
%aerialpython% udp_test_get.py test
echo =========== ALL GET DONE ================
echo Press any key to exit this windiow.
pause
src/Microwave/demo/AutoSendAndGetTest.bat
New file
@@ -0,0 +1,16 @@
@echo off
@REM change to the filepath
cd %~dp0
echo change to path: %cd%
set aerialpython=%cd%/../../../env/aerial_deploy/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    %envsetting%
)
start AutoGetUDPtest.bat
start AutoSendUDPtest.bat
src/Microwave/demo/AutoSendUDPtest.bat
New file
@@ -0,0 +1,22 @@
@echo off
@REM change to the filepath
cd %~dp0
echo change to path: %cd%
set aerialpython=%cd%/../../../env/aerial_deploy/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    %envsetting%
)
echo All data saved in '%cd%/demoUDPData/' folder will be sent to 127.0.0.1:9911
%aerialpython% udp_test_send.py
echo =========== ALL SEND DONE ================
echo Press any key to exit this windiow.
pause
src/Microwave/demo/MicroWaveReceiverTest.py
@@ -28,3 +28,4 @@
                print("Frame {} ready".format(frame_number))
                with open(bin_name, "wb") as bin_file:
                    bin_file.write(receiver.DataFrame)
                    bin_file.close()
src/Microwave/demo/MicroWaveUDPServerTest.py
@@ -1,13 +1,37 @@
import sys
import time
import os
from socketserver import BaseRequestHandler, UDPServer
# add python path of microwave to sys.path
microwave_path = os.path.join(__file__, *(['..'] * 3))
microwave_path = os.path.abspath(microwave_path)
sys.path.insert(0, microwave_path)
from microwave.servers import MicroWaveUDPServer
from microwave.servers import MicroWaveReceiver
class MicroWaveRequestHandlertest(BaseRequestHandler):
    def handle(self):
        # Get message and client socket
        buf, _ = self.request
        receiver = self.server.Receiver
        receiver.AddBuf(buf)
        if receiver.DataFrameReady:
            # data frame ready
            frame_number = receiver.Header.FrameNumber
            bin_name = os.path.join(self.server.OutputFolder, "{}.bin".format(frame_number))
            print("Frame {} ready".format(frame_number))
            with open(bin_name, "wb") as bin_file:
                bin_file.write(receiver.DataFrame)
class MicroWaveUDPServertest(UDPServer):
    def __init__(self, server_address, output_folder):
        super().__init__(server_address, MicroWaveRequestHandlertest)
        # create receiver instance
        self.Receiver = MicroWaveReceiver()
        self.OutputFolder = output_folder
if __name__ == '__main__':
    if len(sys.argv) == 2:
@@ -18,7 +42,7 @@
    # host = '192.168.2.65'
    host = ''
    port = 9911
    server = MicroWaveUDPServer((host, port), output_folder)
    server = MicroWaveUDPServertest((host, port), output_folder)
    server.packed_count = 0
    print(time.asctime(),'Server started on port', port)
    print('....')
src/Microwave/demo/udp_test_get.py
@@ -1,6 +1,6 @@
from socketserver import BaseRequestHandler, UDPServer
import time
import os
import os, sys
cudir,_ = os.path.split(__file__)
@@ -12,30 +12,44 @@
packed_count = 0
class PointCloudUDPServer(BaseRequestHandler):
class PointCloudUDPRequestHandler(BaseRequestHandler):
    def handle(self):
        global packed_count
        print('Got connection from {}, {}'.format(self.client_address, packed_count))
        print(time.asctime(),' Got connection from {}, {}'.format(self.client_address, packed_count))
        # Get message and client socket
        msg, sock = self.request
        f = open('{}/packet{:000006}.udp'.format(file_folder,packed_count), 'wb')
        f = open('{}/packet{}.udp'.format(file_folder,packed_count), 'wb')
        f.write(msg)
        f.close()
        packed_count += 1
        if packed_count >= 100:
        if packed_count >= 1000000:
            UDPServer.server_close(server)
if __name__ == '__main__':
    global server
    def help():
        print("Usage: udp_test_get.py [host]. host can be 'test' or 'microwave' ")
        exit(1)
    if len(sys.argv) == 2:
        if sys.argv[1] == 'test':
    host = ''
    # host = '192.168.2.65'
        elif sys.argv[1] == 'microwave':
            host = '192.168.2.65'
        else:
            help()
    else:
        help()
    global server
    # host = ''
    # host = '192.168.2.65' # use this host to get the udp data from microwave device
    port = 9911
    server =UDPServer((host, port), PointCloudUDPServer)
    server =UDPServer((host, port), PointCloudUDPRequestHandler)
    print(time.asctime(),'Server started on port', port)
    print('....')
    print('ctrl-c to quit server.')
src/Microwave/demo/udp_test_send.py
@@ -16,5 +16,6 @@
            client_socket.settimeout(1.0)
            addr = ("127.0.0.1", 9911)
            client_socket.sendto(message, addr)
            print (time.asctime(), f' Sending {file} to {addr} ...')
            time.sleep(0.1)
    print('Done!')
src/engine/__init__.py
@@ -0,0 +1,8 @@
from .AcquisitionMain import *
from .CaptureThread import *
from .ControllThread import *
from .DeviceManager import *
from .DustCleaner import *
from .DustCleanerThread import *
from .MessageQueueThread import *
from .MicroWaveUDPThread import *
src/protos/compile.bat
@@ -4,7 +4,7 @@
cd %~dp0
echo change to path: %cd%
set protoc=%cd%\..\..\env\aerial_deploy\Library\bin\protoc.exe
set protoc=%cd%/../../env/aerial_deploy/Library/bin/protoc.exe
%protoc% aerial.proto --python_out=%cd%