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