auto setting env and getting udp data
| | |
| | | @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 |
| New file |
| | |
| | | @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 |
| New file |
| | |
| | | @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 |
| New file |
| | |
| | | @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 |
| New file |
| | |
| | | @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 |
| | |
| | | print("Frame {} ready".format(frame_number)) |
| | | with open(bin_name, "wb") as bin_file: |
| | | bin_file.write(receiver.DataFrame) |
| | | bin_file.close() |
| | |
| | | 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: |
| | |
| | | # 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('....') |
| | |
| | | from socketserver import BaseRequestHandler, UDPServer |
| | | import time |
| | | import os |
| | | import os, sys |
| | | |
| | | |
| | | cudir,_ = os.path.split(__file__) |
| | |
| | | |
| | | 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__': |
| | | |
| | | 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 = '' |
| | | elif sys.argv[1] == 'microwave': |
| | | host = '192.168.2.65' |
| | | else: |
| | | help() |
| | | else: |
| | | help() |
| | | |
| | | global server |
| | | host = '' |
| | | # host = '192.168.2.65' |
| | | # 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.') |
| | |
| | | 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!') |
| | |
| | | from .AcquisitionMain import * |
| | | from .CaptureThread import * |
| | | from .ControllThread import * |
| | | from .DeviceManager import * |
| | | from .DustCleaner import * |
| | | from .DustCleanerThread import * |
| | | from .MessageQueueThread import * |
| | | from .MicroWaveUDPThread import * |
| | |
| | | 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% |
| | | |