diff --git a/.gitignore b/.gitignore index cdd066e..f893e4b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,6 @@ dist *.exe *.zip *.bak +*.rar build/ diff --git a/FyneApp.toml b/FyneApp.toml index 6a89a25..e899de5 100644 --- a/FyneApp.toml +++ b/FyneApp.toml @@ -4,5 +4,5 @@ Website = "https://hirschmann-koxha.de/" Icon = "assets/Icon.png" Name = "Saab CIM Tool" ID = "com.eep.tool" - Version = "2.0.12" - Build = 1 + Version = "2.0.13" + Build = 4 diff --git a/avr/firmware.hex b/avr/firmware.hex index 4747460..e3bbacf 100644 --- a/avr/firmware.hex +++ b/avr/firmware.hex @@ -400,7 +400,7 @@ :1018EE006E002C0007696E76616C69642073697AEC :1018FE00650007696E76616C6964206368697000C3 :10190E0007696E76616C6964206F72670076322E9D -:10191E00302E31320A002D2D2D2073657474696EB0 +:10191E00302E31330A002D2D2D2073657474696EAF :10192E006773202D2D2D00636869703A200073694E :10193E007A653A20006F72673A200064656C6179AF :10194E003A2000696E76616C696420636F6D6D611B diff --git a/firmware/.vscode/arduino.json b/firmware/.vscode/arduino.json index 6567896..d4a3cb0 100644 --- a/firmware/.vscode/arduino.json +++ b/firmware/.vscode/arduino.json @@ -1,7 +1,7 @@ { "sketch": "firmware.ino", "board": "arduino:avr:uno", - "port": "COM3", + "port": "COM10", "output": "./build", "programmer": "arduino:avrisp" } \ No newline at end of file diff --git a/firmware/firmware.ino b/firmware/firmware.ino index f00f619..8c719a5 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -8,7 +8,7 @@ #define DO_PIN 12 #define ORG_PIN 8 -#define WIRE_VERSION "v2.0.12\n" +#define WIRE_VERSION "v2.0.13\n" M93Cx6 ep = M93Cx6(PWR_PIN, CS_PIN, SK_PIN, DO_PIN, DI_PIN, ORG_PIN, 150); diff --git a/go.mod b/go.mod index b4faa4b..3ed68fe 100644 --- a/go.mod +++ b/go.mod @@ -13,28 +13,14 @@ require ( require ( github.com/benoitkugler/textlayout v0.2.1 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/gin-gonic/gin v1.7.7 // indirect - github.com/go-playground/locales v0.13.0 // indirect - github.com/go-playground/universal-translator v0.17.0 // indirect - github.com/go-playground/validator/v10 v10.4.1 // indirect github.com/go-text/typesetting v0.0.0-20221129122707-b081989d8c45 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/json-iterator/go v1.1.12 // indirect github.com/kr/pretty v0.3.0 // indirect - github.com/leodido/go-urn v1.2.0 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect github.com/rogpeppe/go-internal v1.8.0 // indirect - github.com/ugorji/go/codec v1.1.7 // indirect - golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect - google.golang.org/protobuf v1.27.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) require ( github.com/TheTitanrain/w32 v0.0.0-20200114052255-2654d97dbd3d // indirect - github.com/albenik/bcd v0.0.0-20170831201648-635201416bc7 // indirect github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/ghostiam/binstruct v1.3.2 // indirect github.com/go-openapi/errors v0.20.3 // indirect diff --git a/go.sum b/go.sum index e64a1b1..6e69b41 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,6 @@ github.com/TheTitanrain/w32 v0.0.0-20200114052255-2654d97dbd3d/go.mod h1:peYoMnc github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM= github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= -github.com/albenik/bcd v0.0.0-20170831201648-635201416bc7 h1:m3Ayfs5OcAlIMEdLIQKubBsVLGee4YMUr14+d1256WE= -github.com/albenik/bcd v0.0.0-20170831201648-635201416bc7/go.mod h1:QIAMbrwsnQZ2ES3G26RubSrDB5SPyzsp9Hts5NJdTrI= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -159,10 +157,6 @@ github.com/fyne-io/image v0.0.0-20221020213044-f609c6a24345/go.mod h1:eO7W361vml github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghostiam/binstruct v1.3.2 h1:ODI6PEOYDrfLmJnTuORj6oNh+TZ5KnIt2nqqV+Z4/MA= github.com/ghostiam/binstruct v1.3.2/go.mod h1:4xldhq82h6CxIBFSARyUs4Yoi8P/Mj24rkxyaGyZLJ4= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= -github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -181,13 +175,6 @@ github.com/go-openapi/errors v0.20.3 h1:rz6kiC84sqNQoqrtulzaL/VERgkoCyB6WdEkc2uj github.com/go-openapi/errors v0.20.3/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= github.com/go-openapi/strfmt v0.21.3 h1:xwhj5X6CjXEZZHMWy1zKJxvW9AfHC9pkyUjLvHtKG7o= github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-text/typesetting v0.0.0-20221129122707-b081989d8c45 h1:U8LDBBo6EfHVZW8uh4dNAhEOKDbBuJRon4QOI18dR5c= github.com/go-text/typesetting v0.0.0-20221129122707-b081989d8c45/go.mod h1:kssHQBiSa7hcHEW4iDHI8JnhXB87V5kDmLtnk9Ccx/A= @@ -228,7 +215,6 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -318,10 +304,6 @@ github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= -github.com/hirschmann-koxha-gbr/cim v0.2.10 h1:eQ/R8J/YB0wy6ENnF7xEKZxhme1x5cP3M3XurnBNVjk= -github.com/hirschmann-koxha-gbr/cim v0.2.10/go.mod h1:g1u4jUrL6HMjVuEYzPxCj62nFr/rhltzQOj8MPPFYw4= -github.com/hirschmann-koxha-gbr/cim v0.3.0 h1:yJTLv+TjGWvOP+2SaGwuTSp2ivnch5V2kV1H0/7+yS4= -github.com/hirschmann-koxha-gbr/cim v0.3.0/go.mod h1:21fRVcF32QbjxeQrIxhfOw+kPqkAYwdiKUWGgTTl9p4= github.com/hirschmann-koxha-gbr/cim v0.3.1 h1:/CssyX0Uzu5kOz35HZMoZKhcnHpMDhwkrArnMij5kjI= github.com/hirschmann-koxha-gbr/cim v0.3.1/go.mod h1:21fRVcF32QbjxeQrIxhfOw+kPqkAYwdiKUWGgTTl9p4= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= @@ -336,7 +318,6 @@ github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= @@ -359,8 +340,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lucor/goinfo v0.0.0-20210802170112-c078a2b0f08b/go.mod h1:PRq09yoB+Q2OJReAmwzKivcYyremnibWGbK7WfftHzc= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= @@ -402,11 +381,9 @@ github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -506,9 +483,6 @@ github.com/tevino/abool v1.2.0/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K0 github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= @@ -557,7 +531,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/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-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -983,7 +956,6 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/gui/gui.go b/gui/gui.go index e0352e2..07b6068 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -10,7 +10,7 @@ import ( "golang.org/x/mod/semver" ) -const VERSION = "v2.0.12" +const VERSION = "v2.0.13" type EEPGui struct { port string diff --git a/gui/serial.go b/gui/serial.go index 2f64d08..c668bf1 100644 --- a/gui/serial.go +++ b/gui/serial.go @@ -36,15 +36,20 @@ func (m *mainWindow) writeCIM(port string, data []byte) error { return fmt.Errorf("Failed to load CIM: %w", err) //lint:ignore ST1005 ignore } + xorBytes, err := input.XORBytes() + if err != nil { + return fmt.Errorf("Failed to XOR CIM: %w", err) //lint:ignore ST1005 ignore + } + client := m.newAdapter() if err := client.Open(m.e.port, VERSION); err != nil { return fmt.Errorf("Failed to init adapter: %w", err) //lint:ignore ST1005 ignore } defer client.Close() - m.progressBar.Max = float64(len(data)) + m.progressBar.Max = float64(len(xorBytes)) - if err := client.WriteCIM(data); err != nil { + if err := client.WriteCIM(xorBytes); err != nil { return fmt.Errorf("Failed to write CIM: %w", err) //lint:ignore ST1005 ignore } diff --git a/gui/viewerWindow.go b/gui/viewerWindow.go index 25dde24..3b48447 100644 --- a/gui/viewerWindow.go +++ b/gui/viewerWindow.go @@ -180,17 +180,14 @@ func (vw *viewerWindow) newToolbar() *widget.Toolbar { func (vw *viewerWindow) layout() fyne.CanvasObject { vw.toolbar = vw.newToolbar() - vw.infoTab = container.NewTabItemWithIcon("Info", theme.InfoIcon(), vw.renderInfoTab()) - - vw.versionTab = container.NewTabItemWithIcon("Versions", theme.QuestionIcon(), container.NewVBox( - kv(vw, "End model (HW+SW)", "%d%s", vw.cimBin.PartNo1, vw.cimBin.PartNo1Rev), - kv(vw, "Base model (HW+boot)", "%d%s", vw.cimBin.PnBase1, vw.cimBin.PnBase1Rev), - kv(vw, "Delphi part number", "%d", vw.cimBin.DelphiPN), - kv(vw, "SAAB part number", "%d", vw.cimBin.PartNo), - kv(vw, "Configuration Version", "%d", vw.cimBin.ConfigurationVersion), + vw.versionTab = container.NewTabItemWithIcon("Versions", theme.QuestionIcon(), widget.NewForm( + widget.NewFormItem("End model (HW+SW)", widget.NewLabel(fmt.Sprintf("%d%s", vw.cimBin.PartNo1, vw.cimBin.PartNo1Rev))), + widget.NewFormItem("Base model (HW+boot)", widget.NewLabel(fmt.Sprintf("%d%s", vw.cimBin.PnBase1, vw.cimBin.PnBase1Rev))), + widget.NewFormItem("Delphi part number", widget.NewLabel(fmt.Sprintf("%d", vw.cimBin.DelphiPN))), + widget.NewFormItem("SAAB part number", widget.NewLabel(fmt.Sprintf("%d", vw.cimBin.PartNo))), + widget.NewFormItem("Configuration Version", widget.NewLabel(fmt.Sprintf("%d", vw.cimBin.ConfigurationVersion))), )) - vw.keyList = &widget.List{ Length: func() int { return int(vw.cimBin.Keys.Count1) @@ -213,7 +210,6 @@ func (vw *viewerWindow) layout() fyne.CanvasObject { c.Objects[2].(*widget.Label).SetText(vw.cimBin.Keys.Data1[item].Type()) c.Objects[3].(*widget.Label).SetText(fmt.Sprintf("%02X", vw.cimBin.Keys.Data1[item].Value)) c.Objects[5].(*widget.Button).OnTapped = func() { - //vw.SetContent(newKeyView(vw.e, vw, item, vw.cimBin)) dialog.ShowCustom("Edit key", "OK", newKeyView(vw.e, vw, item, vw.cimBin), vw) } obj.(*fyne.Container).Objects[6].(*widget.Button).OnTapped = func() { @@ -264,7 +260,6 @@ func hexValidator(length int) func(s string) error { } func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { - vButton := widget.NewButtonWithIcon("Virginize", theme.SearchReplaceIcon(), func() { vw.cimBin.Unmarry() vw.SetContent(vw.layout()) @@ -274,9 +269,8 @@ func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { }) iskEntry := &widget.Entry{ - Text: fmt.Sprintf("%X%X", vw.cimBin.Keys.IskHI1, vw.cimBin.Keys.IskLO1), - Wrapping: fyne.TextWrapOff, - //TextStyle: fyne.TextStyle{Monospace: true}, + Text: fmt.Sprintf("%X%X", vw.cimBin.Keys.IskHI1, vw.cimBin.Keys.IskLO1), + Wrapping: fyne.TextWrapOff, Validator: hexValidator(12), } iskEntry.OnChanged = func(s string) { @@ -296,9 +290,8 @@ func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { } pskEntry := &widget.Entry{ - Text: fmt.Sprintf("%X%X", vw.cimBin.PSK.High, vw.cimBin.PSK.Low), - Wrapping: fyne.TextWrapOff, - //TextStyle: fyne.TextStyle{Monospace: true}, + Text: fmt.Sprintf("%X%X", vw.cimBin.PSK.High, vw.cimBin.PSK.Low), + Wrapping: fyne.TextWrapOff, Validator: hexValidator(12), } pskEntry.OnChanged = func(s string) { @@ -306,13 +299,11 @@ func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { pskEntry.SetText(s[:12]) } if len(s) == 12 { - decoded, err := hex.DecodeString(s) if err != nil { dialog.ShowError(err, vw) return } - if err := vw.cimBin.PSK.SetHigh(decoded[:4]); err != nil { dialog.ShowError(err, vw) return @@ -324,9 +315,7 @@ func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { } } - vinEntry := &widget.Entry{ - Text: vw.cimBin.Vin.Data, - } + vinEntry := &widget.Entry{Text: vw.cimBin.Vin.Data} vinEntry.OnChanged = func(s string) { if len(s) > 17 { vinEntry.SetText(s[:17]) @@ -344,14 +333,9 @@ func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { pin = "not set" } - pinEntry := &widget.Entry{ - Text: pin, - } - - pinHex := &widget.Label{ - Text: fmt.Sprintf("%X", vw.cimBin.Pin.Data1), - } + pinHex := &widget.Label{Text: fmt.Sprintf("%X", vw.cimBin.Pin.Data1)} + pinEntry := &widget.Entry{Text: pin} pinEntry.OnChanged = func(s string) { if len(s) > 4 { pinEntry.SetText(s[:4]) @@ -377,61 +361,23 @@ func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { }(), } - /* - left := container.NewVBox( - kv(vw, "MD5 ", "%s", vw.cimBin.MD5()), - kv(vw, "CRC32", "%s", vw.cimBin.CRC32()), - kv(vw, "Size ", "%d", len(vw.data)), - - layout.NewSpacer(), - - container.NewHBox( - container.NewHBox( - newBoldEntry("VIN :"), - //widget.NewLabelWithStyle(vinEntry.Text, fyne.TextAlignLeading, fyne.TextStyle{}), - container.NewBorder(nil, nil, nil, nil, vinEntry), - ), - container.NewHBox( - widget.NewLabelWithStyle("MY:", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}), - widget.NewLabelWithStyle(vw.cimBin.ModelYear(), fyne.TextAlignLeading, fyne.TextStyle{}), - ), - layout.NewSpacer(), - widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() { - vw.e.mw.Clipboard().SetContent(vw.cimBin.Vin.Data) - }), - ), - - kv(vw, "PIN ", "%s", pin), - kv(vw, "PIN (hex)", "%X", vw.cimBin.Pin.Data1), - - layout.NewSpacer(), + snstickerEntry := &widget.Entry{Text: fmt.Sprintf("%X", vw.cimBin.SnSticker)} + snstickerEntry.OnChanged = func(s string) { + if len(s) > 10 { + snstickerEntry.SetText(s[:10]) + return + } + if len(s) == 10 { + b, err := hex.DecodeString(s) + if err != nil { + dialog.ShowError(err, vw) + return + } + vw.cimBin.SnSticker = b + } + } - container.NewHBox( - newBoldEntry("SAS :"), - sasSelect, - ), - container.NewHBox( - newBoldEntry("ISK :"), - container.NewBorder(nil, nil, nil, nil, iskEntry), - layout.NewSpacer(), - widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() { - vw.e.mw.Clipboard().SetContent(iskEntry.Text) - }), - ), - container.NewHBox( - newBoldEntry("PSK :"), - container.NewBorder(nil, nil, nil, nil, pskEntry), - layout.NewSpacer(), - widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() { - vw.Clipboard().SetContent(iskEntry.Text) - }), - ), - layout.NewSpacer(), - vButton, - ) - */ form := widget.NewForm( - widget.NewFormItem("MD5", container.NewHBox( widget.NewLabel(vw.cimBin.MD5()), layout.NewSpacer(), @@ -446,8 +392,15 @@ func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { vw.Clipboard().SetContent(vw.cimBin.CRC32()) }), )), - widget.NewFormItem("Size", widget.NewLabel(fmt.Sprintf("%d", len(vw.data)))), - + widget.NewFormItem("S/N Sticker", container.NewHBox( + container.NewHBox( + snstickerEntry, + ), + layout.NewSpacer(), + widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() { + vw.Clipboard().SetContent(vinEntry.Text) + }), + )), widget.NewFormItem("VIN", container.NewHBox( container.NewHBox( vinEntry, @@ -458,32 +411,29 @@ func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { ), layout.NewSpacer(), widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() { - vw.e.mw.Clipboard().SetContent(vinEntry.Text) + vw.Clipboard().SetContent(vinEntry.Text) }), )), - widget.NewFormItem("PIN", container.NewHBox( pinEntry, layout.NewSpacer(), widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() { - vw.e.mw.Clipboard().SetContent(pinEntry.Text) + vw.Clipboard().SetContent(pinEntry.Text) }), )), - widget.NewFormItem("PIN (hex)", container.NewHBox( pinHex, layout.NewSpacer(), widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() { - vw.e.mw.Clipboard().SetContent(fmt.Sprintf("%X", pinHex.Text)) + vw.Clipboard().SetContent(fmt.Sprintf("%X", pinHex.Text)) }), )), - widget.NewFormItem("SAS", sasSelect), widget.NewFormItem("ISK", container.NewHBox( iskEntry, layout.NewSpacer(), widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() { - vw.e.mw.Clipboard().SetContent(iskEntry.Text) + vw.Clipboard().SetContent(iskEntry.Text) }), )), widget.NewFormItem("PSK", container.NewHBox( @@ -494,13 +444,5 @@ func (vw *viewerWindow) renderInfoTab() fyne.CanvasObject { }), )), ) - - //right := container.NewVBox( - // - // layout.NewSpacer(), - //) - - // return container.NewGridWithColumns(2, left, right) return container.NewBorder(nil, vButton, nil, nil, form) - }