remove command function
This commit is contained in:
+4
-2
@@ -36,7 +36,9 @@ and usage of using your command. For example:
|
|||||||
Cobra is a CLI library for Go that empowers applications.
|
Cobra is a CLI library for Go that empowers applications.
|
||||||
This application is a tool to generate the needed files
|
This application is a tool to generate the needed files
|
||||||
to quickly create a Cobra application.`,
|
to quickly create a Cobra application.`,
|
||||||
Run: start,
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
start()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var run bool
|
var run bool
|
||||||
@@ -55,7 +57,7 @@ func init() {
|
|||||||
// startCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
// startCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||||
}
|
}
|
||||||
|
|
||||||
func start(cmd *cobra.Command, args []string) {
|
func start() {
|
||||||
// Go signal notification works by sending `os.Signal`
|
// Go signal notification works by sending `os.Signal`
|
||||||
// values on a channel. We'll create a channel to
|
// values on a channel. We'll create a channel to
|
||||||
// receive these notifications (we'll also make one to
|
// receive these notifications (we'll also make one to
|
||||||
|
|||||||
+4
-2
@@ -28,10 +28,12 @@ var testCmd = &cobra.Command{
|
|||||||
Long: `loading config file
|
Long: `loading config file
|
||||||
Test serial port
|
Test serial port
|
||||||
Test load sqlite database and init table`,
|
Test load sqlite database and init table`,
|
||||||
Run: test,
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
test()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func test(cmd *cobra.Command, args []string) {
|
func test() {
|
||||||
log.Println("Testing environment")
|
log.Println("Testing environment")
|
||||||
_ = utils.OpenPort(device, baudrate, bytesize)
|
_ = utils.OpenPort(device, baudrate, bytesize)
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ func OpenPort(device string, baudrate int, bytesize byte) error {
|
|||||||
|
|
||||||
func ReadPort() ([]byte, int){
|
func ReadPort() ([]byte, int){
|
||||||
buffer := make([]byte, 256)
|
buffer := make([]byte, 256)
|
||||||
|
if !ServerRunning {
|
||||||
|
return buffer, 0
|
||||||
|
}
|
||||||
count,err := port.Read(buffer)
|
count,err := port.Read(buffer)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
log.Println("error in read port ", err)
|
log.Println("error in read port ", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user