Skip to content

Lua API 全集与机型可用性 ​

本页列出固件与模拟器运行期真的能被调用的全部 Lua 模块与函数:50 个模块、412 个函数、230 个常量。

本页随固件与模拟器版本同步更新,与文档正文有出入时以本页为准 —— 本页只写"有没有、叫什么、在哪个机型能用",参数细节和用法请看各模块页。

  • 两种调用形态不要混用:plc.get(...)、timer.start(...) 这类是库级函数,直接点出来调用;pipe.setup(...)、com.setup(...)、bacnet.creat(...) 这类先拿回一个对象,再用冒号调用它的方法(p:read_u16(...)、node:add_element(...)),冒号调用不用自己把对象当第一个参数传进去。websocketserver 是个例外:它只提供 creat(),没有对象方法。

怎么读这张表 ​

  • 本页只回答三件事:这个函数有没有、叫什么、在哪些机型上能用。参数怎么填、返回什么,看"详解"列指向的模块页。
  • 「签名怎么读」:括号内按顺序列全参数,方括号里的可以省略(不传就走默认值)—— com.setup(com_num, [baud, parity, databits, stopbits]) 是最小调用 1 个参数、后面 4 个可省;... 表示还可继续传同类参数。个别函数标注为 … 表示参数构成待核对,请以「典型调用」列与模块页为准。
  • 机型 一栏只写"哪里有"。同一个库在 ESP32 机型与软 PLC 模拟器上的可用集合并不相同,个别协议栈只在 ESP32-S3 上编译(该栏会写明)。
  • 「典型调用」 是该函数标准写法的示例,可直接照抄起步;— 表示暂无示例写法。
  • 「详解」列 指向写有该函数成套参数与返回值说明的模块页;— 表示说明散落在库页各处,从函数名搜索即可找到。

必载与系统 ​

plc ​

共 61 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:plc.BITE、plc.CLOUD_AUTO、plc.CLOUD_DOWN、plc.CLOUD_UP、plc.COMPUTE、plc.FLOAT、plc.PUBLISH、plc.S16、plc.S32、plc.SUBSCRIBE

库级函数典型调用详解
plc.aes_decode(encrypted_string)—有说明
plc.aes_encode(string)—有说明
plc.AI(…)—有说明
plc.ap_gateway(integer, ...)—有说明
plc.ap_ip(integer, ...)—有说明
plc.ap_mask(integer, ...)—有说明
plc.ap_password(string, ...)—有说明
plc.ap_ssid(string, ...)—有说明
plc.base64_decode(encoded_string)—有说明
plc.base64_encode(string)—有说明
plc.bite(data, bit_position)—有说明
plc.cloud_bind(bind_table)—有说明
plc.cloud_compute(json_string)—有说明
plc.cloud_publish(...)—有说明
plc.cloud_reg(message_type, callback_function)—有说明
plc.cloud_status(…)—有说明
plc.cloud_subscribe(...)—有说明
plc.cn(integer, ...)—有说明
plc.cs(integer, ...)—有说明
plc.d(integer, integer, ...)—有说明
plc.dd(address)—有说明
plc.df(integer, ...)—有说明
plc.ds(integer, ...)—有说明
plc.dsd(integer, ...)—有说明
plc.dsf(integer, ...)—有说明
plc.dstr(integer, ...)—有说明
plc.eth_dhcp(integer, ...)—有说明
plc.eth_gateway(integer, ...)—有说明
plc.eth_ip(integer, ...)—有说明
plc.eth_mask(integer, ...)—有说明
plc.get(string, integer, integer, integer)—有说明
plc.kv_get—有说明
plc.kv_set—有说明
plc.led(mode)—有说明
plc.lua_password(password_string)—有说明
plc.m(integer, ...)—有说明
plc.ms(integer, ...)—有说明
plc.plc_name—有说明
plc.plc_password(password_string)—有说明
plc.put(string, integer, integer, integer)—有说明
plc.r(address)—有说明
plc.rd(address)—有说明
plc.recv_sms()——
plc.rf(address)—有说明
plc.rstr(address)—有说明
plc.rtc_set(integer, integer, integer, integer, integer, integer, ...)—有说明
plc.s(integer, ...)—有说明
plc.send_sms(phone_number, message)——
plc.sms_recv()—有说明
plc.sms_send(phone_number, message)—有说明
plc.sta_autochn—有说明
plc.sta_dhcp(integer, ...)—有说明
plc.sta_gateway(integer, ...)—有说明
plc.sta_ip(integer, ...)—有说明
plc.sta_mask(integer, ...)—有说明
plc.sta_password(string, ...)—有说明
plc.sta_ssid(string, ...)—有说明
plc.tn(integer, ...)—有说明
plc.ts(integer, ...)—有说明
plc.x(integer, ...)—有说明
plc.y(integer, ...)—有说明

