mirror of https://github.com/arendst/Tasmota.git
Berry fix for stricter mode
This commit is contained in:
parent
04f1c57e90
commit
18a950f61c
|
@ -471,7 +471,7 @@ static void new_var(bparser *parser, bstring *name, bexpdesc *var)
|
|||
bfuncinfo *finfo = parser->finfo;
|
||||
if (comp_is_strict(parser->vm)) {
|
||||
/* check if we are masking a builtin */
|
||||
if (be_builtin_class_find(parser->vm, name) >= 0) {
|
||||
if (be_builtin_find(parser->vm, name) >= 0) {
|
||||
push_error(parser, "strict: redefinition of builtin '%s'", str(name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,21 +132,6 @@ int be_builtin_find(bvm *vm, bstring *name)
|
|||
return -1; /* not found */
|
||||
}
|
||||
|
||||
/* find in the list of builtins or classes - used by strict to avoid accidental change of those */
|
||||
int be_builtin_class_find(bvm *vm, bstring *name)
|
||||
{
|
||||
bvalue *res = be_map_findstr(vm, builtin(vm).vtab, name);
|
||||
if (res) {
|
||||
return var_toidx(res);
|
||||
} else {
|
||||
int idx = global_native_class_find(vm, name);
|
||||
if (idx >= 0) {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
return -1; /* not found */
|
||||
}
|
||||
|
||||
bstring* be_builtin_name(bvm *vm, int index)
|
||||
{
|
||||
bmap *map = builtin(vm).vtab;
|
||||
|
|
|
@ -23,7 +23,6 @@ int be_global_new(bvm *vm, bstring *name);
|
|||
bvalue* be_global_var(bvm *vm, int index);
|
||||
void be_global_release_space(bvm *vm);
|
||||
int be_builtin_find(bvm *vm, bstring *name);
|
||||
int be_builtin_class_find(bvm *vm, bstring *name);
|
||||
bstring* be_builtin_name(bvm *vm, int index);
|
||||
int be_builtin_new(bvm *vm, bstring *name);
|
||||
void be_bulitin_release_space(bvm *vm);
|
||||
|
|
|
@ -105,7 +105,7 @@ struct bvm {
|
|||
struct bgc gc;
|
||||
bctypefunc ctypefunc; /* handler to ctype_func */
|
||||
bbyte compopt; /* compilation options */
|
||||
uint32_t bytesmaxsize; /* max allowed size for bytes() object, default 32kb but can be increased */
|
||||
int32_t bytesmaxsize; /* max allowed size for bytes() object, default 32kb but can be increased */
|
||||
bobshook obshook;
|
||||
bmicrosfnct microsfnct; /* fucntion to get time as a microsecond resolution */
|
||||
#if BE_USE_PERF_COUNTERS
|
||||
|
|
|
@ -18,7 +18,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* do not modify the version number! */
|
||||
#define BERRY_VERSION "1.0.0"
|
||||
#define BERRY_VERSION "1.1.0"
|
||||
|
||||
#if BE_STACK_TOTAL_MAX < BE_STACK_FREE_MIN * 2
|
||||
#error "The value of the macro BE_STACK_TOTAL_MAX is too small."
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import os
|
||||
|
||||
def strfind(str, char)
|
||||
var len = size(str)
|
||||
def strfind(st, char)
|
||||
var len = size(st)
|
||||
for i : 0 .. len - 1
|
||||
if str[i] == char
|
||||
if st[i] == char
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,22 +2,13 @@
|
|||
|
||||
def assert_syntax_error(code)
|
||||
try
|
||||
f = compile(code)
|
||||
var f = compile(code)
|
||||
assert(false, 'unexpected execution flow')
|
||||
except .. as e, m
|
||||
assert(e == 'syntax_error')
|
||||
end
|
||||
end
|
||||
def assert_attribute_error(f)
|
||||
try
|
||||
f()
|
||||
assert(false, 'unexpected execution flow')
|
||||
except .. as e, m
|
||||
assert(e == 'attribute_error')
|
||||
end
|
||||
end
|
||||
def findinlist(l, e)
|
||||
var i
|
||||
for i: 0..size(l)-1
|
||||
if l[i] == e return i end
|
||||
end
|
||||
|
@ -42,8 +33,8 @@ global.global_c = 3
|
|||
f = compile("return global_c")
|
||||
assert(f() == 3)
|
||||
|
||||
#- check that access to non-existent global returns an exception -#
|
||||
assert_attribute_error(/-> global.d)
|
||||
#- check that access to non-existent global returns nil (new behavior) -#
|
||||
assert(global.d == nil)
|
||||
|
||||
#- check the glbal list -#
|
||||
assert(findinlist(global(), 'global_a') != nil)
|
||||
|
|
|
@ -12,10 +12,10 @@ assert(os.path.join('abc', '/de', 'fghij') == '/de/fghij')
|
|||
assert(os.path.join('abc', 'xyz', '/de', 'fghij') == '/de/fghij')
|
||||
|
||||
# os.path.split test
|
||||
def split(str, list)
|
||||
var res = os.path.split(str)
|
||||
assert(res[0] == list[0] && res[1] == list[1],
|
||||
'unexpected results: ' .. res .. ', reference value: ' .. list)
|
||||
def split(st, lst)
|
||||
var res = os.path.split(st)
|
||||
assert(res[0] == lst[0] && res[1] == lst[1],
|
||||
'unexpected results: ' .. res .. ', reference value: ' .. lst)
|
||||
end
|
||||
|
||||
split('/', ['/', ''])
|
||||
|
@ -31,10 +31,10 @@ split('abcd////ef/////', ['abcd////ef', ''])
|
|||
split('abcd////ef', ['abcd', 'ef'])
|
||||
|
||||
# os.path.splitext test
|
||||
def splitext(str, list)
|
||||
var res = os.path.splitext(str)
|
||||
assert(res[0] == list[0] && res[1] == list[1],
|
||||
'unexpected results: ' .. res .. ', reference value: ' .. list)
|
||||
def splitext(st, lst)
|
||||
var res = os.path.splitext(st)
|
||||
assert(res[0] == lst[0] && res[1] == lst[1],
|
||||
'unexpected results: ' .. res .. ', reference value: ' .. lst)
|
||||
end
|
||||
|
||||
splitext('a.b', ['a', '.b'])
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,23 +29,25 @@ class FT3663 : I2C_Driver
|
|||
def init()
|
||||
super(self).init("FT3663", 0x38)
|
||||
# check that ID from register 0xA8 is 0x11
|
||||
var vendid = self.read8(0xA8)
|
||||
var chipid = self.read8(0xA3)
|
||||
if vendid != 0x11 || chipid != 0x64
|
||||
tasmota.log("I2C: ignoring address 0x38, not FT3663", 2)
|
||||
self.wire = nil
|
||||
return
|
||||
if self.wire
|
||||
var vendid = self.read8(0xA8)
|
||||
var chipid = self.read8(0xA3)
|
||||
if vendid != 0x11 || chipid != 0x64
|
||||
tasmota.log("I2C: ignoring address 0x38, not FT3663", 2)
|
||||
self.wire = nil
|
||||
return
|
||||
end
|
||||
|
||||
# FT3663 is now confirmed
|
||||
tasmota.log("TS : FT3663 Touch Screen detected")
|
||||
|
||||
self.write8(0x00, 0x00) # writeRegister8(FT6X36_REG_DEVICE_MODE, 0x00);
|
||||
self.write8(0x80, 22) # writeRegister8(FT6X36_REG_THRESHHOLD, FT6X36_DEFAULT_THRESHOLD);
|
||||
self.write8(0x88, 0x0E) # writeRegister8(FT6X36_REG_TOUCHRATE_ACTIVE, 0x0E);
|
||||
|
||||
# register ourself
|
||||
tasmota.add_driver(self)
|
||||
end
|
||||
|
||||
# FT3663 is now confirmed
|
||||
tasmota.log("TS : FT3663 Touch Screen detected")
|
||||
|
||||
self.write8(0x00, 0x00) # writeRegister8(FT6X36_REG_DEVICE_MODE, 0x00);
|
||||
self.write8(0x80, 22) # writeRegister8(FT6X36_REG_THRESHHOLD, FT6X36_DEFAULT_THRESHOLD);
|
||||
self.write8(0x88, 0x0E) # writeRegister8(FT6X36_REG_TOUCHRATE_ACTIVE, 0x0E);
|
||||
|
||||
# register ourself
|
||||
tasmota.add_driver(self)
|
||||
end
|
||||
|
||||
# read touch screen and publish result
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
# Native commands
|
||||
# 00 : ctor (leds:int, gpio:int[, type:int, rmt:int]) -> void
|
||||
# 00 : ctor (leds:int, gpio:int[, typ:int, rmt:int]) -> void
|
||||
# 01 : begin void -> void
|
||||
# 02 : show void -> void
|
||||
# 03 : CanShow void -> bool
|
||||
|
@ -28,9 +28,9 @@ class Leds : Leds_ntv
|
|||
var leds # number of leds
|
||||
# leds:int = number of leds of the strip
|
||||
# gpio:int (optional) = GPIO for NeoPixel. If not specified, takes the WS2812 gpio
|
||||
# type:int (optional) = Type of LED, defaults to WS2812 RGB
|
||||
# typ:int (optional) = Type of LED, defaults to WS2812 RGB
|
||||
# rmt:int (optional) = RMT hardware channel to use, leave default unless you have a good reason
|
||||
def init(leds, gpio_phy, type, rmt) # rmt is optional
|
||||
def init(leds, gpio_phy, typ, rmt) # rmt is optional
|
||||
self.gamma = true # gamma is enabled by default, it should be disabled explicitly if needed
|
||||
self.leds = int(leds)
|
||||
|
||||
|
@ -40,7 +40,7 @@ class Leds : Leds_ntv
|
|||
end
|
||||
|
||||
# initialize the structure
|
||||
self.ctor(self.leds, gpio_phy, type, rmt)
|
||||
self.ctor(self.leds, gpio_phy, typ, rmt)
|
||||
|
||||
if self._p == nil raise "internal_error", "couldn't not initialize noepixelbus" end
|
||||
|
||||
|
@ -92,14 +92,14 @@ class Leds : Leds_ntv
|
|||
self.show()
|
||||
end
|
||||
|
||||
def ctor(leds, gpio_phy, type, rmt)
|
||||
if type == nil
|
||||
type = self.WS2812_GRB
|
||||
def ctor(leds, gpio_phy, typ, rmt)
|
||||
if typ == nil
|
||||
typ = self.WS2812_GRB
|
||||
end
|
||||
if rmt == nil
|
||||
rmt = self.assign_rmt(gpio_phy)
|
||||
end
|
||||
self.call_native(0, leds, gpio_phy, type, rmt)
|
||||
self.call_native(0, leds, gpio_phy, typ, rmt)
|
||||
end
|
||||
def begin()
|
||||
self.call_native(1)
|
||||
|
|
|
@ -30,7 +30,7 @@ class Partition_info
|
|||
var type
|
||||
var subtype
|
||||
var start
|
||||
var size
|
||||
var sz
|
||||
var label
|
||||
var flags
|
||||
|
||||
|
@ -54,7 +54,7 @@ class Partition_info
|
|||
self.type = 0
|
||||
self.subtype = 0
|
||||
self.start = 0
|
||||
self.size = 0
|
||||
self.sz = 0
|
||||
self.label = ''
|
||||
self.flags = 0
|
||||
|
||||
|
@ -69,7 +69,7 @@ class Partition_info
|
|||
self.type = raw.get(2,1)
|
||||
self.subtype = raw.get(3,1)
|
||||
self.start = raw.get(4,4)
|
||||
self.size = raw.get(8,4)
|
||||
self.sz = raw.get(8,4)
|
||||
self.label = self.remove_trailing_zeroes(raw[12..27]).asstring()
|
||||
self.flags = raw.get(28,4)
|
||||
|
||||
|
@ -109,7 +109,7 @@ class Partition_info
|
|||
if self.is_ota() == nil && !self.is_factory() return -1 end
|
||||
try
|
||||
var addr = self.start
|
||||
var size = self.size
|
||||
var sz = self.sz
|
||||
var magic_byte = flash.read(addr, 1).get(0, 1)
|
||||
if magic_byte != 0xE9 return -1 end
|
||||
|
||||
|
@ -124,10 +124,10 @@ class Partition_info
|
|||
var segment_header = flash.read(seg_offset - 8, 8)
|
||||
var seg_start_addr = segment_header.get(0, 4)
|
||||
var seg_size = segment_header.get(4,4)
|
||||
# print(string.format("Segment %i: flash_offset=0x%08X start_addr=0x%08X size=0x%08X", seg_num, seg_offset, seg_start_addr, seg_size))
|
||||
# print(string.format("Segment %i: flash_offset=0x%08X start_addr=0x%08X sz=0x%08X", seg_num, seg_offset, seg_start_addr, seg_size))
|
||||
|
||||
seg_offset += seg_size + 8 # add segment_length + sizeof(esp_image_segment_header_t)
|
||||
if seg_offset >= (addr + size) return -1 end
|
||||
if seg_offset >= (addr + sz) return -1 end
|
||||
|
||||
seg_num += 1
|
||||
end
|
||||
|
@ -186,7 +186,7 @@ class Partition_info
|
|||
return string.format("<instance: Partition_info(%d%s,%d%s,0x%08X,0x%08X,'%s',0x%X)>",
|
||||
self.type, type_s,
|
||||
self.subtype, subtype_s,
|
||||
self.start, self.size,
|
||||
self.start, self.sz,
|
||||
self.label, self.flags)
|
||||
end
|
||||
|
||||
|
@ -197,7 +197,7 @@ class Partition_info
|
|||
b.add(self.type, 1)
|
||||
b.add(self.subtype, 1)
|
||||
b.add(self.start, 4)
|
||||
b.add(self.size, 4)
|
||||
b.add(self.sz, 4)
|
||||
var label = bytes().fromstring(self.label)
|
||||
label.resize(16)
|
||||
b = b + label
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -62,7 +62,7 @@ class Partition_wizard_UI
|
|||
if last_slot.is_spiffs()
|
||||
# verify that last slot is filesystem
|
||||
var flash_size_k = self.get_max_flash_size_k(p)
|
||||
var partition_end_k = (last_slot.start + last_slot.size) / 1024 # last kb used for fs
|
||||
var partition_end_k = (last_slot.start + last_slot.sz) / 1024 # last kb used for fs
|
||||
if partition_end_k < flash_size_k
|
||||
return flash_size_k - partition_end_k
|
||||
end
|
||||
|
@ -143,7 +143,7 @@ class Partition_wizard_UI
|
|||
def get_cur_fs_size_k(p)
|
||||
var last_slot = p.slots[-1]
|
||||
if last_slot.is_spiffs() # verify that last slot is filesystem
|
||||
return (last_slot.size + 1023) / 1024
|
||||
return (last_slot.sz + 1023) / 1024
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
@ -265,7 +265,7 @@ class Partition_wizard_UI
|
|||
var app0 = p.get_ota_slot(0)
|
||||
var app1 = p.get_ota_slot(0)
|
||||
var app0_firmware_size = (app0 != nil) ? app0.get_image_size() : -1
|
||||
var app1_size = (app1 != nil) ? app1.size : -1
|
||||
var app1_size = (app1 != nil) ? app1.sz : -1
|
||||
if app0_firmware_size < 0 || app1_size < 0 return "can't find app0/1 sizes" end
|
||||
if app0_firmware_size >= app1_size return "`app1` is too small" end
|
||||
return false
|
||||
|
@ -295,7 +295,7 @@ class Partition_wizard_UI
|
|||
if !self.factory_migrate_eligible(p) return "not eligible to migration" end
|
||||
|
||||
var app0 = p.get_ota_slot(0)
|
||||
if app0.size < (self.app_size_min * 1024) return "`app0` is too small for `safeboot`" end
|
||||
if app0.sz < (self.app_size_min * 1024) return "`app0` is too small for `safeboot`" end
|
||||
var app0_image_size = app0.get_image_size()
|
||||
if (app0_image_size > 0) && (app0_image_size < (self.app_size_min * 1024)) return true end
|
||||
return false
|
||||
|
@ -347,13 +347,13 @@ class Partition_wizard_UI
|
|||
# if app0.get_image_size() > (self.app_size_min * 1024) return "`app0` is too small for `safeboot`" end
|
||||
end
|
||||
|
||||
static def copy_ota(from_addr, to_addr, size)
|
||||
static def copy_ota(from_addr, to_addr, sz)
|
||||
import flash
|
||||
import string
|
||||
var size_left = size
|
||||
var size_left = sz
|
||||
var offset = 0
|
||||
|
||||
tasmota.log(string.format("UPL: Copy flash from 0x%06X to 0x%06X (size: %ikB)", from_addr, to_addr, size / 1024), 2)
|
||||
tasmota.log(string.format("UPL: Copy flash from 0x%06X to 0x%06X (size: %ikB)", from_addr, to_addr, sz / 1024), 2)
|
||||
while size_left > 0
|
||||
var b = flash.read(from_addr + offset, 4096)
|
||||
flash.erase(to_addr + offset, 4096)
|
||||
|
@ -376,7 +376,7 @@ class Partition_wizard_UI
|
|||
var app0 = p.get_ota_slot(0)
|
||||
var app1 = p.get_ota_slot(1)
|
||||
var app0_size = app0.get_image_size()
|
||||
if app0_size > app1.size raise "internal_error", "`app1` too small to copy firmware form `app0`" end
|
||||
if app0_size > app1.sz raise "internal_error", "`app1` too small to copy firmware form `app0`" end
|
||||
self.copy_ota(app0.start, app1.start, app0_size)
|
||||
|
||||
p.set_active(1)
|
||||
|
@ -433,14 +433,14 @@ class Partition_wizard_UI
|
|||
|
||||
# do the change
|
||||
app0.subtype = 0 # factory subtype
|
||||
app0.size = factory_size
|
||||
app0.sz = factory_size
|
||||
app0.label = 'safeboot'
|
||||
|
||||
app1.subtype = 0x10 # app1 becomes app0
|
||||
app1.label = 'app0'
|
||||
var f1_start = app1.start
|
||||
app1.start = app0.start + factory_size
|
||||
app1.size += f1_start - app1.start
|
||||
app1.sz += f1_start - app1.start
|
||||
|
||||
# swicth partitions
|
||||
p.set_active(0)
|
||||
|
@ -526,10 +526,10 @@ class Partition_wizard_UI
|
|||
|
||||
var usage_str = "unknown"
|
||||
var used = slot.get_image_size()
|
||||
if (used >= 0) && (used <= slot.size)
|
||||
usage_str = string.format("used %i%%", ((used / 1024) * 100) / (slot.size / 1024))
|
||||
if (used >= 0) && (used <= slot.sz)
|
||||
usage_str = string.format("used %i%%", ((used / 1024) * 100) / (slot.sz / 1024))
|
||||
end
|
||||
var title = string.format("%ssubtype:%s offset:0x%06X size:0x%06X", current_boot_partition ? "booted " : "", slot.subtype_to_string(), slot.start, slot.size)
|
||||
var title = string.format("%ssubtype:%s offset:0x%06X size:0x%06X", current_boot_partition ? "booted " : "", slot.subtype_to_string(), slot.start, slot.sz)
|
||||
var col_before = ""
|
||||
var col_after = ""
|
||||
if current_boot_partition
|
||||
|
@ -538,11 +538,11 @@ class Partition_wizard_UI
|
|||
end
|
||||
# webserver.content_send(string.format("<p><b>%s</b> [%s]: %i KB (%s)</p>", slot.label, slot.subtype_to_string(), slot.size / 1024, usage_str))
|
||||
webserver.content_send(string.format("<tr><td title='%s'><b>%s%s%s</b>: </td><td align='right'> %i KB </td><td> (%s)</td></tr>",
|
||||
title, col_before, slot.label, col_after, slot.size / 1024, usage_str))
|
||||
title, col_before, slot.label, col_after, slot.sz / 1024, usage_str))
|
||||
elif slot.is_spiffs()
|
||||
# spiffs partition
|
||||
var title = string.format("subtype:%s offset:0x%06X size:0x%06X", slot.subtype_to_string(), slot.start, slot.size)
|
||||
webserver.content_send(string.format("<tr><td title='%s'><b>fs</b>: </td><td align='right'> %i KB</td></tr>", title, slot.size / 1024))
|
||||
var title = string.format("subtype:%s offset:0x%06X size:0x%06X", slot.subtype_to_string(), slot.start, slot.sz)
|
||||
webserver.content_send(string.format("<tr><td title='%s'><b>fs</b>: </td><td align='right'> %i KB</td></tr>", title, slot.sz / 1024))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -550,7 +550,7 @@ class Partition_wizard_UI
|
|||
if unallocated > 0
|
||||
var last_slot = p.slots[-1]
|
||||
# verify that last slot is file-system
|
||||
var partition_end_k = (last_slot.start + last_slot.size) / 1024 # last kb used for fs
|
||||
var partition_end_k = (last_slot.start + last_slot.sz) / 1024 # last kb used for fs
|
||||
webserver.content_send(string.format("<tr><td title='offset:0x%06X size:0x%06X'><free>: </td><td align='right'> %i KB</td></tr>",
|
||||
partition_end_k * 1024, unallocated * 1024, unallocated))
|
||||
end
|
||||
|
@ -621,7 +621,7 @@ class Partition_wizard_UI
|
|||
|
||||
# since unallocated succeeded, we know the last slot is FS
|
||||
var fs_slot = p.slots[-1]
|
||||
fs_slot.size += unallocated * 1024
|
||||
fs_slot.sz += unallocated * 1024
|
||||
p.save()
|
||||
p.invalidate_spiffs() # erase SPIFFS or data is corrupt
|
||||
|
||||
|
@ -649,12 +649,12 @@ class Partition_wizard_UI
|
|||
|
||||
# apply the change
|
||||
# shrink last OTA App
|
||||
var delta = (fs_target * 1024) - fs.size
|
||||
last_app.size -= delta
|
||||
var delta = (fs_target * 1024) - fs.sz
|
||||
last_app.sz -= delta
|
||||
|
||||
# move fs
|
||||
fs.start -= delta
|
||||
fs.size += delta
|
||||
fs.sz += delta
|
||||
p.save()
|
||||
p.invalidate_spiffs()
|
||||
|
||||
|
|
Loading…
Reference in New Issue