FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
06-12-2024 02:32 PM
I'm developing an App with UDP communication. But I had trouble getting the communication running, even though I've entered the port number in the "Port forwarding" field.
Then, I've found out that CtrlX WORKS is assuming tcp, which leads to the following line in the "start.bat" file of the app build environment:
call launch.bat amd64 noproxy "hostfwd=tcp::11022-:22,hostfwd=tcp::16110-:6110" Testbuilder whpx:tcg
When I manually changed it to "udp" and started the environment manually via "start.bat", my communication worked.
call launch.bat amd64 noproxy "hostfwd=tcp::11022-:22,hostfwd=udp::16110-:6110" Testbuilder whpx:tcg
Unfortunately, on every start via CtrlX Works, this line is set back to "tcp".
Is there a way to define port forwarding for "upd" in the app build environment properties in CtrlX WORKS?
Solved! Go to Solution.
06-12-2024 02:51 PM
Did you try to remove the port form the Port Forwarding settings in the ctrlX Works UI. And then manually add the udp port to the start.bat?
06-12-2024 03:05 PM - edited 06-12-2024 03:22 PM
Hi @BennyF,
You can manually add the UDP ports to the launch.bat which won't be changed on modification of the ctrlX WORKS configuration.
@echo off
rem Parameters
rem %1 CPU Architecture Guest System: amd64 (default), aarch64
rem %2 Proxy usage: proxy (default), no-proxy
rem Important:
rem Enclose these parameter values with quotation marks otherwise they will be splitted.
rem %3 Port Forwarding: "hostfwd=tcp::10022-:22,hostfwd=tcp::8000-:8000,hostfwd=...."
rem %4 Acceleration: "whpx:hax:tcg"
set ARCH=%~1
If not defined ARCH (set ARCH=amd64)
set PROXY=%~2
If not defined PROXY (set PROXY=proxy)
set TCP_PFW=%~3
If not defined TCP_PFW (set PFW=hostfwd=tcp::10022-:22)
set UDP_PFW=hostfwd=udp::16110-:6110
set PFW=%TCP_PFW%%UDP_PFW%
echo %PFW%
pause
set NAME=%~4
If not defined NAME (set NAME=App-Build-Environment)
set ACCEL=%~5
If not defined ACCEL (set ACCEL=whpx:hax:tcg)
set ACTIVITY="Initializing, please wait - restart if finshed"
if exist *.qcow2 (set ACTIVITY= )
TITLE %NAME% %ACTIVITY% %CD% %ARCH% %PFW%
set OS=ubuntu-20.04-server
set ARCH=amd64
set PROXY=proxy
set AR=ar
set NO=no
rem https://stackoverflow.com/questions/7005951/batch-file-find-if-substring-is-in-string-not-in-a-file
for %%x in (%*) do (
echo %%x
echo %%x | FINDSTR /C:%AR% >nul && ( set ARCH=aarch64)
echo %%x | FINDSTR /C:%NO% >nul && ( set PROXY=noproxy)
)
:: Check cloud image file ---------------------------------------------------
set U=%OS%-cloudimg
set UA=%U%-%ARCH%
set IMG=%UA%.img
set QCOW2=%UA%-snapshot-%PROXY%.qcow2
set UDIMG=%UA%-user-data-%PROXY%.img
IF "%ARCH%" == "aarch64" (
set IMG=%U%-arm64.img
)
if not exist %IMG% (
call wget.bat https://cloud-images.ubuntu.com/releases/focal/release/%IMG% %IMG%
)
if not exist %IMG% (
echo ERROR: File '%IMG%' is missing
echo INFO: Download this file from 'https://cloud-images.ubuntu.com/releases/focal/release' and copy it into this directory
exit /B 1
)
:: Create snapshot file --------------------------------------------------------
if not exist %QCOW2% (
qemu-img create -b %IMG% -f qcow2 %QCOW2% -F qcow2 32G
)
:: Check user data image file -------------------------------------------------
if not exist %UDIMG% (
echo ERROR: File '%UDIMG%' is missing
echo INFO: Copy this file from your SDK zip archive into this directory
exit /B 1
)
REM wget.exe changes the title
TITLE %NAME% %ACTIVITY% %CD% %ARCH% %PFW%
REM Enable ESC sequences for enhanced text output in console - needs no admin rights
REG ADD HKCU\CONSOLE /f /v VirtualTerminalLevel /t REG_DWORD /d 1
IF "%ARCH%" == "amd64" (
qemu-system-x86_64.exe ^
-name "%NAME%" ^
-machine q35,accel=%ACCEL% ^
-smp 4 ^
-m 4G ^
-netdev user,id=eth0,%PFW% ^
-device virtio-net-pci,netdev=eth0,mac=DE-AD-BE-00-00-01 ^
-drive "file=%QCOW2%,format=qcow2" ^
-drive "file=%UDIMG%,format=raw" ^
-display none ^
-nographic
exit /B 0
)
if not exist QEMU_EFI.fd (
call wget.bat https://releases.linaro.org/components/kernel/uefi-linaro/16.02/release/qemu64/QEMU_EFI.fd QEMU_EFI.fd
)
if not exist QEMU_EFI.fd (
echo ERROR: File QEMU_EFI.fd is missing
echo INFO: Download this file from 'https://releases.linaro.org/components/kernel/uefi-linaro/16.02/release/qemu64' and copy it into this directory
exit /B 1
)
REM Windows only: -cpu cortex-a72
qemu-system-aarch64.exe ^
-name "%NAME%" ^
-M virt ^
-cpu cortex-a72 ^
-accel tcg ^
-smp 4 ^
-m 4G ^
-bios QEMU_EFI.fd ^
-netdev user,id=eth0,%PFW% ^
-device virtio-net-pci,netdev=eth0,mac=DE-AD-BE-00-00-01 ^
-drive "file=%QCOW2%,format=qcow2" ^
-drive "file=%UDIMG%,format=raw" ^
-display none ^
-nographic
The relevant section is here. I had it pausing for debug purposes, so really you want to append the UDP ports to the PFW variable and remove the pause:
set TCP_PFW=%~3
If not defined TCP_PFW (set PFW=hostfwd=tcp::10022-:22)
set UDP_PFW=hostfwd=udp::16110-:6110
set PFW=%TCP_PFW%%UDP_PFW%
echo %PFW%
pause
06-12-2024 06:04 PM
Hello @Sgilk,
yes, that solution worked for me. The start.bat file is overwritten by CtrlX WORKS on starting the app build environment. The launch.bat file is not touched. I only had to add a "," between TCP_PFW and UDP_PFW:
set PFW=%TCP_PFW%,%UDP_PFW%
Then, your solution worked fine for me. Thanks!