[arduinorelay] Don't expect the correct port format

The port format expected was a single hexadecimal digit, but this puts a
lot of weight on salt configs to do the conversion from integers to
hexadecimal digits. We'd rather do that here ourselves.

IN-367

Change-Id: I131c5a8df676bb1866730e629134dd26c3defb8d
diff --git a/pdu/arduinorelay/arduinorelay.go b/pdu/arduinorelay/arduinorelay.go
index f15c82f..38fc353 100644
--- a/pdu/arduinorelay/arduinorelay.go
+++ b/pdu/arduinorelay/arduinorelay.go
@@ -7,6 +7,7 @@
 import (
 	"fmt"
 	"io"
+	"strconv"
 	"time"
 
 	"fuchsia.googlesource.com/infra/infra/serial"
@@ -15,8 +16,15 @@
 const baudRate = 115200
 
 func Reboot(path string, port string) error {
-	if len(port) != 1 {
-		return fmt.Errorf("port must be exactly 1 byte in size")
+	// Port will be an integer here.
+	portNum, err := strconv.Atoi(port)
+	if err != nil {
+		return err
+	}
+	// Port number must not be 0 since that means "reboot all" and valid ports
+	// are only hexadecimal digits 1-F.
+	if portNum <= 0 || portNum >= 15 {
+		return fmt.Errorf("port number must be >0 and <16, got %d", portNum)
 	}
 
 	// Open the device for writing with 10 second timeout.
@@ -26,7 +34,7 @@
 	}
 
 	// Turn off device.
-	n, err := io.WriteString(device, port+"0")
+	n, err := io.WriteString(device, fmt.Sprintf("%X0", portNum))
 	if err != nil {
 		return err
 	} else if n != 2 {
@@ -38,7 +46,7 @@
 	time.Sleep(1 * time.Second)
 
 	// Turn the device back on.
-	n, err = io.WriteString(device, port+"1")
+	n, err = io.WriteString(device, fmt.Sprintf("%X1", portNum))
 	if err != nil {
 		return err
 	} else if n != 2 {