system ​

共 6 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
system.fs_exists(string)—有说明
system.fs_info(…)—有说明
system.fs_list(string)—有说明
system.restart(…)—有说明
system.sleep(integer, ...)—有说明
system.start_thread(...)—有说明

timer ​

共 2 个库级函数 + 1 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
timer.start(ms, callback, [once])—有说明
timer.stop()—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:stop()—有说明

data ​

共 4 个库级函数 + 4 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
data.creat([value])—有说明
data.get_bool()—有说明
data.get_num()—有说明
data.get_string()—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:get_bool()—有说明
h:get_num()—有说明
h:get_string()—有说明
h:set(value)——

task ​

共 3 个库级函数 · 可用范围:ESP32 机型 · 4G 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
task.start(function, ...)task.start(function() while true do system.sleep(200) end end)后台任务
task.stop(integer)task.stop(tid)后台任务
task.list()task.list()后台任务

event ​

共 6 个库级函数 · 可用范围:ESP32 机型 · 4G 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
event.on(string, key, function, [boolean])event.on("cloud", "*", cb, true)事件订阅与发布
event.wait(string, key, [number])event.wait("net", "*", 5000)事件订阅与发布
event.off(integer)event.off(h)事件订阅与发布
event.emit(string, [number, number, number])event.emit("go", 0, 1, 2)事件订阅与发布
event.gather(string, [number])event.gather("frame", 5000)事件订阅与发布
event.done(string)event.done("frame")事件订阅与发布

串口与采集协议 ​

com ​

共 11 个库级函数 + 10 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:com.EVEN、com.NONE、com.ODD

库级函数典型调用详解
com.add_device(sub_device)—有说明
com.close()—有说明
com.print(com_device, dataN, ...)—有说明
com.recv()—有说明
com.reg(callback)—有说明
com.send(com_device, dataN, ...)—有说明
com.set_time_lunxun(timeout_ms)—有说明
com.set_timeout(timeout_ms)—有说明
com.set_transparent(transparent_device)—有说明
com.setup(com_num, [baud, parity, databits, stopbits])—有说明
com.start()—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:add_device(sub_device)—有说明
h:close()—有说明
h:print(com_device, dataN, ...)—有说明
h:recv()—有说明
h:reg(callback)—有说明
h:send(com_device, dataN, ...)—有说明
h:set_time_lunxun(timeout_ms)—有说明
h:set_timeout(timeout_ms)—有说明
h:set_transparent(transparent_device)—有说明
h:start()—有说明

com_modbus ​

共 8 个库级函数 + 7 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:com_modbus.AB、com_modbus.ABCD、com_modbus.ABCDEFGH、com_modbus.ASCII、com_modbus.BA、com_modbus.BADC、com_modbus.BADCFEHG、com_modbus.BITE、com_modbus.CDAB、com_modbus.DCBA、com_modbus.DOUBLE、com_modbus.FLOAT、com_modbus.GHEFCDAB、com_modbus.HGFEDCBA、com_modbus.READ、com_modbus.READ_WRITE、com_modbus.RTU、com_modbus.S16、com_modbus.S32、com_modbus.U16、com_modbus.U32、com_modbus.WRITE

库级函数典型调用详解
com_modbus.add_channel(modbus_type, modbus_addr, data_mode, data_var, read_write)—有说明
com_modbus.creat(work_mode, device_addr, [data_state])—有说明
com_modbus.set_16_ab(encode)—有说明
com_modbus.set_32_abcd(encode)—有说明
com_modbus.set_double_abcdefgh(encode)—有说明
com_modbus.set_float_abcd(encode)—有说明
com_modbus.set_time_error(ms)—有说明
com_modbus.set_time_recv(ms)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:add_channel(modbus_type, modbus_addr, data_mode, data_var, read_write)—有说明
h:set_16_ab(encode)—有说明
h:set_32_abcd(encode)—有说明
h:set_double_abcdefgh(encode)—有说明
h:set_float_abcd(encode)—有说明
h:set_time_error(ms)—有说明
h:set_time_recv(ms)—有说明

