cmd

package
v1.3.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Copyright © 2023 NAME HERE <EMAIL ADDRESS>

Index

Constants

This section is empty.

Variables

View Source
var FreqCmd = &cobra.Command{
	Use:   "freq [MHz]",
	Short: "Get or Set current frequency",
	Run: func(cmd *cobra.Command, args []string) {
		freq := ""
		if len(args) != 0 {
			freq = args[0]
		}
		port, err := djx100.Connect(rootCmd.PersistentFlags().Lookup("port").Value.String())
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		response, err := djx100.SendCmd(port, "AL~FREQ"+freq)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		fmt.Println(response)
	},
}
View Source
var GPSCmd = &cobra.Command{
	Use:   "gps",
	Short: "GPS Info",
	Run: func(cmd *cobra.Command, args []string) {
		port, err := djx100.Connect(rootCmd.PersistentFlags().Lookup("port").Value.String())
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		response, err := djx100.SendCmd(port, "AL~GPS")
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		fmt.Println(response)
	},
}
View Source
var ReadCmd = &cobra.Command{
	Use:   "read [address]",
	Short: "Read Data",
	Args:  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		port, err := djx100.Connect(rootCmd.PersistentFlags().Lookup("port").Value.String())
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		response, err := djx100.ReadData(port, args[0])
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		fmt.Println(response)
	},
}
View Source
var SQLCmd = &cobra.Command{
	Use:   "sql <level>",
	Short: "Set SQL [0-35]",
	Args:  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		port, err := djx100.Connect(rootCmd.PersistentFlags().Lookup("port").Value.String())
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		response, err := djx100.SendCmd(port, "AL~SQL"+args[0])
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		fmt.Println(response)
	},
}
View Source
var VolCmd = &cobra.Command{
	Use:   "vol <level>",
	Short: "Set Volume [0-35]",
	Args:  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		port, err := djx100.Connect(rootCmd.PersistentFlags().Lookup("port").Value.String())
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		response, err := djx100.SendCmd(port, "AL~VOL"+args[0])
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		fmt.Println(response)
	},
}
View Source
var WriteCmd = &cobra.Command{
	Use:   "write [address] [data]",
	Short: "Write Data",
	Args:  cobra.MinimumNArgs(2),
	Run: func(cmd *cobra.Command, args []string) {
		port, err := djx100.Connect(rootCmd.PersistentFlags().Lookup("port").Value.String())
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		if len(args[1]) != 256 {
			fmt.Println("Data size must be 256")
			os.Exit(1)
		}
		response, err := djx100.WriteData(port, args[0], args[1])
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		fmt.Println(response)

		err = djx100.RestartCmd(port)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

	},
}

Functions

func Execute

func Execute()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL