2 Commits
v0.1 ... master

Author SHA1 Message Date
Torsten Harenberg
99bcee2e92 v0.2: updated README.md 2022-06-30 11:14:39 +02:00
Torsten Harenberg
709e47a585 v0.2: improved serial i/o significantly 2022-06-30 11:10:13 +02:00
10 changed files with 131 additions and 94 deletions

21
.idea/remote-targets.xml generated Normal file
View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteTargetsManager">
<targets>
<target name="pi@funkpi.fritz.box:22" type="ssh/sftp" uuid="aeb286c6-b75d-4521-a125-14979623eb00">
<config>
<option name="projectRootOnTarget" value="/home/pi/go-scsupdate" />
<option name="serverName" value="pi@funkpi.fritz.box:22 password" />
<option name="useRsync" value="true" />
</config>
<ContributedStateBase type="GoLanguageRuntime">
<config>
<option name="goPath" value="/home/pi/go" />
<option name="goRoot" value="/usr/local/go/bin//go" />
<option name="goVersion" value="go1.18.3 linux/arm" />
</config>
</ContributedStateBase>
</target>
</targets>
</component>
</project>

View File

@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="go build go-scsupdate" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
<module name="go-scsupdate" />
<target name="pi@funkpi.fritz.box:22" />
<working_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<package value="go-scsupdate" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<option name="build_on_remote_target" value="true" />
<option name="run" value="false" />
<method v="2" />
</configuration>
</component>

View File

@@ -1,5 +1,11 @@
# go-scsupdate Changelog # go-scsupdate Changelog
## v0.2
- serial write process now handles error (especially interrupted system call errors) properly
- remove serial timeout parameter - no needed anymore with the change above
- moved to go-playground/log/v8
## v0.1 ## v0.1
Initial release Initial release

View File

@@ -29,9 +29,6 @@ firmware being written
--force (optional) skip testing if firmware fits modem. Useful if --force (optional) skip testing if firmware fits modem. Useful if
the modem is bricked and you need to put it into BIOS the modem is bricked and you need to put it into BIOS
mode. Read the manual! mode. Read the manual!
-t --timeout (optional) Sets the read and write timeout. Default: 70.
If you have handshake problems, enlarge this values,
especially for older modems.`
``` ```
All options but -f, --file are optional. This requires that your OS is connected to the PACTOR modem through USB or Bluetooth (USB highly recommended!). All options but -f, --file are optional. This requires that your OS is connected to the PACTOR modem through USB or Bluetooth (USB highly recommended!).

View File

@@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"errors" "errors"
"github.com/go-playground/log/v7" "github.com/go-playground/log/v8"
"hash/crc32" "hash/crc32"
"io" "io"
"io/ioutil" "io/ioutil"

14
go.mod
View File

@@ -4,23 +4,21 @@ go 1.17
require ( require (
github.com/akamensky/argparse v1.3.1 github.com/akamensky/argparse v1.3.1
github.com/albenik/go-serial/v2 v2.4.0 github.com/albenik/go-serial/v2 v2.5.1
github.com/go-playground/log/v8 v8.0.1
github.com/schollz/progressbar/v3 v3.8.3
) )
require ( require (
github.com/creack/goselect v0.1.2 // indirect github.com/creack/goselect v0.1.2 // indirect
github.com/go-playground/ansi/v3 v3.0.0 // indirect github.com/go-playground/errors/v5 v5.2.3 // indirect
github.com/go-playground/errors/v5 v5.1.1 // indirect github.com/go-playground/pkg/v5 v5.6.0 // indirect
github.com/go-playground/log/v7 v7.0.2 // indirect
github.com/go-playground/pkg/v4 v4.0.0 // indirect
github.com/go-playground/pkg/v5 v5.3.0 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/rivo/uniseg v0.2.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect
github.com/schollz/progressbar/v3 v3.8.3 // indirect
go.uber.org/atomic v1.9.0 // indirect go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect go.uber.org/multierr v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
) )

57
go.sum
View File

@@ -1,35 +1,27 @@
github.com/RackSec/srslog v0.0.0-20180709174129-a4725f04ec91/go.mod h1:cDLGBht23g0XQdLjzn6xOGXDkLK182YfINAaZEQLCHQ=
github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g= github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g=
github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA= github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
github.com/albenik/go-serial/v2 v2.4.0 h1:2yIM9C0l0YznmMbHF8Yw+j0XY1ZDy5YciqhGdOik6r8= github.com/albenik/go-serial/v2 v2.5.1 h1:nnnyjuwIJLdih8yJyrncLFLQtGCnIppLcTNNtPg+ME0=
github.com/albenik/go-serial/v2 v2.4.0/go.mod h1:JUrQKdczCMB0FlXt2rlJJ8zbfFzmjTIAkLPyyVfr5ho= github.com/albenik/go-serial/v2 v2.5.1/go.mod h1:ySdCqoERscw1xluK1n62R8Faoyu+jXKwVHPa1lSSAew=
github.com/aws/aws-sdk-go v1.25.31/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.44.24/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
github.com/aws/aws-sdk-go v1.32.11/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0= github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0=
github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY= github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-playground/ansi/v3 v3.0.0 h1:TXexAx1sXuL/N/cqV472ffRdkoiqPA3LeKMXCoz8t4Y=
github.com/go-playground/ansi/v3 v3.0.0/go.mod h1:btm11Vjtjy20mZiJwufDvdVAVxjLuYFDu164b83ekBs=
github.com/go-playground/assert v1.2.1/go.mod h1:Lgy+k19nOB/wQG/fVSQ7rra5qYugmytMQqvQ2dgjWn8= github.com/go-playground/assert v1.2.1/go.mod h1:Lgy+k19nOB/wQG/fVSQ7rra5qYugmytMQqvQ2dgjWn8=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/errors/v5 v5.0.1/go.mod h1:p7HVwyH3I0esuPnvChd2Uf4ceZwG2GcaDT/KpzCN18M= github.com/go-playground/errors/v5 v5.2.3 h1:RPxaFHgJZjgk/OFkUcfytJgRQKRINLtueVxgOdnfPpg=
github.com/go-playground/errors/v5 v5.1.1 h1:H/igfatbYnCqa4Xednb1nnxljpPWnogA4TgsA4U891I= github.com/go-playground/errors/v5 v5.2.3/go.mod h1:DincxRGwraWmq39TZDqtnOtHGOJ+AbNbO0OmBzX6MLw=
github.com/go-playground/errors/v5 v5.1.1/go.mod h1:xyrVVz3LrfHZQmZQ1ri/8rdiis2F96q15wGX89xWsL0=
github.com/go-playground/form/v4 v4.0.0/go.mod h1:bodWfd97U9PVMZFcDsbVzSbQQTtaWrebnTwQtWjSW1M=
github.com/go-playground/form/v4 v4.1.1/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U= github.com/go-playground/form/v4 v4.1.1/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U=
github.com/go-playground/log/v7 v7.0.2 h1:jHdecwWiVlQsOr9CKnAy1yjlwMTXITwUB2Tb3jVUrfU= github.com/go-playground/form/v4 v4.2.0/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U=
github.com/go-playground/log/v7 v7.0.2/go.mod h1:AWMsaRSXCVhwbCSvvchHqQfyREAODmWrX435KTjpuYU= github.com/go-playground/log/v8 v8.0.1 h1:yclpYIMZ49kTwtRZsmFlPRr/mmgBrRAXzC7FcZn9jmM=
github.com/go-playground/pkg/v4 v4.0.0 h1:0lTr9H8RyCwom4TcfNhMCNvlTlFuin7uUlXcZQuxrA4= github.com/go-playground/log/v8 v8.0.1/go.mod h1:G6XdEdQBItRKCi6XtQ2CMSkyP81AScSQEnNqKzknaT4=
github.com/go-playground/pkg/v4 v4.0.0/go.mod h1:TLowM3d3a/m04JlHK/zM6Ia8zf8+0C/9pTwhDEUqKO0=
github.com/go-playground/pkg/v5 v5.0.0/go.mod h1:0380E0lsFB1POWFypOLL8tX2f0O1OBCBpSdVmEy4mg0= github.com/go-playground/pkg/v5 v5.0.0/go.mod h1:0380E0lsFB1POWFypOLL8tX2f0O1OBCBpSdVmEy4mg0=
github.com/go-playground/pkg/v5 v5.3.0 h1:G+DOJRqMoQTpnSGEjc1rWat6pE4EKp7ejM3udkjCi78= github.com/go-playground/pkg/v5 v5.6.0 h1:97YpRFzIcS5NFP2Uzxj8cPYz4zTuwweyXADYcA1KfUQ=
github.com/go-playground/pkg/v5 v5.3.0/go.mod h1:HXedFsSf7dogjVi5wmbOK7P+doyvzvLYMNlyX+PfGZI= github.com/go-playground/pkg/v5 v5.6.0/go.mod h1:TvZ2nNtNh6VfoNteY9ApA2BXt1ZwJliFZ4hzPAwLS9Y=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -40,7 +32,6 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -48,31 +39,23 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/schollz/progressbar/v3 v3.8.3 h1:FnLGl3ewlDUP+YdSwveXBaXs053Mem/du+wr7XSYKl8= github.com/schollz/progressbar/v3 v3.8.3 h1:FnLGl3ewlDUP+YdSwveXBaXs053Mem/du+wr7XSYKl8=
github.com/schollz/progressbar/v3 v3.8.3/go.mod h1:pWnVCjSBZsT2X3nx9HfRdnCDrpbevliMeoEVhStwHko= github.com/schollz/progressbar/v3 v3.8.3/go.mod h1:pWnVCjSBZsT2X3nx9HfRdnCDrpbevliMeoEVhStwHko=
github.com/segmentio/errors-go v1.0.0/go.mod h1:RDVEREUrpa4/jM8rt5KsQpu+JoXPi6i07vG7m4tX0MY=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210223212115-eede4237b368/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -80,16 +63,16 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+R
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 h1:CBpWXWQpIRjzmkkA+M7q9Fqnwd2mZr3AFqexg8YTfoM=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

18
main.go
View File

@@ -1,14 +1,14 @@
// Copyright 2021 Torsten Harenberg DL1THM. All rights reserved. // Copyright 2021 Torsten Harenberg DL1THM. All rights reserved.
// A SCS PACTOR modem flashing utility written in Go. Should run anywhere Go runs. // A SCS PACTOR modem flashing utility written in Go. Should run everywhere Go runs.
package main package main
import ( import (
"bytes"
"fmt" "fmt"
"github.com/akamensky/argparse" "github.com/akamensky/argparse"
"github.com/go-playground/log/v7" "github.com/go-playground/log/v8"
"github.com/go-playground/log/v7/handlers/console"
"go-scsupdate/firmware" "go-scsupdate/firmware"
"go-scsupdate/update" "go-scsupdate/update"
"go-scsupdate/usb" "go-scsupdate/usb"
@@ -24,9 +24,9 @@ func main() {
debug := parser.Flag("d", "debug", &argparse.Options{Required: false, Help: "(optional) enable debug logs"}) 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"}) 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 the modem. Useful if the modem is bricked and you need to put it into BIOS mode. Read the manual!"}) force := parser.Flag("", "force", &argparse.Options{Required: false, Help: "(optional) skip testing if firmware fits the 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) err := parser.Parse(os.Args)
cLog := console.New(true) buff := new(bytes.Buffer)
cLog := log.NewConsoleBuilder().WithWriter(buff).Build()
if *debug { if *debug {
log.AddHandler(cLog, log.AllLevels...) log.AddHandler(cLog, log.AllLevels...)
log.Debug("DEBUG logging enabled") log.Debug("DEBUG logging enabled")
@@ -34,10 +34,6 @@ func main() {
log.AddHandler(cLog, log.InfoLevel, log.ErrorLevel, log.AlertLevel, log.WarnLevel, log.NoticeLevel, log.PanicLevel) 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 { if *serialDevice != "" && *brate == 0 {
log.Fatal("ERROR: if you specify a device, you need to specify a baud rate as well. Cannot continue") log.Fatal("ERROR: if you specify a device, you need to specify a baud rate as well. Cannot continue")
} }
@@ -90,9 +86,9 @@ func main() {
if *dryrun != true { if *dryrun != true {
var err error var err error
if *serialDevice != "" { if *serialDevice != "" {
err = update.Update(*serialDevice, baudrate, *sertimeout, *f, *force) err = update.Update(*serialDevice, baudrate, *f, *force)
} else { } else {
err = update.Update(ports[0].Port, baudrate, *sertimeout, *f, *force) err = update.Update(ports[0].Port, baudrate, *f, *force)
} }
if err != nil { if err != nil {
log.Panic(err) log.Panic(err)

View File

@@ -6,7 +6,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/albenik/go-serial/v2" "github.com/albenik/go-serial/v2"
"github.com/go-playground/log/v7" "github.com/go-playground/log/v8"
"github.com/schollz/progressbar/v3" "github.com/schollz/progressbar/v3"
"io/ioutil" "io/ioutil"
"os" "os"
@@ -25,14 +25,14 @@ type modem struct {
} }
// initmodem: opens the serial line, returns instance of serial.Port // initmodem: opens the serial line, returns instance of serial.Port
func initmodem(serport string, baudrate int, sertimeout int) (*modem, error) { func initmodem(serport string, baudrate int) (*modem, error) {
p, err := serial.Open(serport, p, err := serial.Open(serport,
serial.WithBaudrate(baudrate), serial.WithBaudrate(baudrate),
serial.WithDataBits(8), serial.WithDataBits(8),
serial.WithParity(serial.NoParity), serial.WithParity(serial.NoParity),
serial.WithStopBits(serial.OneStopBit), serial.WithStopBits(serial.OneStopBit),
serial.WithReadTimeout(sertimeout), serial.WithReadTimeout(-1), //blocking I/O, see https://pkg.go.dev/github.com/albenik/go-serial#Port
serial.WithWriteTimeout(sertimeout)) serial.WithWriteTimeout(-1)) //blocking I/O
if err != nil { if err != nil {
fmt.Printf("ERROR: File %s could not be opened\n", serport) fmt.Printf("ERROR: File %s could not be opened\n", serport)
return nil, err return nil, err
@@ -41,9 +41,10 @@ func initmodem(serport string, baudrate int, sertimeout int) (*modem, error) {
return m, nil return m, nil
} }
// write: writes to the serial ports, returns answer and logs output // write: writes to the serial ports, returns answer and logs output. Optional toread forces a
func (m *modem) write(out string, nolog ...bool) ([]byte, error) { // certain number of bytes to read
if len(nolog) == 0 { func (m *modem) write(out string, toread ...uint32) ([]byte, error) {
if len(toread) == 0 {
log.Debug("Sending " + strings.TrimFunc(out, func(r rune) bool { log.Debug("Sending " + strings.TrimFunc(out, func(r rune) bool {
return !unicode.IsGraphic(r) return !unicode.IsGraphic(r)
})) }))
@@ -52,18 +53,37 @@ func (m *modem) write(out string, nolog ...bool) ([]byte, error) {
log.Debugf("Sending %d byte(s)", len(out)) log.Debugf("Sending %d byte(s)", len(out))
} }
} }
_, err := m.port.Write([]byte(out)) for {
status, err := m.port.GetModemStatusBits()
if err != nil { if err != nil {
log.Errorf("ERROR while sending serial command: %s\n", out) log.Fatal("GetModemStatusBits failed")
log.Error(err)
return []byte(""), err
} }
buff := make([]byte, 1024) if status.CTS {
if len(nolog) == 0 { for {
time.Sleep(50 * time.Millisecond) // give the PTC some time to answer, no needed with binary sent, err := m.port.Write([]byte(out))
if err == nil {
break
} else {
// log.Errorf("ERROR while sending serial command: %s\n", out)
log.Debug(err)
out = out[sent:]
} }
}
break
}
}
var btr uint32
if len(toread) == 0 {
time.Sleep(80 * time.Millisecond) // give the PTC some time to answer, no needed with binary
btr, _ = m.port.ReadyToRead()
if btr == 0 {
return []byte(""), nil
}
} else {
btr = toread[0]
}
buff := make([]byte, btr)
n, err := m.port.Read(buff) n, err := m.port.Read(buff)
// fmt.Printf("Read %d bytes\n", n)
if err != nil { if err != nil {
log.Errorf("ERROR: cannot read answer from command: %s\n", out) log.Errorf("ERROR: cannot read answer from command: %s\n", out)
return []byte(""), err return []byte(""), err
@@ -103,27 +123,29 @@ func (m *modem) setDateTime() error {
// writeUpdate: main flash utility. Writes the firmware taken from fwfile to the modem. Write progress bar. // writeUpdate: main flash utility. Writes the firmware taken from fwfile to the modem. Write progress bar.
func (m *modem) writeUpdate(fwfile string) error { func (m *modem) writeUpdate(fwfile string) error {
m.port.SetWriteTimeout(-50)
m.port.SetReadTimeout(-1)
_, err := m.write("UPDATE\r") _, err := m.write("UPDATE\r")
if err != nil { if err != nil {
_, _ = m.write("\033", true) // send ESC to cancel the update _, _ = m.write("\033") // send ESC to cancel the update
return err return err
} }
answer, err := m.write("\006", true) answer, err := m.write("\006")
if err != nil { if err != nil {
_, _ = m.write("\033", true) // send ESC to cancel the update fmt.Println(err)
_, _ = m.write("\033") // send ESC to cancel the update
return err return err
} }
log.Debugf("flash stamp: % X", binary.LittleEndian.Uint32(answer[2:6])) log.Debugf("flash stamp: % X", binary.LittleEndian.Uint32(answer[2:6]))
flashId := binary.LittleEndian.Uint16(answer[0:2]) flashId := binary.LittleEndian.Uint16(answer[0:2])
log.Debugf("flash id: % X", flashId) log.Debugf("flash id: % X", flashId)
if flashId != 0xa41f && flashId != 0x5b1f && flashId != 0xda1f { if flashId != 0xa41f && flashId != 0x5b1f && flashId != 0xda1f {
_, _ = m.write("\033", true) // send ESC to cancel the update _, _ = m.write("\033") // send ESC to cancel the update
return errors.New("wrong flash id") return errors.New("wrong flash id")
} }
r, err := os.Open(fwfile) r, err := os.Open(fwfile)
if err != nil { if err != nil {
_, _ = m.write("\033", true) // send ESC to cancel the update _, _ = m.write("\033") // send ESC to cancel the update
return err return err
} }
fstat, _ := r.Stat() fstat, _ := r.Stat()
@@ -132,7 +154,7 @@ func (m *modem) writeUpdate(fwfile string) error {
fwblob, err := ioutil.ReadFile(fwfile) fwblob, err := ioutil.ReadFile(fwfile)
if err != nil { if err != nil {
_, _ = m.write("\033", true) // send ESC to cancel the update _, _ = m.write("\033") // send ESC to cancel the update
return err return err
} }
// fmt.Println(fsize) // fmt.Println(fsize)
@@ -140,20 +162,20 @@ func (m *modem) writeUpdate(fwfile string) error {
if fsize%256 != 0 { if fsize%256 != 0 {
chunks++ chunks++
} }
// send ACK // send ACK
_, err = m.write("\006", true) _, err = m.write("\006")
if err != nil { if err != nil {
_, _ = m.write("\033", true) // send ESC to cancel the update _, _ = m.write("\033") // send ESC to cancel the update
return err return err
} }
// send number of chunks // send number of chunks
a := make([]byte, 2) a := make([]byte, 2)
binary.BigEndian.PutUint16(a, chunks) binary.BigEndian.PutUint16(a, chunks)
res, err := m.write(string(a), true) res, err := m.write(string(a))
if err != nil || string(res) != "\006" { //no ACK if err != nil || string(res) != "\006" { //no ACK
_, _ = m.write("\033", true) // send ESC to cancel the update fmt.Println("kein ACK")
_, _ = m.write("\033") // send ESC to cancel the update
return err return err
} }
@@ -168,15 +190,15 @@ func (m *modem) writeUpdate(fwfile string) error {
} else { } else {
sendbuff = string(fwblob[i*CHUNKSIZE : i*CHUNKSIZE+CHUNKSIZE]) sendbuff = string(fwblob[i*CHUNKSIZE : i*CHUNKSIZE+CHUNKSIZE])
} }
res, err = m.write(sendbuff, true) res, err = m.write(sendbuff, 1)
if err != nil || string(res) != "\006" { //no ACK if err != nil || string(res) != "\006" { //no ACK
_, _ = m.write("\033", true) // send ESC to cancel the update
log.Errorf("Error in Handshake! Rx: %s", hex.EncodeToString(res)) log.Errorf("Error in Handshake! Rx: %s", hex.EncodeToString(res))
_, _ = m.write("\033") // send ESC to cancel the update
return err return err
} }
} }
log.Infof("Firmware file %s successfully written", fwfile) log.Infof("Firmware file %s successfully written", fwfile)
_, err = m.write("\r", true) _, err = m.write("\r")
if err != nil { if err != nil {
log.Error("Error in Handshake: cannot send final cr") log.Error("Error in Handshake: cannot send final cr")
} }
@@ -226,8 +248,8 @@ func (m *modem) checkFirmwareFits(fwfile string) error {
} }
// Update: main firmware update utility. Runs pre-checks and calls main flashing function writeUpdate // Update: main firmware update utility. Runs pre-checks and calls main flashing function writeUpdate
func Update(serport string, baudrate int, sertimeout int, fwfile string, force bool) error { func Update(serport string, baudrate int, fwfile string, force bool) error {
m, err := initmodem(serport, baudrate, sertimeout) m, err := initmodem(serport, baudrate)
defer m.port.Close() defer m.port.Close()
if err != nil { if err != nil {
return errors.New("FEHLER in Update") return errors.New("FEHLER in Update")

View File

@@ -3,7 +3,7 @@ package usb
import ( import (
"errors" "errors"
enumerator2 "github.com/albenik/go-serial/v2/enumerator" enumerator2 "github.com/albenik/go-serial/v2/enumerator"
"github.com/go-playground/log/v7" "github.com/go-playground/log/v8"
) )
/* /*