Windows-Testskripte für Rotorverbindung ergänzen
This commit is contained in:
parent
d9a70b9225
commit
21d622e040
4 changed files with 110 additions and 4 deletions
|
|
@ -11,10 +11,6 @@
|
||||||
{
|
{
|
||||||
"port": "COM100",
|
"port": "COM100",
|
||||||
"remote_device": "rotor"
|
"remote_device": "rotor"
|
||||||
},
|
|
||||||
{
|
|
||||||
"port": "COM101",
|
|
||||||
"remote_device": "radio"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
12
scripts/test-rotor-com10.bat
Normal file
12
scripts/test-rotor-com10.bat
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
@echo off
|
||||||
|
cd /d "%~dp0.."
|
||||||
|
|
||||||
|
echo ==========================================
|
||||||
|
echo rs2322tcp COM10 Testsequenz
|
||||||
|
echo ==========================================
|
||||||
|
echo.
|
||||||
|
|
||||||
|
powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\scripts\test-rotor-com10.ps1"
|
||||||
|
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
80
scripts/test-rotor-com10.ps1
Normal file
80
scripts/test-rotor-com10.ps1
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
$port = New-Object System.IO.Ports.SerialPort COM10,600,None,8,one
|
||||||
|
|
||||||
|
try {
|
||||||
|
$port.Open()
|
||||||
|
|
||||||
|
[byte[]]$request = 0x57,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x20
|
||||||
|
|
||||||
|
$port.Write($request, 0, $request.Length)
|
||||||
|
|
||||||
|
$response = New-Object System.Collections.Generic.List[byte]
|
||||||
|
|
||||||
|
$timeout = [DateTime]::UtcNow.AddSeconds(2)
|
||||||
|
|
||||||
|
while ([DateTime]::UtcNow -lt $timeout) {
|
||||||
|
|
||||||
|
while ($port.BytesToRead -gt 0) {
|
||||||
|
$buffer = New-Object byte[] $port.BytesToRead
|
||||||
|
$count = $port.Read($buffer, 0, $buffer.Length)
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt $count; $i++) {
|
||||||
|
$response.Add($buffer[$i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auf das Startbyte 57 synchronisieren.
|
||||||
|
$start = $response.IndexOf([byte]0x57)
|
||||||
|
|
||||||
|
if ($start -ge 0 -and ($response.Count - $start) -ge 12) {
|
||||||
|
$response = [System.Collections.Generic.List[byte]](
|
||||||
|
$response.GetRange($start, 12)
|
||||||
|
)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-Sleep -Milliseconds 20
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response.Count -eq 12) {
|
||||||
|
$actual = ($response |
|
||||||
|
ForEach-Object { "{0:X2}" -f $_ }) -join " "
|
||||||
|
|
||||||
|
$expected = "57 07 01 06 00 01 03 06 02 00 01 20"
|
||||||
|
|
||||||
|
Write-Host "Bytes empfangen: $($response.Count)"
|
||||||
|
Write-Host "Antwort: $actual"
|
||||||
|
|
||||||
|
if ($actual -eq $expected) {
|
||||||
|
Write-Host "TEST ERFOLGREICH"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "TEST FEHLGESCHLAGEN"
|
||||||
|
Write-Host "Erwartet: $expected"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Bytes empfangen: $($response.Count)"
|
||||||
|
|
||||||
|
if ($response.Count -gt 0) {
|
||||||
|
$actual = ($response |
|
||||||
|
ForEach-Object { "{0:X2}" -f $_ }) -join " "
|
||||||
|
Write-Host "Antwort: $actual"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Keine Antwort"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "TEST FEHLGESCHLAGEN - keine vollstaendige Antwort gefunden"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if ($port.IsOpen) {
|
||||||
|
$port.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
$port.Dispose()
|
||||||
|
$port = $null
|
||||||
|
|
||||||
|
[GC]::Collect()
|
||||||
|
[GC]::WaitForPendingFinalizers()
|
||||||
|
}
|
||||||
18
scripts/test-windows-client.bat
Normal file
18
scripts/test-windows-client.bat
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
@echo off
|
||||||
|
cd /d "%~dp0.."
|
||||||
|
|
||||||
|
echo ==========================================
|
||||||
|
echo rs2322tcp Windows Client Test
|
||||||
|
echo ==========================================
|
||||||
|
echo.
|
||||||
|
echo Starte technischen Client...
|
||||||
|
echo COM100 wird vom Client verwendet.
|
||||||
|
echo COM10 wird fuer die Testsequenz verwendet.
|
||||||
|
echo.
|
||||||
|
echo Zum Beenden: Ctrl+C
|
||||||
|
echo.
|
||||||
|
go run .\cmd\rs2322tcp-client-test
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Client beendet.
|
||||||
|
pause
|
||||||
Loading…
Reference in a new issue