com_fx ​

共 4 个库级函数 + 3 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:com_fx.AB、com_fx.ABCD、com_fx.ASCII、com_fx.BA、com_fx.BADC、com_fx.BITE、com_fx.CDAB、com_fx.DCBA、com_fx.FLOAT、com_fx.READ、com_fx.READ_WRITE、com_fx.RTU、com_fx.S16、com_fx.S32、com_fx.U16、com_fx.U32

库级函数典型调用详解
com_fx.add_channel(string, integer, integer, integer)—有说明
com_fx.creat([data_state])—有说明
com_fx.set_time_error(ms)—有说明
com_fx.set_time_recv(ms)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:add_channel(string, integer, integer, integer)—有说明
h:set_time_error(ms)—有说明
h:set_time_recv(ms)—有说明

com_dlt645 ​

共 4 个库级函数 + 3 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:com_dlt645.A_A_1997、com_dlt645.A_A_2007、com_dlt645.A_B_1997、com_dlt645.A_B_2007、com_dlt645.A_C_1997、com_dlt645.A_C_2007、com_dlt645.COS_1997、com_dlt645.COS_2007、com_dlt645.KWH_1997、com_dlt645.KWH_2007、com_dlt645.KW_1997、com_dlt645.KW_2007、com_dlt645.KW_MAX_1997、com_dlt645.KW_M_TIME1_1997、com_dlt645.KW_M_TIME1_2007、com_dlt645.KW_M_TIME2_1997、com_dlt645.KW_M_TIME2_2007、com_dlt645.KW_M_TIME3_1997、com_dlt645.KW_M_TIME3_2007、com_dlt645.KW_M_TIME4_1997、com_dlt645.KW_M_TIME4_2007、com_dlt645.KW_TIME1_1997、com_dlt645.KW_TIME1_2007、com_dlt645.KW_TIME2_1997、com_dlt645.KW_TIME2_2007、com_dlt645.KW_TIME3_1997、com_dlt645.KW_TIME3_2007、com_dlt645.KW_TIME4_1997、com_dlt645.KW_TIME4_2007、com_dlt645.V_A_1997、com_dlt645.V_A_2007、com_dlt645.V_B_1997、com_dlt645.V_B_2007、com_dlt645.V_C_1997、com_dlt645.V_C_2007

库级函数典型调用详解
com_dlt645.add_channel(channel_id, data_var)—有说明
com_dlt645.creat(meter_number, [data_state])—有说明
com_dlt645.set_time_error(ms)—有说明
com_dlt645.set_time_recv(ms)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:add_channel(channel_id, data_var)—有说明
h:set_time_error(ms)—有说明
h:set_time_recv(ms)—有说明

modbus ​

共 12 个库级函数 + 11 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:modbus.AB、modbus.ABCD、modbus.ABCDEFGH、modbus.BA、modbus.BADC、modbus.BADCFEHG、modbus.BITE、modbus.CDAB、modbus.DCBA、modbus.DOUBLE、modbus.FLOAT、modbus.GHEFCDAB、modbus.HGFEDCBA、modbus.READ、modbus.READ_WRITE、modbus.S16、modbus.S32、modbus.U16、modbus.U32

库级函数典型调用详解
modbus.add_channel(device_addr, modbus_addr, data_mode, data_var, read_write)—有说明
modbus.close()—有说明
modbus.creat(ip, port)—有说明
modbus.set_16_ab(encode)—有说明
modbus.set_32_abcd(encode)—有说明
modbus.set_double_abcdefgh(encode)—有说明
modbus.set_float_abcd(encode)—有说明
modbus.set_time_error(ms)—有说明
modbus.set_time_lunxun(ms)—有说明
modbus.set_time_recv(ms)—有说明
modbus.set_time_relink(ms)—有说明
modbus.start()—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:add_channel(device_addr, modbus_addr, data_mode, data_var, read_write)—有说明
h:close()—有说明
h:set_16_ab(encode)—有说明
h:set_32_abcd(encode)—有说明
h:set_double_abcdefgh(encode)—有说明
h:set_float_abcd(encode)—有说明
h:set_time_error(ms)—有说明
h:set_time_lunxun(ms)—有说明
h:set_time_recv(ms)—有说明
h:set_time_relink(ms)—有说明
h:start()—有说明

