From c9e3ba052a34741aa000dca6943dd82ecc5edb86 Mon Sep 17 00:00:00 2001 From: Dieter Lang Date: Sat, 22 Aug 2026 16:24:15 +0200 Subject: [PATCH] =?UTF-8?q?Linux-PTY-R=C3=BCckweg=20und=20plattformabh?= =?UTF-8?q?=C3=A4ngige=20Porttests=20erg=C3=A4nzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/client.json | 2 +- internal/client/pty_linux.go | 25 ++++++++++++++++++++++++- internal/config/config_test.go | 14 +++++++++++--- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/configs/client.json b/configs/client.json index 69af052..5983adf 100644 --- a/configs/client.json +++ b/configs/client.json @@ -9,7 +9,7 @@ }, "virtual_ports": [ { - "port": "COM100", + "port": "/dev/ttyUSB100", "remote_device": "rotor", "startup_bytes": "57 00 00 00 00 00 00 00 00 00 00 1F 20" } diff --git a/internal/client/pty_linux.go b/internal/client/pty_linux.go index a07eca4..709a4b2 100644 --- a/internal/client/pty_linux.go +++ b/internal/client/pty_linux.go @@ -205,7 +205,30 @@ func (p *ptySerial) Write(b []byte) (int, error) { return 0, fmt.Errorf("PTY master is closed") } - return unix.Write(fd, b) + fmt.Printf( + "PTY TX [%s]: % X\n", + p.path, + b, + ) + + n, err := unix.Write(fd, b) + + if err != nil { + fmt.Printf( + "PTY TX Fehler [%s]: %v\n", + p.path, + err, + ) + return n, err + } + + fmt.Printf( + "PTY TX erfolgreich [%s]: %d Bytes\n", + p.path, + n, + ) + + return n, nil } // Close closes the PTY master and slave. diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 523fef9..8cc3587 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -8,11 +8,13 @@ package config_test import ( "encoding/json" - "git.lang-dieter.de/rs2322tcp/internal/config" "os" "path/filepath" + "runtime" "strings" "testing" + + "git.lang-dieter.de/rs2322tcp/internal/config" ) /////////////////////////////////////////////////////////////////////////////// @@ -485,13 +487,19 @@ func TestExampleClientConfig(t *testing.T) { ) } + expectedPort := "COM100" + + if runtime.GOOS == "linux" { + expectedPort = "/dev/ttyUSB100" + } + port := cfg.VirtualPorts[0] - if port.Port != "COM100" { + if port.Port != expectedPort { t.Errorf( "VirtualPorts[0].Port = %q, want %q", port.Port, - "COM100", + expectedPort, ) }