←  Tutorials

ComputerCraft | Programmable Computers for Minecraft

»

[1.5+] In-depth Modem Channels Tutorial

theoriginalbit's Photo theoriginalbit 30 Jul 2013

View Postmakerimages, on 30 July 2013 - 03:47 AM, said:

Does the 128 channel limitation apply for a specific modem, a specific computer or the entire world?
Per modem. So if you have a computer with all 6 sides as modems you can have 768 channels open at any given point in time.
Quote

makerimages's Photo makerimages 30 Jul 2013

ok, thanks
Edit: a few pages back, there was a piece of code to listen on all open channels, i implemented that into this program:
term.clear()
local modem=peripheral.wrap("left")
local SiteLookup={}
local function listen()
  while true do
	    local evts = {os.pullEvent()}
	    if evts[1] == "timer" then
		   return
	    elseif evts[1] == "modem_message" then
		   print("Message: "..evts[4])
	    end
  end
end
local max = 65535
local large = 128
while true do
for i=1, max, large do
  for x=i, i+large do
	    modem.open(x)
  end
	    os.startTimer(2) --Listen for two seconds and then move on to the next range
	    listen()
  for x=1, i+large do
	    modem.close(x)
  end
end
end

it says that on line 21 ( the line with modem.open(x) ) there are too many open channels. how do I fix this?
Quote

Bubba's Photo Bubba 30 Jul 2013

View Postmakerimages, on 30 July 2013 - 04:43 AM, said:

-snip-

Look at your closing for loop:
  
for x=1, i+large do
   modem.close(x)
end

x=1 should be x=i
Quote

jesusthekiller's Photo jesusthekiller 30 Jul 2013

Just stumbled across this post, really nice tutorial :)
Quote

makerimages's Photo makerimages 31 Jul 2013

View PostBubba, on 30 July 2013 - 08:29 AM, said:

View Postmakerimages, on 30 July 2013 - 04:43 AM, said:

-snip-

Look at your closing for loop:
  
for x=1, i+large do
   modem.close(x)
end

x=1 should be x=i

that fixed nothing

term.clear()
local modem=peripheral.wrap("left")
local SiteLookup={}
local function listen()
  while true do
	    local evts = {os.pullEvent()}
	    if evts[1] == "timer" then
		   return
	    elseif evts[1] == "modem_message" then
		   print("Message: "..evts[4])
	    end
  end
end
local max = 65535
local large = 128
while true do
for i=1, max, large do
  for x=i, i+large do
	    modem.open(x)
  end
	    os.startTimer(2) --Listen for two seconds and then move on to the next range
	    listen()
  for x=i, i+large do
	    modem.close(x)
  end
end
end

same error (too many open channels) same line(modem.open(x))
Quote

Bubba's Photo Bubba 31 Jul 2013

View Postmakerimages, on 31 July 2013 - 03:45 AM, said:

same error (too many open channels) same line(modem.open(x))

Oops sorry. You should leave the correction there as it is a performance improvement, but it's not the issue. The issue is that you're adding i+large, which would actually be 129 channels instead of 128. Change it instead to i+large-1
Quote

tuocuggino's Photo tuocuggino 13 Aug 2013

hi guys,
i'm not able to understand where where is the error on this programs:

turtle with a gate reader:
modem = peripheral.wrap("right")
m = peripheral.wrap("left")
while true do
	    data = m.get()
	    modem.transmit(1,2,data)
	    count = 0
	    for i in pairs(data) do
			    if i ~= nil then
					    count = count + 1
			    end
	    end
	    print(count)
end

Computer:
modem = peripheral.wrap("top")
modem.open(1)
local event, modemSide, senderChannel, replyChannel,
message, senderDistance = os.pullEvent("modem_message")
for i,v in pairs(message) do
    print(i..":"..tostring(v))
end

the computer give me a error, it say something like " the variabile message must be a table"
Quote

PsychicMiner2025's Photo PsychicMiner2025 21 Apr 2016

View PostMudkipTheEpic, on 10 February 2013 - 04:54 AM, said:

Wow... Code for snooping on all channels...

modem = peripheral.wrap(modemside)
for i=0, 65535 do -- Or how ever many channels there are
modem.open(i)
end

Would this allow you to snoop on rednet.send messages?

Edit: Wait.. can you only listen on 1 channel?

You could have a huge array of computers with wireless modems, all connected by network cables to a drive. Then you could set each computer (even thought it would take a while) to listen on different channels, each listening to 128 channels. e.g. computer 1, 1-128, computer 2, 129-256 ect. Then when a modem receives a message it would write the send and reply channels, the modem side and dist and message and write it to a file on the networked disk drive. not very practical in survival mode since you would need about 12131 stone 1112 redstone 512 ender pearls or 32 stacks! 512 glass panes and around 135 hours of smelting the stone (in one furnace) so dont attempt in survival mode. im sure there's easier ways to do this and since wireless modems only have a max range of 381 blocks at max altitude this would only get a very small scan range but would be good in a populated area in a server. you always could have less or even one modem that is quickly switching between groups of channels but then theres the chance you could miss a message. you could build a box made of computers reducing the wire needs and decreasing the chance that a signal or a low channel that is only in range of the high channel end of a line gets missed. anyway because of the 256 max range of wires you would have to put computers on both sides of a half length wire if you made a long line. sorry for the long post. also this is my first post. far from a "hi i'm new"











and one floppy disk ;)
Quote

valithor's Photo valithor 23 Apr 2016

View PostPsychicMiner2025, on 21 April 2016 - 05:27 AM, said:

-snip

This is actually something that I have seen a few times on servers. The one improvement you can make to the system you described is having 5 wireless modems per computer instead of 1 (can open 128 channels per modem not computer), and 1 wired modem to connect to the drive. This would cut down on the costs.

edit:

Also welcome to the forums :D
Edited by valithor, 23 April 2016 - 01:12 AM.
Quote

MineRobber___T's Photo MineRobber___T 13 Nov 2016

I did some math. Guess how many modems you need in order to scan all channels at once?

The answer: 534.

My explanation:

Spoiler
Quote