[botanist] Prefer using serial multiplexer on devices

The Start() function in device.go was accessing the raw character
device instead of the serial multiplexer. This change will transition us
over to the multiplexer.

Bug: b/203605183
Change-Id: I58d5612cbb1d6cb39f43c6e4a1568006cad3f6f4
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/596106
Reviewed-by: Nathan Mulcahey <nmulcahey@google.com>
Fuchsia-Auto-Submit: Anirudh Mathukumilli <rudymathu@google.com>
Commit-Queue: Anirudh Mathukumilli <rudymathu@google.com>
diff --git a/tools/botanist/target/device.go b/tools/botanist/target/device.go
index 5996bdf..16342e3 100644
--- a/tools/botanist/target/device.go
+++ b/tools/botanist/target/device.go
@@ -51,6 +51,9 @@
 
 	// Serial is the path to the device file for serial i/o.
 	Serial string `json:"serial,omitempty"`
+
+	// SerialMux is the path to the device's serial multiplexer.
+	SerialMux string `json:"serial_mux,omitempty"`
 }
 
 // NetworkProperties are the static network properties of a target.
@@ -104,7 +107,16 @@
 		return nil, fmt.Errorf("could not parse out signers from private keys: %w", err)
 	}
 	var s io.ReadWriteCloser
-	if config.Serial != "" {
+	if config.SerialMux != "" {
+		s, err = serial.NewSocket(ctx, config.SerialMux)
+		if err != nil {
+			return nil, fmt.Errorf("unable to open: %s: %w", config.SerialMux, err)
+		}
+		// Dump the existing serial debug log buffer.
+		if _, err := io.WriteString(s, dlogCmd); err != nil {
+			return nil, fmt.Errorf("failed to tail serial logs: %w", err)
+		}
+	} else if config.Serial != "" {
 		s, err = serial.Open(config.Serial)
 		if err != nil {
 			return nil, fmt.Errorf("unable to open %s: %w", config.Serial, err)