Bugfixes in file transfer
This commit is contained in:
parent
4185f1fcc7
commit
cd77508c83
11
send_file
11
send_file
@ -1,5 +1,5 @@
|
||||
--import module
|
||||
dofile("utils")
|
||||
dofile("/git-scripts/utils")
|
||||
|
||||
local function printUsage()
|
||||
print("Usage:")
|
||||
@ -13,7 +13,7 @@ if #args < 2 then
|
||||
end
|
||||
|
||||
local filename = args[1]
|
||||
local file = fs.open(path, "r")
|
||||
local file = fs.open(filename, "r")
|
||||
if file == nil then
|
||||
print("Error: File not found")
|
||||
return
|
||||
@ -24,7 +24,7 @@ data.filename = filename
|
||||
data.content = content
|
||||
data = textutils.serialize(data) --convert to string
|
||||
file.close()
|
||||
local receiver = args[2]
|
||||
local receiver = tonumber(args[2])
|
||||
|
||||
--init rednet
|
||||
modemSide = utils.getSideOf("modem")
|
||||
@ -35,10 +35,9 @@ end
|
||||
rednet.open(modemSide)
|
||||
|
||||
print("Waiting for receiver...")
|
||||
id, msg, sth = rednet.receive("fileXfer")
|
||||
while id != receiver do
|
||||
repeat
|
||||
id, msg, sth = rednet.receive("fileRX") --keep waiting
|
||||
end
|
||||
until id == receiver
|
||||
|
||||
--receiver is online!
|
||||
rednet.send(id, data, "fileTX")
|
||||
|
Loading…
x
Reference in New Issue
Block a user