diff --git a/peripheral/devices/cdash_display.go b/peripheral/devices/cdash_display.go index a8f0e4a..20a0622 100644 --- a/peripheral/devices/cdash_display.go +++ b/peripheral/devices/cdash_display.go @@ -56,11 +56,6 @@ func createWindow(dCMD *DeviceCMD, args []string) (types.Command, []byte, error) Title [32]byte } - err := dCMD.ArgCheck(args) - if err != nil { - return 0, []byte{}, err - } - x0, err := strconv.ParseInt(args[0], 10, 0) if err != nil { return 0, []byte{}, err @@ -111,11 +106,6 @@ func destroyWindow(dCMD *DeviceCMD, args []string) (types.Command, []byte, error WinID int16 } - err := dCMD.ArgCheck(args) - if err != nil { - return 0, []byte{}, err - } - id, err := strconv.ParseInt(args[0], 10, 0) if err != nil { return 0, []byte{}, err diff --git a/peripheral/devices/devices.go b/peripheral/devices/devices.go index e32cbf7..b3fd134 100644 --- a/peripheral/devices/devices.go +++ b/peripheral/devices/devices.go @@ -58,6 +58,17 @@ type DeviceCMD struct { Fn DeviceCMDFn } +func (dCMD *DeviceCMD) Run(args []string) (types.Command, []byte, error) { + // Validate the arguments in the device function + err := dCMD.ArgCheck(args) + if err != nil { + return 0, []byte{}, err + } + + // Run the function + return dCMD.Fn(dCMD, args) +} + func (dCMD *DeviceCMD) GetIdentifier() types.Command { return dCMD.Identifier } diff --git a/peripheral/peripheral.go b/peripheral/peripheral.go index 5245ad3..8d90d3e 100644 --- a/peripheral/peripheral.go +++ b/peripheral/peripheral.go @@ -120,7 +120,7 @@ func (clerk *PeripheralDeviceClerk) RunDeviceFunction(ID uint8, f string, args [ } // Execute the function - command, payload, err := cmd.Fn(cmd, args) + command, payload, err := cmd.Run(args) if err != nil { return err }