pipe ​

共 1 个库级函数 + 18 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
pipe.setup(…)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:read(…)——
h:read_bite(…)——
h:read_double(…)——
h:read_float(…)——
h:read_s16(…)——
h:read_s32(…)——
h:read_string(…)——
h:read_u16(…)——
h:read_u32(…)——
h:write(…)——
h:write_bite(…)——
h:write_double(…)——
h:write_float(…)——
h:write_s16(…)——
h:write_s32(…)——
h:write_string(…)——
h:write_u16(…)——
h:write_u32(…)——

网络 ​

net ​

共 24 个库级函数 + 14 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
net.accept(…)—有说明
net.bind(…)—有说明
net.close(…)—有说明
net.connect(…)—有说明
net.errstr(…)—有说明
net.get_ntp_time_async(string)—有说明
net.getoption(…)—有说明
net.listen(…)—有说明
net.localip(…)—有说明
net.lookup(…)—有说明
net.packip(…)—有说明
net.peer(…)—有说明
net.ping(string, ...)—有说明
net.ping_stats(…)—有说明
net.recv(…)—有说明
net.recvfrom(…)—有说明
net.select(...)—有说明
net.send(…)—有说明
net.sendto(…)—有说明
net.setoption(...)—有说明
net.shutdown(…)—有说明
net.socket(…)—有说明
net.sockname(…)—有说明
net.unpackip(…)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:accept(…)—有说明
h:bind(…)—有说明
h:close(…)—有说明
h:connect(…)—有说明
h:getoption(…)—有说明
h:listen(…)—有说明
h:peer(…)—有说明
h:recv(…)—有说明
h:recvfrom(…)—有说明
h:send(…)—有说明
h:sendto(…)—有说明
h:setoption(...)—有说明
h:shutdown(…)—有说明
h:sockname(…)—有说明

tcp_client ​

共 8 个库级函数 + 7 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:tcp_client.CONNECTED、tcp_client.DISCONNECTED、tcp_client.RECVDATA

库级函数典型调用详解
tcp_client.close(…)—有说明
tcp_client.creat(string, integer, string, ...)—有说明
tcp_client.is_linked(…)—有说明
tcp_client.reg(integer)—有说明
tcp_client.send(…)—有说明
tcp_client.set_timeout(integer)—有说明
tcp_client.set_transparent(…)—有说明
tcp_client.start(…)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:close(…)—有说明
h:is_linked(…)—有说明
h:reg(integer)—有说明
h:send(…)—有说明
h:set_timeout(integer)—有说明
h:set_transparent(…)—有说明
h:start(…)—有说明

tcp_server ​

共 5 个库级函数 + 4 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:tcp_server.CONNECTED、tcp_server.DISCONNECTED、tcp_server.RECVDATA

库级函数典型调用详解
tcp_server.close(integer)—有说明
tcp_server.creat(integer, integer, integer, ...)—有说明
tcp_server.reg(integer)—有说明
tcp_server.send(integer)—有说明
tcp_server.start(…)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:close(integer)—有说明
h:reg(integer)—有说明
h:send(integer)—有说明
h:start(…)—有说明

udp ​

共 4 个库级函数 + 3 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:udp.RECVDATA

库级函数典型调用详解
udp.creat(port, ip)—有说明
udp.reg(msg_type, callback)—有说明
udp.send(ip, port, data)—有说明
udp.start()—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:reg(msg_type, callback)—有说明
h:send(ip, port, data)—有说明
h:start()—有说明

http ​

共 6 个库级函数 + 5 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
http.add_head(string, string)client:add_head(name, value)有说明
http.creat(string, string, ...)—有说明
http.get(string, string, ...)—有说明
http.get_asy(string, string, ...)—有说明
http.post(string, string, ...)—有说明
http.post_asy(string, string, ...)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:add_head(string, string)client:add_head(name, value)有说明
h:get(string, string, ...)—有说明
h:get_asy(string, string, ...)—有说明
h:post(string, string, ...)—有说明
h:post_asy(string, string, ...)—有说明

