pycom / pycom-micropython-sigfox Goto Github PK
View Code? Open in Web Editor NEWA fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
License: MIT License
A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
License: MIT License
LOPY 1.7.9.b3.
if you run the below code, you will see that after many loops it will raise "memory error". To reproduce in fastest way set SLEEP= 0.5. Same result is with gc.enable().
import gc
import utime
from machine import Timer
class Object:
def __init__(self, count=0):
print ("Object INIT ", self)
self._timer = Timer.Alarm(self._timerCallback, 0.5, periodic=False)
def __del__(self):
print ("Object DEL ", self)
def _timerCallback(self, timer):
print("Timer finish " , self)
self._timer.cancel()
del self._timer
self._timer = None
print("Start memory %s" %(gc.mem_free()))
SLEEP = 1.5
gc.disable()
while True:
obj = Object(100)
utime.sleep(SLEEP)
gc.collect()
print("\t\tmemory %s" %(gc.mem_free()))
I was using WiPy 2.0
Firmware version
sysname='WiPy', nodename='WiPy', release='1.6.13.b1', version='v1.8.6-607-g9c8a0e9e on 2017-05-01', machine='WiPy with ESP32')
When configuring P8 as input
p_in = Pin('P8', mode=Pin.IN, pull=Pin.PULL_UP)
It is high measuring 3.3v
when pulling it down
p_in = Pin('P8', mode=Pin.IN, pull=Pin.PULL_DOWN)
it stills measure High 3.3V even i declared it as a pull down.
check pycom forum link
I'm using the LoPy with firmware 1.7.3.b2.
Some functions like LoRa.join
raise a TimeoutError
if something fails. Python includes that exception since 3.3.
You define the exception in py/objexcept.c
:
MP_DEFINE_EXCEPTION(TimeoutError, OSError)
I can catch the exception raised by the LoRa class:
>>> try:
... lora.lora.join(activation=LoRa.OTAA, auth=lora.auth, timeout=1)
... except Exception as ee:
... foo = ee
...
>>> foo
TimeoutError('timed out',)
>>> foo.__class__
<class 'TimeoutError'>
...but the class does not exist in the global namespace!
>>> TimeoutError
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'TimeoutError' is not defined
Please consider also the open issues from the pycom-micropython branch.
They should not get lost. Most of them are also applicable to this branch.
Board: LoPy running firmware 1.7.8.b1
Problem:
The LoRaWAN stack on the LoPy only accepts downlinks sent to port 1 and 2. Downlinks sent to other valid ports (3 - 223) don't trigger an RX_PACKET_EVENT and return empty on socket.recv()
This behaviour is confirmed by the source code - there are only case statements for port 1, 2 and 224 (the latter being the LoRaWAN certification port)
Expected result:
Since there isn't currently a way to filter downlinks by port number - socket.bind() on LoRa only changes the uplink ports - I think the LoPy should accept downlinks to all valid application ports 1 to 223 as per the LoRaWAN specification. Silently dropping them is not a good option.
Proposed solution:
I'd be happy to submit a pull request to fix this by simply allowing any valid port, but perhaps a more complex solution including downlink port filtering should be implemented. Such a mechanism has been requested in the forums, but I'm not sure what is the best place to do it.
Acknowledgments:
Thanks to bmarkus for raising the issue of missing downlinks.
Please include the following information when submitting a bug report:
LoPy + PyCom expansion board
(sysname='LoPy', nodename='LoPy', release='1.7.3.b1', version='1e46e72-dirty on 2017-06-18', machine='LoPy with ESP32', lorawan='1.0.0') plus some small printf mods below
Exact steps to cause this issue
importing this class and running the classes start()
method runs a timer every 5 seconds that invokes _sendData()
from network import LoRa
import socket
import binascii
import time
from machine import Timer
class PNode:
def start(self):
lora = LoRa(mode=LoRa.LORA,
frequency=868100000,
bandwidth=LoRa.BW_125KHZ,
sf=12,
coding_rate=LoRa.CODING_4_8,
power_mode=LoRa.ALWAYS_ON, tx_iq=True)
print("LoRa Initialised")
self.__s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
self.__s.setblocking(False)
self.ping_counter = 1
self.start_time = time.ticks_ms()
self.__alarm = Timer.Alarm(self._sendData, 5, periodic=True)
def _sendData(self, alarm):
try:
self.__s.send('Ping {0!s}'.format(self.ping_counter))
except OSError as err:
print("OSError {0}, time={1}".format(err,time.ticks_diff(self.start_time, time.ticks_ms())))
else:
print('Sent Ping {0!s} at time={1}ms'.format(self.ping_counter,time.ticks_diff(self.start_time, time.ticks_ms())))
self.ping_counter += 1
Also using a modified version of the sigfox repo modlora.c
code below to give some additional information via printf's. No other changes made.
static int32_t lora_send (const byte *buf, uint32_t len, uint32_t timeout_ms) {
lora_cmd_data_t cmd_data;
cmd_data.cmd = E_LORA_CMD_TX;
memcpy (cmd_data.info.tx.data, buf, len);
cmd_data.info.tx.len = len;
printf("lora_send timeout is %dms\n",timeout_ms);
printf("lora_send sending data len=%d\n",cmd_data.info.tx.len);
printf("lora_send sending data=\"");
for(int i=0; i<cmd_data.info.tx.len; i++) {
printf("%c",cmd_data.info.tx.data[i]);
}
printf("\"\n");
if (timeout_ms < 0) {
// blocking mode
timeout_ms = portMAX_DELAY;
}
xEventGroupClearBits(LoRaEvents, LORA_STATUS_COMPLETED | LORA_STATUS_ERROR | LORA_STATUS_MSG_SIZE);
// just pass to the LoRa queue
if (!xQueueSend(xCmdQueue, (void *)&cmd_data, (TickType_t)(timeout_ms / portTICK_PERIOD_MS))) {
printf("xQueueSend Full\n");
return 0;
}
lora_obj.sftx = lora_obj.sf;
if (timeout_ms != 0) {
xEventGroupWaitBits(LoRaEvents,
LORA_STATUS_COMPLETED | LORA_STATUS_ERROR | LORA_STATUS_MSG_SIZE,
pdTRUE, // clear on exit
pdFALSE, // do not wait for all bits
(TickType_t)portMAX_DELAY);
}
// return the number of bytes sent
printf("lora_send sent %d bytes\n", len);
return len;
}
Should send an incrementing Ping number every 5 seconds. It works mostly by occasionally gets a number of EAGAIN errors which fire repeatedly and very rapidly until the system becomes stable and starts ping again.
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 17"
lora_send sent 7 bytes
Sent Ping 17 at time=85003ms
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 18"
lora_send sent 7 bytes
Sent Ping 18 at time=93031ms
The timer alarm now seems to fire far more often than my 5 seconds requested.
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 19"
lora_send sent 7 bytes
Sent Ping 19 at time=93042ms
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 20"
lora_send sent 7 bytes
Sent Ping 20 at time=93054ms
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
NOTE:*********************************
Queue seems full? and then the sytem
keeps retrying ~ 20ms without my consent
until fixed - see last entries below
every
OSError [Errno 11] EAGAIN, time=93066
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93079
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93092
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93104
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93117
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93130
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93142
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93155
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93168
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93180
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93193
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93206
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93218
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93231
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93244
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93256
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93269
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93282
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93294
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93307
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93320
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93332
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93345
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93358
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93370
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93383
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93396
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93408
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
xQueueSend Full
OSError [Errno 11] EAGAIN, time=93421
************ Now it is recovered OK
lora_send timeout is 0ms
lora_send sending data len=7
lora_send sending data="Ping 21"
lora_send sent 7 bytes
Sent Ping 21 at time=95936ms
Questions:
Why does my timer fire more rapidly than 5 seconds that causes Queue full?
Why is the queue full?
I only issue a single send but the modlora code keeps firing.
Also, why does my try: except: clause keep firing? OSError [Errno 11] EAGAIN, time=
messages are emitted by my python except clause.
The issue seems to be worse if I run a wlan.scan() on another timer every 30 seconds.
(sysname='LoPy', nodename='LoPy', release='1.6.13.b1', version='v1.8.6-593-g8e4ed0fa on 2017-04-12', machine='LoPy with ESP32', lorawan='1.0.0')
When ADR is enabled for the LoRaWAN class, the data rate is still expected to be set in the socket setsockopt() method.
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, self.ack)
s.setblocking(True)
s.send(bytes([0x01, 0x02, 0x03]))
Where the LoRaWAN constructor is called as following:
lora = LoRa(mode=LoRa.LORAWAN, frequency=868000000, adr=True)
And the produced error is as follows:
Traceback (most recent call last):
File "<stdin>", line 124, in <module>
File "<stdin>", line 83, in transmit
OSError: [Errno 11] EAGAIN
The ADR should not require the data rate to be set inside of the socket class as the gateway should provide feedback and control over data rate.
Thanks!
WiPy 2.0 or LoPy, both running 1.7.9.b3 firmware.
Strange BLE issue: an EMBC02 beacon advertising every second cannot be seen from WiPy (sometimes it catches one advertisement in 30 or 40). EMBC02 can advertise with its proprietary format (the trace below) or as a standard iBeacon/Eddystone; however, WiPy never sees it.
It's the unique type and make of device not seen until now (I have several). Did a scan with my Ubertooth One posting here the trace of one advertisement hoping that some expert sees why the ble stack is deaf for these devices:
systime=1503417955 freq=2402 addr=8e89bed6 delta_t=1008.339 ms rssi=-39
02 25 b4 46 0b ee f3 0c 0f 09 45 4d 42 65 61 63 6f 6e 31 38 30 39 31 00 0e ff 5a 00 bf f8 30 32 29 00 07 d2 e1 c0 01 23 21 3f
Advertising / AA 8e89bed6 (valid)/ 37 bytes
Channel Index: 37
Type: ADV_NONCONN_IND
AdvA: 0c:f3:ee:0b:46:b4 (public)
AdvData: 0f 09 45 4d 42 65 61 63 6f 6e 31 38 30 39 31 00 0e ff 5a 00 bf f8 30 32 29 00 07 d2 e1 c0 01
Type 09 (Complete Local Name)
EMBeacon18091.
Type ff (Manufacturer Specific Data)
Company: EM Microelectronic-Marin SA
Data: bf f8 30 32 29 00 07 d2 e1 c0 01
Data: b4 46 0b ee f3 0c 0f 09 45 4d 42 65 61 63 6f 6e 31 38 30 39 31 00 0e ff 5a 00 bf f8 30 32 29 00 07 d2 e1 c0 01
CRC: 23 21 3f
I was trying out the over-the-air (OTA) firmware update functionality and after a small tweak was surprised I could actually:
The only change I made was setting
#define IMG_SIZE (1536 * 1024)
in pycom-micropython-sigfox/esp32/bootloader/bootloader.h
(the 1536K is the actual size of the image, the old value 1024 overwrote the running code on SPI and cause very bad results)
I understand the size of the images and maybe the bootloader may not be fixed in stone yet but maybe this could work within minor versions?
wipy2.0
firmware version 1.7.2.b1
please wire all required wires for SD card slot
but do not insert SD card
put files
file sd.py
from machine import SD
import os
print('sd_init')
sd = SD()
print(sd)
os.mount(sd, '/sd')
print('sd mounted')
print(os.listdir('/sd'))
in main.py
execfile('/flash/sd.py')
and now - remove power and plug again
you got OSError - it is ok
but now - insert SD card and press reset
you still got OSError
remove power completly and plug again - it work
reset is not physical like power removing it miss something
WiPy 2.0
v1.8.6-650-g9bacbbd4 on 2017-06-09'
When I attempt to make a socket connection to a machine that is down the timeout value is completely ignored and connect() doesn't throw an exception.
Example code:
import time
import socket
def test1():
start = time.time()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
s.settimeout(3)
s.connect(('192.168.1.120', 15000))
finish = time.time()
print(finish - start)
s.close()
This takes 18-19 seconds and throws no exception.
(sysname='LoPy', nodename='LoPy', release='1.7.9.b3', version='v1.8.6-747-gc4ec6110 on 2017-08-09', machine='LoPy with ESP32', lorawan='1.0.0')
I tried to Add the FSK Channel from LoRaWAN 868 MHz (DR = 7) with the following command:
lora.add_channel(8, frequency=868800000, dr_min=7, dr_max=7)
An then i get the Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid argument(s) value
I think the Error is in:
esp32/mods/modlora.c :
lora_validate_data_rate()
It aborts, when the datarate is greater than DR_6 and that is wrong, because in 868 MHz band it can go to DR_7.
Hi,
I've managed to setup the advertisement as such now it functions as an iBeacon. However, I can't find anywhere in the documentation for a way to set the advertising frequency and the actual transmitting power. By Tx Power I do not mean the RSSI which is at the end of the manufacture data.
So I'm wondering if these can be set in some way.
Thanks,
QJ
Please include the following information when submitting a bug report:
(Dev env on a ubuntu 16.04 machine.
Using atom with pymakr plugin (latest available))
pyTrack with LoPy (Using it for a PoC that needs all power savings patches available...)
(have 2 Lopy 1 pytrack and 1 pyExpboard)
Updated both LoPy to 1.7.9.b3
Updated pyTrack to 0.0.4 (using pytrack_0.0.4.dfu)
All updates worked fine.
Both LoPY on pyExpBoard works (=connects to REPL in atom/pymaker) over serial (/dev/ttyUSB3) and on wifi.
But on pyTrack ....
Before shield update it turn up as /dev/ttyACM0 as expected (although I could for some reason not use
that port (could be my env somehow) it complained about rst/dtr settings in dmesg..)
wifi worked though which was enough for our purposes. (but really needed to get the new patches in to
save power and some improvements on the LoRa layer (Counters - NVRAM helped.)
To issue started when I updated the sheild to 0.0.4.
Then it will not come up as a serial device anymore...
in dmesg:
[158447.985265] usb 2-2: new full-speed USB device number 119 using xhci_hcd
[158448.113748] usb 2-2: New USB device found, idVendor=04d8, idProduct=f014
[158448.113751] usb 2-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb-devices:
T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 76 Spd=12 MxCh= 0
D: Ver= 1.00 Cls=fe(app. ) Sub=01 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=04d8 ProdID=f014 Rev=00.03
C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=00 Driver=(none)
No driver is found. (PIC16LF1459 say it should be ttyACMx)
WiFi is dead (comes to life if move to the pyExpboard)
and obviously installed program do not run....
so can't access it nor is anything starting ... bricked?
Is there any way of reverting the update via dfu-util of the pytrack shield?
(or is there a other pytrack_0.0.X that works?)
Any ideas what went wrong?
/ME
Hi, I'm playing with the wipy2 + pytrack.
os.uname()=
(sysname='WiPy', nodename='WiPy', release='1.7.5.b2', version='v1.8.6-694-g25826866 on 2017-06-29', machine='WiPy with E
SP32')
pytrack dfu ver: 0.0.3
I used the turorial script from github to get the accelerometers data in a while loop:
while True:
print("{} {:>10.3} {:>10.3} {:>10.3} ".format(li.acceleration(), li.pitch(), li.yaw(), li.roll()))
utime.sleep_ms(500)
I think I got some bugged response
laying on the bench it seems all regular:
(-0.015625, -0.0007324219, 1.014038) 0.884 -0.0414 -0.883
(-0.01708984, 0.001098633, 1.014404) 0.967 0.062 -0.965
but if I roll the pytrack, both pitch and roll reads some values:
(0.9797363, -0.1525879, -0.07019043) -86 -8.83 80.3
(1.001099, -0.1734619, -0.1179199) -83.4 -9.76 78.2
if I pitch the pytrack, pitch and yaw reads some values:
(-0.03173828, 0.994873, -0.08068848) -85.4 85 -1.82
(-0.01452637, 0.9941406, -0.07385254) -85.8 85.7 -0.835
if i yaw the pytrack ( Holding it vertically), it's pitch and yaw again
(0.1431885, -1.013672, 0.03063965) 88.3 -81.8 8.04
(0.1501465, -1.015625, 0.03515625) 88 -81.4 8.4
but if i turn it 90°, yaw decreases and roll increases:
(-0.9949951, -0.1469727, -0.04418945) -87.5 -8.39 -81.2
(-0.9726563, -0.09790039, -0.04040527) -87.6 -5.74 -83.8
is that a known bug or I do I have to parse the output data or else?
As the code for this has already been figured out, is there any chance this can be merged into the pycom port ??
https://github.com/micropython/micropython-esp32/blob/esp32/extmod/machine_pulse.c
It works very well and is EXTREMELY useful ?!
http://docs.micropython.org/en/v1.8.7/pyboard/library/machine.html#machine.time_pulse_us
Thanks
micropython/micropython@4fb72fe
Would it be possible to merge this in order to determine the available flash filesystem space ?
Thanks
LoPy
Firmware release 1.6.13.b1
My analysis is also described here: https://forum.pycom.io/topic/1255/lopy-stops-detecting-ble-advertisements
What I wanted to test out was how well LoPy receives BLE advertisements as a preparation for a real use case with iBeacons on vehicles. As the LoPy would be USB-powered I use start_scan(-1). I might be able to check only occasionally later on, but for now I assume the LoPy needs to be always scanning.
I noticed that get_adv sees only some of the advertisements, and it comes and goes. For a few seconds it can detect all, then for several seconds it hardly detects any. I've secured that the advertisement buffer never gets full. The beacons used for testing were very close by (like 10 cm away).
Another related problem is that after a varying time it stops detecting advertisements altogether, and I need to reboot for it to start again. In that state get_adv simply returns nothing.
This seems related: espressif/esp-idf#421
Cheers,
Anders
All versions:
for files larger than 2 GB the file size is displayed as negative number, resulting from a int <-> uint mismatch in the code for uos.stat(). This can be fixed by changing line 436 of mods/moduos.c into:
t->items[6] = mp_obj_new_int_from_uint(fno.fsize); // st_size
Nothing tragic.
I use both pyboard and xxPy, running both micropython. I used some code cross-boards as far as possible, and I ran into a minor annoyance for a function in utime
called ticks_diff()
that really doesn't have to be different at all.
The micropython of Pycom reverses the order of the arguments, whereas the implementation on the original micropython platform uses the IMHO right way to do this. Just to illustrate:
micropython's way
# Wait for GPIO pin to be asserted, but at most 500us
start = time.ticks_us()
while pin.value() == 0:
if time.ticks_diff(time.ticks_us(), start) > 500:
raise TimeoutError
Pycom's micropython way
# Wait for GPIO pin to be asserted, but at most 500us
start = time.ticks_us()
while pin.value() == 0:
if time.ticks_diff(start, time.ticks_us()) > 500:
raise TimeoutError
When using a static IP address (instead of DHCP), the ntp_sync() doesn't work when using the FQDN 'pool.ntp.org' although it does work when DHCP is used or when an IP-address is used.
>>> import os
>>> os.uname()
(sysname='LoPy', nodename='LoPy', release='1.6.13.b1', version='v1.8.6-607-g9c8a0e9e on 2017-05-01', machine='LoPy with ESP32', lorawan='1.0.0')
>>> wlan.ifconfig()
('192.168.0.191', '255.255.255.0', '192.168.0.1', '213.46.228.196')
>>> import machine
>>> rtc = machine.RTC()
>>> rtc.ntp_sync('pool.ntp.org', 3600)
>>> rtc.now()
(1970, 1, 1, 0, 2, 21, 96633, None)
>>> rtc.ntp_sync('128.199.44.119', 3600)
>>> rtc.now()
(2017, 5, 16, 6, 3, 44, 126771, None)
Also (I am adding it here in this issue because it might be caused by the same problem), socket.getaddrinfo() often returns '0.0.0.0' while using a static IP-address:
>>> wlan.ifconfig() ('192.168.0.191', '255.255.255.0', '192.168.0.1', '213.46.228.196')
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('0.0.0.0', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('122.175.14.128', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('16.88.252.63', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('0.0.0.0', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('0.0.0.0', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('0.0.0.0', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('80.87.252.63', 80))]
These libraries are not included in the repository and are requested during loading.
When building for LoPy: make BOARD=LOPY LORA_BAND=USE_BAND_915 TARGET=app
I needed to do this first: micropython/micropython@326343f
Using LoPY1.0r with Expansion board. Trying to use Pycom Firmware Update.app version 1.1.1.b1 running on a MacBook Pro with macOS Sierra version 10.12.4.
The upgrade failed, please check the connections and try the steps again.
This is the log of the upgrading process
Connecting...........................................
I've checked and rechecked. A colleague has tested the board with a PC and everything seemed
OK, but it won't work on my Mac.
https://docs.pycom.io/chapter/firmwareapi/pycom/network/bluetooth/
bluetooth.connect(mac_addr)
Opens a BLE connection with the device specified by the mac_addr argument. This function blocks until the connection succeeds or fails. If the connections succeeds it returns a object of type GATTCConnection.
bluetooth.connect('112233eeddff') # mac address is accepted as a string
I have tried putting in a dummy MAC address and it takes 30 seconds to timeout.
I think it will be great if we can set our own timeout.
e.g. bluetooth.connect('MAC',timeout)
Per the README.me in the esp32/ directory:
In order to build this project, a copy of the Espressif IDF is required and it's
path must be specified via the ESP_IDF_PATH variable. See the Makefile for details.
It should be IDF_PATH
instead of ESP_IDF_PATH
, since Makefile
copies IDF_PATH
to ESP_IDF_PATH
, but application.mk
only uses IDF_PATH
; this causes the call to esptool.py
to fail because the path is wrong.
Also, this line:
make BOARD=LOPY -j5 TARGET=boot
should read
make BOARD=LOPY -j5 LORA_BAND=USE_BAND_868 TARGET=boot
And I'd recommend some text about selecting the correct band for your region.
I can submit a PR, if desired.
There are some files in this repository which are substantial copies of MIT licensed code from the upstream MicroPython repo and they violate the MIT license because the copyright header is not retained. The MIT license has only one single requirement, namely: "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software."
Please fix this.
The following files at least need fixing:
boards/make-pins.py
mpconfigport.h
mods/machpin.c
mods/machspi.c
mods/modmachine.c
mods/modnetwork.h
mods/modnetwork.c
mods/moduos.c
mods/moduselect.c
mods/modusocket.c
mods/modutime.c
I have observed this with a LoPy running 1.8.0b1.
For ADR to perform correctly with deep sleep, the AdrAckCounter value must be saved in order for the device to decrease its data rates.
Similarly some information about the channel mask (among other things) and other setup parameters, transferred in the LinkAdrReq etc MAC commands must be persisted for the lifetime of the device session or the device will behave incorrectly. Channel frequency setups for non-US bands are a separate problem. RX1/RX2 timing windows and frequencies should also be persisted.
It looks like persisting LoRaMacParams and AdrAckCounter within LoRaMacNvsSave
and adding some MIB_...
enums to handle them should be sufficient. LoRaMacParams doesn't appear to contain any pointers so it should be straightforward.
Platform: (sysname='LoPy', nodename='LoPy', release='1.6.13.b1', version='v1.8.6-607-g9c8a0e9e on 2017-05-01', machine='LoPy with ESP32', lorawan='1.0.0')
Expected behaviour, quoted from documentation:
By default the heartbeat LED flashes in blue color once every 4s to signal that the system is alive.
Observed behaviour:
The heartbeat only flashes when there's no code running!
Steps to reproduce:
os.mkfs('/flash')
, to make sure we're in a completely clean state.while True:
pass
Alternative ways to reproduce:
Different main.py
files using busy loops, machine idle loops, time sleep loops:
if __name__ == '__main__':
while True:
pass
import machine
if __name__ == '__main__':
while True:
machine.idle()
import utime
if __name__ == '__main__':
while True:
utime.sleep_ms(10)
main.py
file having running code in a separate thread:
import _thread
def foo():
while True:
pass
if __name__ == '__main__':
_thread.start_new_thread(foo, ())
See also the forum thread at the Pycom forums.
Please note the discussion in the Pycom forum concerning the UART parity issue.
Many thanks!
Hello,
LOPY 1.7.9.b3.
If you run this piece of code you will see that memory is decreasing ... in the end it stops with 'MemoryError: memory allocation failed' . Comparing to previous timer memory leak issue, I believe there is ALWAYS a LEAK when you are using function callbacks.
import gc
import utime
from machine import Pin
class Object:
def __init__(self):
print ("Object INIT ", self)
def start(self):
def _call(arg):
print('PIN changed')
self._analogPin=Pin('P15',mode=Pin.IN,pull=Pin.PULL_UP)
self._analogPin.callback(Pin.IRQ_FALLING , _call)
def __del__(self):
print ("Object DEL ", self)
def stop(self):
self._analogPin.callback(Pin.IRQ_FALLING , None)
del self._analogPin
self._analogPin = None
print("Start memory %s" %(gc.mem_free()))
SLEEP = 0.1
gc.enable()
while True:
obj = Object()
obj.start()
utime.sleep(SLEEP)
obj.stop()
del obj
obj = None
gc.collect()
print("\t\tmemory %s" %(gc.mem_free()))
BLE notifications don't seem to be working on the LoPy, when the LoPy is running as a BLE server (firmware version: 1.7.6.b1). Subscribing to notifications for a characteristic being advertised by a LoPy does not seem to trigger any notifications.
Sample code:
from network import Bluetooth
import pycom
import time
print('Advertising Bluetooth...')
bluetooth = Bluetooth()
bluetooth.set_advertisement(name='LoPy', service_uuid=b'1234567890abcdef')
def conn_cb (bt_o):
events = bt_o.events()
if events & Bluetooth.CLIENT_CONNECTED:
print("Client connected")
elif events & Bluetooth.CLIENT_DISCONNECTED:
print("Client disconnected")
bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)
bluetooth.advertise(True)
#Create service and characteristic
srv1 = bluetooth.service(uuid='0000000000000000', isprimary=True)
chr1 = srv1.characteristic(uuid='0000000000000002', properties=Bluetooth.PROP_INDICATE | Bluetooth.PROP_BROADCAST | Bluetooth.PROP_READ | Bluetooth.PROP_NOTIFY, value='InitialValue')
#Create callback for read events on the characteristic
def char1_cb(chr):
events = chr.events()
if events & Bluetooth.CHAR_READ_EVENT :
print('Bluetooth.CHAR_READ_EVENT')
chr1.callback(trigger=Bluetooth.CHAR_READ_EVENT, handler=char1_cb)
#Update the characteristic value very few seconds
i=0
while True:
val = 'Value{}'.format(i)
print('Setting value: {}'.format(val))
chr1.value(val) #Set the characteristic value - should trigger notification is a client has registered for notifications
time.sleep(3)
i+=1
Steps to reproduce:
Is this a known issue or am I missing something?
Thanks!
System: Ubuntu 16.04 LTS x64
Environment setup:
Micropython test:
MicroPython ccb10e3 on 2017-08-25; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> print('Hello World')
Segmentation fault (core dumped)
Thank you!
(sysname='LoPy', nodename='LoPy', release='1.6.13.b1', version='v1.8.6-607-g9c8a0e9e on 2017-05-01', machine='LoPy with
ESP32', lorawan='1.0.0')
Attempting to connect from one LoPy to another LoPy device:
from network import Bluetooth
import binascii
bluetooth = Bluetooth()
# scan until we can connect to any BLE device around
bluetooth.start_scan(-1)
adv = None
while True:
adv = bluetooth.get_adv()
if adv:
try:
print(binascii.hexlify(adv.mac))
bluetooth.connect(adv.mac)
except:
# start scanning again
bluetooth.start_scan(-1)
continue
break
print("Connected to device with addr = {}".format(binascii.hexlify(adv.mac)))
Error arises after the connecting LoPy finds the address of the advertising device and attempts to connect.
b'240ac40061fa'
Traceback (most recent call last):
File "<stdin>", line 50, in <module>
OSError: connection already closed
Thanks!
LopY 1.7.8.b1
This type of crash blocks the device.
Simple to reproduce. Type in console:
a= 0xaabbccdd
a.to_bytes(4)
b'\xdd\xcc\xbb\xaa'
import ustruct
ustruct.pack('4b',a)
Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x400ee210 PS : 0x00060030 A0 : 0x800ee403 A1 : 0x3ffc6830
A2 : 0x3ffc6af0 A3 : 0x3ffc6841 A4 : 0x00000001 A5 : 0x3ffe83f2
A6 : 0x000000fb A7 : 0xffffffff A8 : 0x00000000 A9 : 0x0000ccdd
A10 : 0x00000002 A11 : 0x3ffe83f0 A12 : 0x0000ccdd A13 : 0x3ffe83ef
A14 : 0x00000010 A15 : 0x3ffe83f1 SAR : 0x0000001e EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x4000c28c LEND : 0x4000c296 LCOUNT : 0x00000000
Backtrace: 0x400ee210:0x3ffc6830 0x400ee400:0x3ffc6850 0x400f5ef0:0x3ffc6870 0x400f77ae:0x3ffc68b0 0x400f7801:0x3ffc68f0 0x400f078b:0x3ffc6920 0x400ecc5d:0x3ffc6950 0x400eccc5:0x3ffc6970 0x400f883d:0x3ffc6990 0x400f0710:0x3ffc6a30 0x400ecc5d:0x3ffc6ab0 0x400ecc8a:0x3ffc6ad0 0x400d9953:0x3ffc6af0 0x400d9bf4:0x3ffc6b90 0x400d8c28:0x3ffc6bd0
Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x4008a199 PS : 0x00060033 A0 : 0x80088fd6 A1 : 0x3ffc6470
A2 : 0x3ffc64c0 A3 : 0x3ffc6490 A4 : 0x00000000 A5 : 0x3ffc483c
A6 : 0x00000000 A7 : 0x3ffc4858 A8 : 0x00000012 A9 : 0x3ffc6440
A10 : 0x3ffc6508 A11 : 0x3ffc6490 A12 : 0x3ffb798c A13 : 0x3ffc6850
A14 : 0x3ffc6af0 A15 : 0x00000000 SAR : 0x00000020 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Backtrace: 0x4008a199:0x3ffc6470 0x40088fd3:0x3ffc6490 0x4008b2f5:0x3ffc64c0 0x4008b66a:0x3ffc6690 0x4008af75:0x3ffc66d0 0x4008b0f0:0x3ffc6750 0x4008168a:0x3ffc6770 0x400ee20d:0x3ffc6830 0x400ee20d:0x3ffc6850 0x400f5ef0:0x3ffc6870 0x400f77ae:0x3ffc68b0 0x400f7801:0x3ffc68f0 0x400f078b:0x3ffc6920 0x400ecc5d:0x3ffc6950 0x400eccc5:0x3ffc6970 0x400f883d:0x3ffc6990 0x400f0710:0x3ffc6a30 0x400ecc5d:0x3ffc6ab0 0x400ecc8a:0x3ffc6ad0 0x400d9953:0x3ffc6af0 0x400d9bf4:0x3ffc6b90 0x400d8c28:0x3ffc6bd0
Hi, I wanna try to compile micropython for my Lopy but I am facing this error. Any idea ?
git revision: f4f56ab
make BOARD=LOPY LORA_BAND=USE_BAND_868 flash V=1
[...]
IMAGE build/LOPY_868/release/lopy_868.bin
python /home/edby8475/Documents/DevOPS/FabLab/lopy_compile/pycom-esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 elf2image --flash_mode qio --flash_freq 40m -o build/LOPY_868/release/lopy_868.bin build/LOPY_868/release/application.elf
esptool.py v2.0-beta2
Signing OTA image
bash tools/appsign.sh build/LOPY_868/release/lopy_868.bin build/LOPY_868/release
make: *** No rule to make target 'build/LOPY_868/release/bootloader/bootloader.bin', needed by 'flash'. Stop.
Thanks for your help
I use a WiPy 2.0
with firmware 1.7.6.b1
.
I notice that with firmware 1.7.6.b1
now the BLE connection function works fine. Now it is possible discover all services and characteristics, but the write function on a characteristic does not work. In my code example chars[0]
is a PROP_WRITE
charateristic, but when I write something on it, anything happen.
from network import Bluetooth
import ubinascii
import machine
import uos
import utime
bt = Bluetooth()
bt.start_scan(-1)
while True:
adv = bt.get_adv()
try:
if adv and bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL) == 'X-DOM-NC':
print(adv.mac)
conn = bt.connect(adv.mac)
while not conn.isconnected():
machine.idle()
print("connected")
print(conn)
services = conn.services()
print("services")
print(services)
print(services[0].uuid())
print(services[1].uuid())
print(services[2].uuid())
chars = services[2].characteristics()
print(chars)
print(chars[0].properties())
print(chars[1].properties())
print(chars[0].uuid())
print(chars[1].uuid())
chars[0].write(b'x0f')
utime.sleep(2)
break
except:
print("Error while connecting or reading from the BLE device")
break
while True:
pass
conn.disconnect()
Instead, if chars[0]
has a property PROP_WRITE_NR
the write function works fine!
There is obviously an inconsistency in the partition map between firmware builds, made by Pycom and those made locally from the github repository. What happens when:
If you have first loaded an pycom.io firmware via updater tool, and then flash a self built image via "make flash", the device does not start, but just shows a red RGB led. One has to erase the flash completely and reload to get it working.
If you have a self built image working and then load an pycom.io image, the device starts, but the content of the file system is gone.
So: would please someone make these two variants consistent.
Building LoPy(Latest firmware update today) from Pycom. Getting this error on linux 64 bit OS. Please resolve this. Even i have tried the method above but no luck.
Error shown below-----
skmis@skmis-VirtualBox:~/esp/esp32$ make BOARD=LOPY -j5 LORA_BAND=USE_BAND_868 TARGET=app
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
LINK build/LOPY_868/release/application.elf
/home/skmis/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lrtc_clk
collect2: error: ld returned 1 exit status
application.mk:360: recipe for target 'build/LOPY_868/release/application.elf' failed
make: *** [build/LOPY_868/release/application.elf] Error 1
Board: LoPy
Firmware: 1.7.8.b1
Please make available destination port of LoRaWAN downlink messages for user space.
Forum reference: https://forum.pycom.io/topic/1582/lorawan-return-downlink-destination-port
int32 overflow because of to late cast
STATIC mp_obj_t machine_deepsleep (uint n_args, const mp_obj_t *arg) {
mperror_enable_heartbeat(false);
bt_deinit(NULL);
wlan_deinit(NULL);
if (n_args == 0) {
esp_deep_sleep_start();
} else {
esp_deep_sleep((uint64_t)(mp_obj_get_int(arg[0]) * 1000));
}
}
but should be
esp_deep_sleep((uint64_t)mp_obj_get_int(arg[0]) * 1000);
Hello,
I am trying to connect to Pycom (1.1.3) from Atom editor (Atom: 1.20.1, Electron: 1.6.9, Chrome: 56.0.2924.87, Node: 7.4.0) on Ubuntu 14.04. I added Pymkr 1.1.3 automatically using the Atom GUI. The Atom editor crashes when clicking on connect, after retrieving and setting the USB serial port for Pycom. The message displayed is "Editor has crashed. Please report this issue". I am totally new to the environment and trying to do my first set up. Could anyone help me identify the source of the problem and fix it?
Thank you!
Board: LoPy
Firmware: 1.7.8.b1
snr returned by lora.stats() is not the snr in dB but the value returned by LoRa HAL. It must devided by 4.
Forum reference: https://forum.pycom.io/topic/1597/false-value-returned-by-lora-stats
wipy2.0
os.uname()=
(sysname='WiPy', nodename='WiPy', release='1.7.5.b2', version='v1.8.6-694-g25826866 on 2017-06-29', machine='WiPy with E
SP32')
pytrack dfu ver: 0.0.3
after some seconds of getting cordinates into the while loop, l76.coordinates() starts alternating (None,None)
and the correct values.
I am connecting my device to a HM-10 BLE product using GATTC.
In super summary, BLE works the following way for GATT,
There is a service, which MAY contain characteristics.
The characteristics will have a value and may have a descriptor.
http://static.thegeekstuff.com/wp-content/uploads/2014/07/ti-ble-profile.png
Usually if you expect a reply from a client, you have to enable the notifications / indications to be 1 within the descriptor field of the characteristic you want to have a reply.
For example, in HM-10, if i send a "AT", i should receive "OK"
For my android phones, and pygatt software and micropython(https://github.com/MrSurly/micropython-esp32/blob/dev-bluetooth/esp32/bluetooth_docs.md), to receive the "OK" command, I will have to manually set the notifications or indications field to be true. It works on all the devices.
However, there is no way for me to set it to be true in pycom micropython as there is no descriptor function within characteristic.
dir(blecharacteristic)
['uuid', 'instance', 'properties', 'read', 'write', 'callback']
I believe you guys missed this portion of the API. Do let me know if you guys need logs or anything.
Board: LoPy
Firmware: 1.7.8.b1
There is a lora.set_battery_level(level) method introduced in latest firmware.
Unfortunately current implementation is not in line with LoraWAN Specification v1.0.2
Method is passing values between 0 and 100 to the LoRaWAN server directly which means on server side 39% for level=100, 20% for level=50, there are no way to report battery level 40-100%.
Default value is 0 which indicates device is running on external source, level=0 doesn't mean 0%. Proper default value would be 255 which by the way can't be reported via this method.
I advice to allow level=0...255 in the method inpput argument and use level=255 as default, adding the quoted text from the LoRaWAN specification to the documentation.
Forum reference: https://forum.pycom.io/topic/1613/lorawan-mac-battery-level-reporting
(from bmarkus)
Hi. I just got a WiPy 2.0, and discovered that the plugin for Atom is broken (can't find serialport.py), so I'm trying VS Code. I've installed the plugin there, and restarted VSCode. The instruction say to:
Open 'Global Settings' (this opens automatically after first install).
Where is "Global Settings"? I've been all over the menus, and there's nothing like that.
My first experience with PyCom is definitely not a great start.
Please help!
(I'd enter all that stuff you wnated from the REPL, but I can't get a REPL!)
Thanks,
Steve
(sysname='WiPy', nodename='WiPy', release='1.8.0.b1', version='v1.8.6-760-g90b72952 on 2017-09-01', machine='WiPy with ESP32')
WiPy 2.0
Pysense firmware updated to 0.0.4, board v1.0
I synced the pysense software using pymakr and the WiPy in the expansion dock as syncing was erratic when the WiPy is in the Pysense dock.
When booting in the Pysense dock I get:
rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff9010,len:12
ho 0 tail 12 room 4
load:0x3fff9020,len:388
load:0x40078000,len:11584
load:0x4009fb00,len:848
entry 0x4009fc9c
Hello from playtime/boot
Hello from playtime/main
MicroPython v1.8.6-760-g90b72952 on 2017-09-01; WiPy with ESP32
Type "help()" for more information.
(boot.py and main.py each contain only a simple print statement)
At this point the behavior is unpredictable. Sometimes I can interact with the REPL, mostly not. If I can and import pysense, it becomes unresponsive.
This is being done on an 11 inch Macbook Air using CoolTerm for interactions with the REPL. I have no issues at all when the WiPy is in the expansion doc. I suspect that the Pysense board is defective.
After cloning the latest version (including pycom-esp-idf) on OS X I get the following compilation error:
/Users/avb/Work/Pycom/pycom-esp-idf/components/soc/esp32/include/soc/io_mux_reg.h: In function 'PIN_PULLUP_DIS':
/Users/avb/Work/Pycom/pycom-esp-idf/components/esp32/include/esp_assert.h:23:28: error: first argument to '__builtin_choose_expr' not a constant
_Static_assert(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG);
... many similar messages to follow
This is for a LOPY on 868 MHz
As earlier versions compiled and worked correctly I think something is broken. Any suggestions how to fix this?
Tnx, Auke
Hardware: WiPy 2.0 (though probably same issue on all).
Problem: int.from_bytes(b'\xFF\x00','big')
returns 255. Expected: 65280 for big endian (255 is correct for little endian).
Apparently this was fixed in the original micropython.org branch in January with PR #2791.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.