Implemented additional checks. Add force flag to flash firmware even if modem is in BIOS mode.

This commit is contained in:
2021-12-21 17:26:43 +01:00
parent c9847645ba
commit befec94cc6
3 changed files with 37 additions and 12 deletions

15
main.go
View File

@@ -1,3 +1,7 @@
// Copyright 2021 Torsten Harenberg DL1THM. All rights reserved.
// A SCS PACTOR modem flashing utility written in Go. Should run anywhere Go runs.
package main
import (
@@ -16,8 +20,11 @@ func main() {
serialDevice := parser.String("s", "serialDevice", &argparse.Options{Required: false, Help: "(optional) serial device the modem is attached to, e.g. /dev/ttyUSB0. If not set, go-scsupdate will search for SCS modems."})
brate := parser.Int("b", "baudrate", &argparse.Options{Required: false, Help: "(optional, required when -s is set) sets the serial baudrate, e.g. 115200"})
f := parser.String("f", "file", &argparse.Options{Required: true, Help: "(required) the file to flash, e.g. profi41r.pro"})
debug := parser.Flag("d", "debug", &argparse.Options{Required: false, Help: "(optional) enable debug logs"})
dryrun := parser.Flag("n", "dryrun", &argparse.Options{Required: false, Help: "(optional) drying: if set, modem will detected but no firmware being written"})
force := parser.Flag("", "force", &argparse.Options{Required: false, Help: "(optional) skip testing if firmware fits modem. Useful if the modem is bricked and you need to put it into BIOS mode. Read the manual!"})
sertimeout := parser.Int("t", "timeout", &argparse.Options{Required: false, Help: "(optional) Sets the read and write timeout. Default: 70. If you have handshake problems, enlarge this values, especially for older modems."})
err := parser.Parse(os.Args)
cLog := console.New(true)
if *debug {
@@ -27,6 +34,10 @@ func main() {
log.AddHandler(cLog, log.InfoLevel, log.ErrorLevel, log.AlertLevel, log.WarnLevel, log.NoticeLevel, log.PanicLevel)
}
if *sertimeout == 0 { // if not set, set the write / read timeout to 70
*sertimeout = 70
}
if *serialDevice != "" && *brate == 0 {
log.Fatal("ERROR: if you specify a device, you need to specify a baud rate as well. Cannot continue")
}
@@ -79,9 +90,9 @@ func main() {
if *dryrun != true {
var err error
if *serialDevice != "" {
err = update.Update(*serialDevice, baudrate, *f)
err = update.Update(*serialDevice, baudrate, *sertimeout, *f, *force)
} else {
err = update.Update(ports[0].Port, baudrate, *f)
err = update.Update(ports[0].Port, baudrate, *sertimeout, *f, *force)
}
if err != nil {
log.Panic(err)