Linux-PTY-Rückweg und plattformabhängige Porttests ergänzen
This commit is contained in:
parent
d890aba7b4
commit
c9e3ba052a
3 changed files with 36 additions and 5 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"virtual_ports": [
|
"virtual_ports": [
|
||||||
{
|
{
|
||||||
"port": "COM100",
|
"port": "/dev/ttyUSB100",
|
||||||
"remote_device": "rotor",
|
"remote_device": "rotor",
|
||||||
"startup_bytes": "57 00 00 00 00 00 00 00 00 00 00 1F 20"
|
"startup_bytes": "57 00 00 00 00 00 00 00 00 00 00 1F 20"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,30 @@ func (p *ptySerial) Write(b []byte) (int, error) {
|
||||||
return 0, fmt.Errorf("PTY master is closed")
|
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.
|
// Close closes the PTY master and slave.
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,13 @@ package config_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"git.lang-dieter.de/rs2322tcp/internal/config"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"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]
|
port := cfg.VirtualPorts[0]
|
||||||
|
|
||||||
if port.Port != "COM100" {
|
if port.Port != expectedPort {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"VirtualPorts[0].Port = %q, want %q",
|
"VirtualPorts[0].Port = %q, want %q",
|
||||||
port.Port,
|
port.Port,
|
||||||
"COM100",
|
expectedPort,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue