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

index out of range errors :: Devices unresponsive #3

Open
askpatrickw opened this issue Jun 16, 2020 · 1 comment
Open

index out of range errors :: Devices unresponsive #3

askpatrickw opened this issue Jun 16, 2020 · 1 comment

Comments

@askpatrickw
Copy link

askpatrickw commented Jun 16, 2020

I was porting uPyEcho to latest MicroPython (June 2020-- 1.12_2 ) to run on the TinPICO.

As part of that, I had to change all the references to clock.gmtime() to clock.datetime() when composing the date_str. as gmtime() is not available on my MP port.

After this format_timetuple_and_zone was hitting index out of range errors and my devices were intermittently discoverable AND always unresponsive after they did work (On and Off).

I tracked that down to changing the timetuple[6] in the day of the week section to [timetuple[4].

This is the corrected function which worked for me.

def format_timetuple_and_zone(timetuple, zone):
    return "%s, %02d %s %04d %02d:%02d:%02d %s" % (
        ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][timetuple[4]],
        timetuple[2],
        [
            "Jan",
            "Feb",
            "Mar",
            "Apr",
            "May",
            "Jun",
            "Jul",
            "Aug",
            "Sep",
            "Oct",
            "Nov",
            "Dec",
        ][timetuple[1] - 1],
        timetuple[0],
        timetuple[3],
        timetuple[4],
        timetuple[5],
        zone,
    )

I don't know why this happened. I'm not sure if the time.gmtime() on your ports of MicroPython just has different looking tuples, if the timetuple changed in MicroPython or if this was always a bug. But for me on 1.12 on the TinyPICO this works.

I thought I'd share in case others hit this this as well.

Thanks!

@lemariva
Copy link
Owner

Thank you, I will check that and keep you informed.

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

No branches or pull requests

2 participants