mqtt ​

共 10 个库级函数 + 9 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:mqtt.CONNECTED、mqtt.DISCONNECTED、mqtt.PUBLISHED、mqtt.RECVDATA、mqtt.SUBSCRIBED、mqtt.UNSUBSCRIBED

库级函数典型调用详解
mqtt.creat(url, port, client_id, username, password)—有说明
mqtt.is_linked()—有说明
mqtt.publish(topic, payload, [qos, retain])—有说明
mqtt.reg(msg_type, callback)—有说明
mqtt.set_cleansession(cleansession)—有说明
mqtt.set_keepalive(keepalive)—有说明
mqtt.set_version(version)—有说明
mqtt.start()—有说明
mqtt.subscribe(client, topicN, ...)—有说明
mqtt.unsubscribe(client, topicN, ...)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:is_linked()—有说明
h:publish(topic, payload, [qos, retain])—有说明
h:reg(msg_type, callback)—有说明
h:set_cleansession(cleansession)—有说明
h:set_keepalive(keepalive)—有说明
h:set_version(version)—有说明
h:start()—有说明
h:subscribe(client, topicN, ...)—有说明
h:unsubscribe(client, topicN, ...)—有说明

websocketserver ​

共 1 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
websocketserver.creat([port])—有说明

json ​

共 2 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:json.new、json.null

库级函数典型调用详解
json.decode(…)—有说明
json.encode(…)—有说明

工业协议服务端 ​

mc_server ​

共 1 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
mc_server.start([port, max_sockets, buffer_size])—有说明

modbus_tcp_server ​

共 1 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
modbus_tcp_server.start([port, max_sockets, buffer_size])—有说明

bacnet ​

共 1 个库级函数 + 15 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机(ESP32-S3 机型;经典 ESP32 未编译此协议栈)

常量:bacnet.BITE、bacnet.DOUBLE、bacnet.ENUM、bacnet.ERROR、bacnet.FLOAT、bacnet.OFFLINE、bacnet.ONLINE、bacnet.READ、bacnet.READ_WRITE、bacnet.S16、bacnet.S32、bacnet.U16、bacnet.U32、bacnet.WRITE

库级函数典型调用详解
bacnet.creat(…)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:add_object(string, integer)add_object(addr, mode, var, access, [name, opt])—
h:add_poll(string, integer)add_poll(mac, addr, mode, var, [opt])—
h:close(…)——
h:del_object(string)del_object(addr)—
h:del_poll(string)del_poll(mac, addr)—
h:is_online(…)——
h:object_list(...)object_list(dest, [device_instance, max])—
h:read(string, ...)read(mac, addr | {addr,...}, [count])—
h:read_prop(string, integer)read_prop(mac, addr, prop_id)—
h:reg(integer)reg(event, callback)—
h:release(string)release(mac, addr, [priority])—
h:start(…)——
h:stat(…)stat()—
h:who_is(…)who_is()—
h:write(string, number)write(mac, addr, value, [priority])—

opcua ​

共 1 个库级函数 + 14 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机(ESP32-S3 机型;经典 ESP32 未编译此协议栈)

常量:opcua.BITE、opcua.BOOLEAN、opcua.CHANGE、opcua.DOUBLE、opcua.ERROR、opcua.FLOAT、opcua.OFFLINE、opcua.ONLINE、opcua.READ、opcua.READ_WRITE、opcua.S16、opcua.S32、opcua.SEC_NONE、opcua.SEC_SIGN、opcua.SEC_SIGNENC、opcua.SESSION、opcua.STRING、opcua.U16、opcua.U32、opcua.WRITE、opcua.WRITE_ONLY

库级函数典型调用详解
opcua.creat(…)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:add_folder(string)add_folder(id, [name])—
h:add_node(string, integer)add_node(id, mode, var, [access, name, opt])—
h:add_poll(string, integer)add_poll(addr, mode, var, [opt])—
h:browse(...)browse([id, max])—
h:close(…)——
h:del_node(string)del_node(id)—
h:del_poll(string)del_poll(addr)—
h:is_online(…)——
h:read(string, ...)read(addr | {addr,...}, [mode])—
h:reg(integer)reg(event, callback)—
h:session_list(…)session_list()—
h:start(…)——
h:stat(…)stat()—
h:write(string, number)write(addr, value, [mode])—

