move to utils package
This commit is contained in:
+5
-15
@@ -16,11 +16,9 @@ limitations under the License.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tarm/serial"
|
||||
"it2000.com.cn/tele-recv/database"
|
||||
"os"
|
||||
"it2000.com.cn/tele-recv/utils"
|
||||
"log"
|
||||
)
|
||||
|
||||
// testCmd represents the test command
|
||||
@@ -34,18 +32,10 @@ Test load sqlite database and init table`,
|
||||
}
|
||||
|
||||
func test(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("test called")
|
||||
fmt.Println("device :", device)
|
||||
c := &serial.Config{Name: device, Baud: baudrate, Size: bytesize}
|
||||
s, err := serial.OpenPort(c)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println(c, "opened")
|
||||
_ = s.Close()
|
||||
log.Println("Testing environment")
|
||||
_ = utils.OpenPort(device, baudrate, bytesize)
|
||||
|
||||
err = database.Init(dbFile, dbInit)
|
||||
err := utils.InitDb(dbFile, dbInit)
|
||||
if err != nil {
|
||||
println("create database error ", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user