1111 posts
Location
Portland OR
Posted 26 February 2012 - 10:10 PM
Since the release of the modems I decided I would finally play around with rednet some.
When setting it up for the wireless modems I found that it was way to easy to use and I should have been using it sooner. It took me not time at all to get a fully functional script up and working.
I then decided that since rednet has been around since prior to the modems that the code should also work when connected to a redpower bundled cable… Ya not so.. Here is a small sample of the code that I'm having problems with. Basically I'm trying to send a command to the server and get status of that device, basically just syncing the clients display with the servers.. When I create a listener script on the server I will see the first command go through for lights, but the 2nd for the harvesters never go through. It works flawless with a modem.
This will be connected to several semi-automated wheat farms when I'm done.
Spoiler
Client:
textutils.slowPrint "Getting Farm #1 Information..."
sleep (0.5)
rednet.send( 8 , "get1light" )
local event, p1, p2 = os.pullEvent()
if event == "rednet_message" and p2 == "light1on" then
light1 = ("true")
elseif event == "rednet_message" and p2 == "light1off" then
light1 = ("false")
end
print ("Received Lighting Information")
sleep (0.5)
rednet.send( 8 , "get1harv" )
local event, p1, p2 = os.pullEvent()
if event == "rednet_message" and p2 == "harvest1on" then
harv1 = ("true")
elseif event == "rednet_message" and p2 == "harvest1off" then
harv1 = ("false")
end
print ("Received Harvester Information")
sleep (0.5)
print ()
Server:
local event, par1, par2 = os.pullEvent()
if event == "rednet_message" then
if par2 == "get1light" then
if rs.testBundledInput(sSide, colors.orange ) == true then
sleep (0.5)
rednet.send( par1 , "light1on" )
else
sleep (0.5)
rednet.send( par1 , "light1off" )
end
elseif par2 == "get1harv" then
if rs.testBundledInput(sSide, colors.red ) == true then
sleep (0.5)
rednet.send( par1 , "harvest1on" )
else
sleep (0.5)
rednet.send( par1 , "harvest1off" )
end
end
end
473 posts
Location
Poland
Posted 26 February 2012 - 10:15 PM
you forgot rednet.open(side) to open port
1111 posts
Location
Portland OR
Posted 26 February 2012 - 10:17 PM
Thats in the beginning of the function. I only put the portion of the code I'm having issues with when using bundled cables.
715 posts
Posted 26 February 2012 - 10:57 PM
Is the code for the server running in a loop?
Because if not, then you're only listening for incoming requests once and then that's where your problem is.
1111 posts
Location
Portland OR
Posted 26 February 2012 - 11:20 PM
I looped my main function, but not this sync function. I'll play around with it, I need more practice with loops anyway. :)/>/>
I did notice some extra redstone communication on the bundled cables thats not there with the modems which would explain why a loop would be needed with the cables and not the modem.
1111 posts
Location
Portland OR
Posted 26 February 2012 - 11:28 PM
That fixed it, thank you for the help!
48 posts
Posted 26 February 2012 - 11:34 PM
I have the bombing run on multiple turtles with modem with a password lock on the bombing run script/program how do i send a message via computer with router to the turtle that tells them all to startup that program?
161 posts
Posted 27 February 2012 - 03:22 AM
Be aware that as well as being much cheaper to build than long strings of bundled cable, wireless modems are also more secure (anyone who can find a bundled cable can tap messages off it; wireless modems always only ever send their messages to the specified recipient), more robust against damage (a creeper can blow up a cable half way between your computers, but would have to actually be at one of the computers to do any damage with a modem), faster (a modem sends a whole message instantaneously because it plumbs directly into native Java code using the peripheral API, while bundled cables actually have to pass the message a byte or two at a time over the cable), and more solid in the face of multiple transmitters (modems always send whole messages as atomic units directly to their recipients; when using bundled cable, if two computers transmit at the same time, you will see a message come out that is a mixture of the two transmitted messages). The only reason I can see to use bundled cable instead of modems, other than existing installations, is if you use broadcasts to discover other computers on the network and don't want to talk to computers outside the site.
195 posts
Location
Cambridgeshire, England
Posted 27 February 2012 - 10:41 AM
when using bundled cable, if two computers transmit at the same time, you will see a message come out that is a mixture of the two transmitted messages). The only reason I can see to use bundled cable instead of modems, other than existing installations, is if you use broadcasts to discover other computers on the network and don't want to talk to computers outside the site.
For the 2 computer transmission I suggest you look at network topology. Specifically the fact that most rednet networks are referred to as bus topology, Its harder to build and slower but it is possible to build a ring topology (with more cable and complexity of wiring though) and also build star networks although star networks I've been having issues with speed of code on the hub computer. Ring seems the most viable multi-user network using bundled cables if you can cope with the HUGE speed impact.
Bundled cables also have a 255 block transmission distance compared to 50 on a wireless modem.
That said I do prefer the wireless modems by far, mostly because since CC 1.3 for some reason redpower has been conflicting whereas it didn't on 1.2. Wireless modems still work without redpower. You can always build a wireless repeater for more range.