Search found 5956 matches

by pythoncoder
Mon Jul 18, 2022 12:37 pm
Forum: General Discussion and Questions
Topic: Using local time with Pico W
Replies: 17
Views: 52462

Re: Using local time with Pico W

Here is a version of ntptime.py which is platform-independent. Tested on Unix, ESP8266, Pico W. It also allows for a local time offset. Hopefully it will be of use to someone ;) import socket import struct from time import gmtime # (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60 # (date(1970, ...
by pythoncoder
Sun Jul 17, 2022 3:41 pm
Forum: General Discussion and Questions
Topic: asyncio.open_connection no exception
Replies: 3
Views: 1420

Re: asyncio.open_connection no exception

The plot thickens.

Your code works on Pico W and Pyboard D.

It does not on ESP32 and ESP8266. I suggest you raise an issue.
by pythoncoder
Sun Jul 17, 2022 3:30 pm
Forum: General Discussion and Questions
Topic: asyncio.open_connection no exception
Replies: 3
Views: 1420

Re: asyncio.open_connection no exception

I'm puzzled. Firstly, if I run your code on a Pico W it returns False: === import uasyncio as asyncio === === # Returns True if port available === async def isPortOpen(ip, port): === try: === print('Testing:', ip, port) === reader, writer = await asyncio.open_connection(ip, port) === print(reader, w...
by pythoncoder
Sun Jul 17, 2022 3:23 pm
Forum: General Discussion and Questions
Topic: I cannot find upip
Replies: 3
Views: 2496

Re: I cannot find upip

I don't know why it isn't installed by default, but it can be found here. You need to copy upip.py and upip_utarfile.py to your filesystem.
by pythoncoder
Sun Jul 17, 2022 3:19 pm
Forum: General Discussion and Questions
Topic: Using local time with Pico W
Replies: 17
Views: 52462

Re: Using local time with Pico W

... @pythoncoder: I might be wrong, but calculating the difference between 1.1.2000 - 1.1.1970 using LibreOffice Calc returns here 946702080 seconds. And using your code causes an overflow error. Probably you mean: time.localtime(ntptime.time() - 946684800) I realised in the early hours of this mor...
by pythoncoder
Sat Jul 16, 2022 12:43 pm
Forum: General Discussion and Questions
Topic: Using local time with Pico W
Replies: 17
Views: 52462

Re: Using local time with Pico W

Firstly MicroPython doesn't support timezones. However you can get UTC and convert it to local time yourself. Copy ntptime.py to the Pico W filesystem and use it as follows: >>> time.localtime(ntptime.time() + 946702080) (2022, 7, 16, 17, 25, 50, 5, 197) Note the factor 946702080 which is 30 year's ...
by pythoncoder
Fri Jul 15, 2022 11:04 am
Forum: General Discussion and Questions
Topic: General Question
Replies: 16
Views: 4623

Re: General Question

...Oh, yes, the designer thought they were clever and mis-wired the ROM to jumble-up the bits. In other words, instead of wiring bits 0-7 to the corresponding pins on the ROM chip, they wired 5 to 2, 7 to 0, etc. An attempt to make the disassembled code meaningless... He made your life too easy. He...
by pythoncoder
Thu Jul 14, 2022 12:23 pm
Forum: Raspberry Pi microcontroller boards
Topic: Gremlins
Replies: 2
Views: 1774

Re: Gremlins

It's a big ask wanting us to trawl through all that code. I suggest you read https://www.tutorialspoint.com/What-are-Python-dictionary-view-objects. These objects are not subscriptable, but you can cast them to lists or tuples: >>> d = {1:'one', 2:'two'} >>> dv = d.values() >>> dv[0] Traceback (most...
by pythoncoder
Tue Jul 12, 2022 4:28 pm
Forum: General Discussion and Questions
Topic: @micropython.native not implemented too long
Replies: 14
Views: 5375

Re: @micropython.native not implemented too long

Interesting. As a matter of interest do you use the second core?
by pythoncoder
Tue Jul 12, 2022 10:03 am
Forum: General Discussion and Questions
Topic: @micropython.native not implemented too long
Replies: 14
Views: 5375

Re: @micropython.native not implemented too long

I suggest you review your use of micropython.native . Like all optimisations it's best only to apply it where there is a true performance bottleneck. My approach is to identify which part of the code is causing the slowdown and optimise it until it sqeals. micropython.native rarely makes a large dif...