ymodem - ymodem Agreement#
Adapted Air780E Air780EP
Note
This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!
Example
-- The purpose of this library is to receive data. If you need to send files, it is recommended to use xmodem library.
local handler = ymodem.create("/")
uart.setup(1, 115200)
uart.on(1, "receive", function(id, len)
while 1 do
local data = uart.read(id, 512)
if not data or #data == 0 then
break
end
ymodem.receive(handler, data)
end
end)
ymodem.create(dir_path,file_path)#
Create a ymodem handle
Parameters
Incoming Value Type |
Explanation |
---|---|
string |
Saved folder path, default is”/” |
string |
The absolute file path to be forcibly saved. The default is empty. If set, it will be saved directly in the file. |
Return Value
return value type |
explanation |
---|---|
boolean |
Success true, failure false |
Examples
local handler = ymodem.create("/")
ymodem.receive(handler, data)#
ymodem Receive file data and save
Parameters
Incoming Value Type |
Explanation |
---|---|
userdata |
ymodem Processing Handle |
zbuff/string |
Data entered |
Return Value
return value type |
explanation |
---|---|
boolean |
Success true, failure false |
int |
ack value, which needs to be returned to the sender through serial port/network, etc. |
int |
flag value, you need to return the value to the sender through the serial port/network, etc. If there is an ack value, you do not send it.flag |
boolean, |
A file is received to complete true, in transit false |
boolean, |
Entire transfer completed true otherwise false |
Examples
-- Note that the data source is not limited, usually uart.read data
no_error,ack,flag,file_done,all_done = ymodem.receive(handler, data)
ymodem.reset(handler)#
Reset ymodem processing
Parameters
Incoming Value Type |
Explanation |
---|---|
userdata |
ymodem Processing Handle |
Return Value
None
Examples
-- Restore to the initial state, generally used to reset after receiving errors, so that the next reception
ymodem.reset(handler)
ymodem.release(handler)#
Release ymodem handle
Parameters
Incoming Value Type |
Explanation |
---|---|
userdata |
handler |
Return Value
None
Examples
ymodem.release(handler)