Skip to content
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

WLua: Handle LUA error with %Z date format on Windows #950

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

shancock884
Copy link
Contributor

I came across an error using the Wireshark dissector on Windows, with messages containing unix time in μs.

Lua Error: ...Data\Roaming\Wireshark\plugins\mavlink_ardupilotmega.lua:22: bad argument #1 to 'date' (invalid conversion specifier '%Z')
    [Expert Info (Error/Undecoded): Lua Error: ...Data\Roaming\Wireshark\plugins\mavlink_ardupilotmega.lua:22: bad argument #1 to 'date' (invalid conversion specifier '%Z')]
        [Lua Error: ...Data\Roaming\Wireshark\plugins\mavlink_ardupilotmega.lua:22: bad argument #1 to 'date' (invalid conversion specifier '%Z')]
        [Severity level: Error]
        [Group: Undecoded]

The %Z date formatter should give the timezone as a short name, but it is not working on Lua 5.2.4 on Windows - as currently used in Wireshark. It worked on Linux, and is already fixed in Lua 5.3.3 or later, which I believe Wireshark will switch to at some point.

I have added code to the generator to catch the error, and if it occurs will instead use "%z" - which gives timezone as an offset instead.
So Windows users will see something like:

Payload: SYSTEM_TIME (2)
    time_unix_usec (uint64_t) [us]: 1718704143118600 (2024-06-18 10:49:03.118600 +0100)
    time_boot_ms (uint32_t) [ms]: 29935

When Wireshark is updated to use a newer Lua, it will give something like this (as Linux users see already):

Payload: SYSTEM_TIME (2)
    time_unix_usec (uint64_t) [us]: 1718704143118600 (2024-06-18 10:49:03.118600 BST)
    time_boot_ms (uint32_t) [ms]: 29935

Tested on my Windows setup, and the error is gone, and output as shown.

@peterbarker
Copy link
Contributor

Why still draft?

@shancock884
Copy link
Contributor Author

Why still draft?

Not sure! I think I planned to re-read my wording with a cup of tea, but got distratced!

@shancock884 shancock884 marked this pull request as ready for review June 19, 2024 06:11
@peterbarker peterbarker merged commit 27eefbe into ArduPilot:master Jun 19, 2024
12 checks passed
@peterbarker
Copy link
Contributor

Merged, thanks!

@shancock884 shancock884 deleted the wslua-timezone-err branch June 20, 2024 05:51
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.

2 participants