Linux-PTY-Rückweg und plattformabhängige Porttests ergänzen

This commit is contained in:
Dieter Lang 2026-08-22 16:24:15 +02:00
parent d890aba7b4
commit c9e3ba052a
3 changed files with 36 additions and 5 deletions

View file

@ -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"
}

View file

@ -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.

View file

@ -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,
)
}