Skip to content

Vestel: decode version as utf16 #21656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2025

Conversation

mfuchs1984
Copy link
Contributor

Die Version ist, wie man in #21644 sieht, als utf16 kodiert. Zudem enthält sie noch weitere Versionskomponenten, getrennt mit einem "-".

Der code kann hier gestestet werden: https://go.dev/play/p/918no4SI930

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mfuchs1984 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 126 to 131
utf16BytesToString := func(b []byte) string {
s, _ := unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM).NewDecoder().String(string(b))
return s
}

fw, _, _ := strings.Cut(strings.TrimPrefix(utf16BytesToString(bytes.TrimRight(b, "\x00")), "v"), "-")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also entweder auf die Funktionsdeklaration verzichten oder (vllt. besser) den ganzen Kram in eine neue Funktion verschieben?

Copy link
Contributor Author

@mfuchs1984 mfuchs1984 Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kommt von hier, ggf. in die helpers / utils?

utf16BytesToString := func(b []byte) string {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

charger/helper.go würde ich spontan sagen. Da ist auch schon bytesAsString() drin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also

utf16BytesAsString

@mfuchs1984
Copy link
Contributor Author

Mir fällt gerade auf, dass dieses encoding auch der Grund sein könnte, warum @DonRoberto1985 den RFID Tag, obwohl er richtig angezeigt wird, nicht erfolgreich verwenden konnte. Der hat in der spec den selben datentyp "String" wie die Firmware Version.

#20848

@premultiply
Copy link
Member

Jo, Strings in Modbus sind immer ein absolutes Ratespiel.
Sind es fortlaufende Bytes über die Wörter? Oder wird nur ein Byte je Wort genutzt? Welche Byte-Order? Null-terminiert? Welche Zeichenkodierung wird verwendet? UTF8, ASCII, UTF16?
Ist das für alle Register eines Geräts auch gleich?

Da kann man eigentlich nur raten und grundsätzlich verlieren.

@andig
Copy link
Member

andig commented Jun 6, 2025

Also wenn richtig angezeigt dann sollte er ja auch richtig dekodiert sein. Aber who knows.

@mfuchs1984
Copy link
Contributor Author

Der Versionsstring wird auch richtig angezeigt wenn man ihn printet, ein Stringvergleich schlägt aber fehl. Konvertiert man die Strings in Byte slices, sieht man wiede den Unterschied.

@mfuchs1984
Copy link
Contributor Author

Ich Bau das mal um. @DonRoberto1985, would you mind testing a nightly when it is ready?

@mfuchs1984 mfuchs1984 marked this pull request as draft June 6, 2025 14:35
@mfuchs1984
Copy link
Contributor Author

Bestätigung bzgl. RFID #21687 (reply in thread)

@mfuchs1984 mfuchs1984 force-pushed the fix/vestel_version_string branch from e6db7cc to 896b59e Compare June 6, 2025 19:02
@mfuchs1984 mfuchs1984 marked this pull request as ready for review June 6, 2025 19:06
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mfuchs1984 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@andig andig merged commit fdae6a7 into evcc-io:master Jun 6, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants