Devicetree error:

local NET_STATE = ‘system.aleos.cellular.state’
print(NET_STATE)
local ok, msg = pcall(function()
local result = devicetree.init()
print(result)
end
)
print(ok)
print(msg)

local ok1, msg1 = pcall(function()
local networkState = devicetree.get(NET_STATE)

print(‘msg:’…networkState)
end

)

print (ok1)
print(msg1)

–[[print “main started” to the console everytime main runs]]–
print(“main started”)

–[[ The above code issues the following console output]]–
system.aleos.cellular.state
table: 0x19479f8
true
nil
false
attempt to yield across metamethod/C-call boundary
main started

WHY AM I RECIEVING “attempt to yield across metamethod/C-call boundary” error?
I am running this code on Aleos application framework 4.5.2 on a raven rv50. The devicetree seems to initialize, what would possibly stop a get call to a valid devicetree address?

Thank you,

MJMurton

devicetree API internally uses sockets and thus ‘yield’ (i.e. block), when waiting for data on the socket (until the data arrives). In Lua 5.1 there is a limitation that is you cannot yield across a C method. pcall is a C method (Lua API implemented in C).
For this reason an yield compatible pcall is provided.

In your code please do
require ‘coxpcall’

then replace pcall() by copcall() (same prototype)

More info on this here: keplerproject.github.io/coxpcall/