water ​

共 1 个库级函数 + 11 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机(ESP32-S3 机型;经典 ESP32 未编译此协议栈)

常量:water.BACKFILL、water.BIT、water.CENTER_OFFLINE、water.CENTER_ONLINE、water.CLK_COARSE、water.CLK_NONE、water.CLK_SYNCED、water.CLOCK_BAD、water.CLOCK_SYNCED、water.CMD、water.DWORD、water.FLOAT、water.MODE_HOUR、water.MODE_INTERVAL、water.MODE_PERIOD、water.REPORT_DONE、water.SL427_2008、water.SL427_2021、water.STORE_FULL、water.SZY206_2016、water.TCP、water.UDP、water.WORD

库级函数典型调用详解
water.creat(...)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:add_alarm(string)add_alarm(code, {high=,low=,mode=,deadband=,min_gap=})—
h:add_center(…)——
h:add_element(string)add_element(code, {reg=,type=,scale=,offset=,invalid=})—
h:close(…)——
h:is_online(…)——
h:preview(…)preview([kind])—
h:reg(…)reg(event, callback)—
h:report_now(…)——
h:start(…)——
h:stat(…)stat()—
h:sync_time(…)——

算法与工具 ​

pid ​

共 7 个库级函数 + 6 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
pid.at_start(callback)—有说明
pid.at_stop()—有说明
pid.creat([kp, ki, kd, ms, outmax, outmin])—有说明
pid.get_out()—有说明
pid.loop(input)—有说明
pid.set_in(input)—有说明
pid.set_set(setpoint)—有说明

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:at_start(callback)—有说明
h:at_stop()—有说明
h:get_out()—有说明
h:loop(input)—有说明
h:set_in(input)—有说明
h:set_set(setpoint)—有说明

encoder ​

共 6 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
encoder.from16hex(input_string)—有说明
encoder.frombase64—有说明
encoder.fromhex—有说明
encoder.to16hex(input_string)—有说明
encoder.tobase64—有说明
encoder.tohex—有说明

crypto ​

共 9 个库级函数 · 可用范围:ESP32 机型

常量:crypto.MODE_CBC、crypto.MODE_CTR、crypto.MODE_ECB、crypto.MODE_GCM

库级函数典型调用详解
crypto.aes_cbc_decrypt(…)—有说明
crypto.aes_cbc_encrypt(…)—有说明
crypto.aes_ctr(…)—有说明
crypto.aes_ecb_decrypt(…)—有说明
crypto.aes_ecb_encrypt(…)—有说明
crypto.base64_decode(…)—有说明
crypto.base64_encode(…)—有说明
crypto.md5(…)—有说明
crypto.random_bytes(integer)—有说明

fdb ​

共 7 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
fdb.kv_del(string)—有说明
fdb.kv_get(string)—有说明
fdb.kv_iter(…)—有说明
fdb.kv_next(…)—有说明
fdb.kv_set(string, integer)—有说明
fdb.ts_add(integer)—有说明
fdb.ts_select(integer, integer)—有说明

ini ​

共 11 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
ini.delete(section, [key, delete_section_if_empty])—有说明
ini.get_all_keys(section)—有说明
ini.get_all_sections()—有说明
ini.get_all_values(section, key)—有说明
ini.get_value(section, key, [default_value, has_multi])—有说明
ini.load_data(data)—有说明
ini.load_file(filename)—有说明
ini.new()—有说明
ini.save()—有说明
ini.save_file(filename)—有说明
ini.set_value(section, key, value)—有说明

dog ​

共 1 个库级函数 + 9 个对象方法 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
dog.new()——

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:feed()——
h:get_name()——
h:get_remaining_time()——
h:get_timeout()——
h:init(name, timeout_ms, [auto_start])——
h:is_active()——
h:set_timeout(timeout_ms)——
h:start()——
h:stop()——

模拟器 / 上位机专有 ​

com2 ​

共 8 个库级函数 · 可用范围:软 PLC 模拟器 / 上位机

常量:com2.R、com2.RW、com2.W

库级函数典型调用详解
com2.get(string)——
com2.mock(string)——
com2.set(string, number)——
com2.start(integer, ...)——
com2.stats(…)——
com2.stop(…)——
com2.tag(string)——
com2.tick(integer)——

com2_modbus ​

共 2 个库级函数 · 可用范围:软 PLC 模拟器 / 上位机

常量:com2_modbus.AREA_0X、com2_modbus.AREA_1X、com2_modbus.AREA_3X、com2_modbus.AREA_4X、com2_modbus.ASCII、com2_modbus.BIT、com2_modbus.F32、com2_modbus.F64、com2_modbus.RTU、com2_modbus.S16、com2_modbus.S32、com2_modbus.TCP、com2_modbus.U16、com2_modbus.U32

库级函数典型调用详解
com2_modbus.master(…)——
com2_modbus.slave(…)——

com2_fx ​

共 1 个库级函数 · 可用范围:软 PLC 模拟器 / 上位机

常量:com2_fx.BIT、com2_fx.F32、com2_fx.S16、com2_fx.S32、com2_fx.U16、com2_fx.U32

库级函数典型调用详解
com2_fx.create(…)——

com2_dlt645 ​

共 1 个库级函数 · 可用范围:软 PLC 模拟器 / 上位机

常量:com2_dlt645.IA、com2_dlt645.IB、com2_dlt645.IC、com2_dlt645.KWH_TOTAL、com2_dlt645.PF、com2_dlt645.POWER、com2_dlt645.SWITCH_CMD、com2_dlt645.SWITCH_STATE、com2_dlt645.UA、com2_dlt645.UB、com2_dlt645.UC

库级函数典型调用详解
com2_dlt645.create(…)——

thread ​

共 6 个库级函数 + 2 个对象方法 · 可用范围:软 PLC 模拟器 / 上位机

库级函数典型调用详解
thread.createmutex([recursive])——
thread.resume(thread_id)——
thread.self()——
thread.start(func, [stack_size, priority, name])——
thread.stop(thread_id)——
thread.suspend(thread_id)——

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:lock()——
h:unlock()——

pahomqtt ​

共 1 个库级函数 + 5 个对象方法 · 可用范围:软 PLC 模拟器 / 上位机

常量:pahomqtt.PERSISTENCE_FILE、pahomqtt.PERSISTENCE_NONE、pahomqtt.PERSISTENCE_USER、pahomqtt.QOS0、pahomqtt.QOS1、pahomqtt.QOS2

库级函数典型调用详解
pahomqtt.client(string, string, integer)——

对象方法(先由库级函数拿到句柄,再冒号调用 h:m(...),不是 m:x(...)):

对象方法典型调用详解
h:connect(…)——
h:disconnect(…)——
h:is_connected(…)——
h:publish(string)——
h:subscribe(string, integer)——

xml ​

共 4 个库级函数 · 可用范围:软 PLC 模拟器 / 上位机

库级函数典型调用详解
xml.encode(...)——
xml.eval(...)——
xml.load(string)——
xml.registerCode(string, string)——

miniz ​

共 2 个库级函数 · 可用范围:软 PLC 模拟器 / 上位机

库级函数典型调用详解
miniz.compress(…)——
miniz.uncompress(…)——

Lua 5.4 标准库 ​

base ​

共 24 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
base._VERSION——
base.assert(...)——
base.collectgarbage(…)——
base.dofile(…)——
base.error(…)——
base.getmetatable(...)——
base.ipairs(...)——
base.load(…)——
base.loadfile(…)——
base.next(…)——
base.pairs(...)——
base.pcall(...)——
base.print(...)——
base.rawequal(...)——
base.rawget(...)——
base.rawlen(…)——
base.rawset(...)——
base.select(integer, ...)——
base.setmetatable(…)——
base.tonumber(...)——
base.tostring(...)——
base.type(…)——
base.warn(string, ...)——
base.xpcall(...)——

string ​

共 19 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
string.byte(…)—有说明
string.char(...)—有说明
string.dump(…)——
string.find(…)—有说明
string.format(...)—有说明
string.fromhex(…)—有说明
string.gmatch(…)—有说明
string.gsub(…)—有说明
string.len(…)—有说明
string.lower(…)—有说明
string.match(…)—有说明
string.pack(string)——
string.packsize(string)——
string.rep(integer)—有说明
string.reverse(…)—有说明
string.sub(integer)—有说明
string.tohex(…)—有说明
string.unpack(string)——
string.upper(…)—有说明

table ​

共 8 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
table.concat(…)—有说明
table.create(integer)——
table.insert(integer, ...)—有说明
table.move(integer, integer, integer)—有说明
table.pack(...)—有说明
table.remove(…)—有说明
table.sort(…)—有说明
table.unpack(…)—有说明

math ​

共 35 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:math.huge、math.maxinteger、math.mininteger、math.pi

库级函数典型调用详解
math.abs(number)—有说明
math.acos(number)—有说明
math.asin(number)—有说明
math.atan(number)—有说明
math.atan2(number)—有说明
math.ceil(number)—有说明
math.cos(number)—有说明
math.cosh(number)——
math.deg(number)—有说明
math.exp(number)—有说明
math.floor(number)—有说明
math.fmod(number, number)—有说明
math.frexp(number)——
math.huge——
math.ldexp(number, integer)——
math.log(number, number)—有说明
math.log10(number)——
math.max(...)—有说明
math.maxinteger——
math.min(...)—有说明
math.mininteger——
math.modf(number)—有说明
math.pi——
math.pow(number, number)—有说明
math.rad(number)—有说明
math.random—有说明
math.randomseed—有说明
math.sin(number)—有说明
math.sinh(number)——
math.sqrt(number)—有说明
math.tan(number)—有说明
math.tanh(number)——
math.tointeger(...)——
math.type(...)——
math.ult(integer, integer)——

io ​

共 11 个库级函数 · 可用范围:软 PLC 模拟器 / 上位机

库级函数典型调用详解
io.close(…)—有说明
io.flush(…)—有说明
io.input(…)—有说明
io.lines(string)—有说明
io.open(string)—有说明
io.output(…)—有说明
io.popen(string)—有说明
io.read(…)—有说明
io.tmpfile(…)—有说明
io.type(...)—有说明
io.write(…)—有说明

os ​

共 11 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
os.clock(…)—有说明
os.date(…)—有说明
os.difftime(…)—有说明
os.execute(…)—有说明
os.exit(…)—有说明
os.getenv(string)—有说明
os.remove(string)—有说明
os.rename(string, string)—有说明
os.setlocale(…)——
os.time(…)—有说明
os.tmpname(…)—有说明

coroutine ​

共 8 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
coroutine.close(…)—有说明
coroutine.create(…)—有说明
coroutine.isyieldable(…)—有说明
coroutine.resume(...)—有说明
coroutine.running(…)—有说明
coroutine.status(…)—有说明
coroutine.wrap(…)—有说明
coroutine.yield(...)—有说明

utf8 ​

共 6 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:utf8.charpattern

库级函数典型调用详解
utf8.char(...)——
utf8.charpattern——
utf8.codepoint(…)——
utf8.codes(string)——
utf8.len(…)——
utf8.offset(integer)——

debug ​

共 17 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

库级函数典型调用详解
debug.debug(…)——
debug.gethook(…)——
debug.getinfo(…)——
debug.getlocal(…)——
debug.getmetatable(...)——
debug.getregistry(…)——
debug.getupvalue(…)——
debug.getuservalue(…)——
debug.setcstacklimit(integer)——
debug.sethook(…)——
debug.setlocal(…)——
debug.setmetatable(…)——
debug.setupvalue(...)——
debug.setuservalue(...)——
debug.traceback(…)——
debug.upvalueid(…)——
debug.upvaluejoin(…)——

package ​

共 8 个库级函数 · 可用范围:ESP32 机型 · 软 PLC 模拟器 / 上位机

常量:package.config、package.loaded、package.preload

库级函数典型调用详解
package.cpath——
package.loaded——
package.loadlib(string, string)——
package.path——
package.preload——
package.require(string)——
package.searchers——
package.searchpath(string, string)——

bit32 ​

共 12 个库级函数 · 可用范围:ESP32 机型

库级函数典型调用详解
bit32.arshift(integer)——
bit32.band(…)——
bit32.bnot(…)——
bit32.bor(...)——
bit32.btest(…)——
bit32.bxor(...)——
bit32.extract(…)——
bit32.lrotate(integer)——
bit32.lshift(integer)——
bit32.replace(…)——
bit32.rrotate(integer)——
bit32.rshift(integer)——

LPPLC 工业物联网云平台 · 软硬件与云平台全栈自研