Jump to content




Rednet: send reply after receiving message

lua networking

8 replies to this topic

#1 Calculator

  • Members
  • 14 posts
  • LocationBelgium

Posted 08 June 2012 - 05:03 PM

Hello crafters,

I'm trying to make one computer reply as soon as it has received a Rednet message. I hope to extend this system to make a small intranet on our SMP server.

My computer setup:
Spoiler
The computer on the left runs the program receivertest.
The computer on the right runs the program sendertest.

Console output of the receiving computer at the left:
Spoiler

Console output of the sending computer at the right:
Spoiler

As you can see, the right computer at the right successfully broadcasts a message to the left computer. This computer then sends a reply, but this doesn't seem to reach the right computer.

When I replace the bundled RedPower cables with wireless modems, it works perfectly. However, I'd rather not put a repeater computer every 17 meters just to make two computers communicate over long distances.

Any ideas?

#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 08 June 2012 - 05:19 PM

The problem might be that using rednet over bundled cables is way too slow, so it times out. The soultion would be to increase the wait time, or use modems. I would recommend using modems, even if you have to set up some repeater system it would be faster. Just try to send a long message over bundle and see how long it takes to send it, that's because it sends each byte over the bundle. Modems send messages of any size instantly, so you could repeat the message through a lot of repeater computers and it would be faster than using cables.

#3 BigSHinyToys

  • Members
  • 1,001 posts

Posted 08 June 2012 - 05:34 PM

View PostCalculator, on 08 June 2012 - 05:03 PM, said:

When I replace the bundled RedPower cables with wireless modems, it works perfectly. However, I'd rather not put a repeater computer every 17 meters just to make two computers communicate over long distances.

Any ideas?
the range of wifi in CC is 50 meters (blocks) so you would only need a repeater computer every 50 not 17. this range is also configurable so you could make it 100 or a 1000 if you wanted.

As for your code you can catch events with " os.pullEvent() " placed in a loop you can creat a computer program that will repete your signal example.
Spoiler
this might be help full in testing
Spoiler


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 08 June 2012 - 05:54 PM

The default range is actually 64 blocks.

#5 Calculator

  • Members
  • 14 posts
  • LocationBelgium

Posted 08 June 2012 - 05:58 PM

View PostMysticT, on 08 June 2012 - 05:19 PM, said:

The problem might be that using rednet over bundled cables is way too slow, so it times out. The soultion would be to increase the wait time, or use modems. I would recommend using modems, even if you have to set up some repeater system it would be faster. Just try to send a long message over bundle and see how long it takes to send it, that's because it sends each byte over the bundle. Modems send messages of any size instantly, so you could repeat the message through a lot of repeater computers and it would be faster than using cables.
We did some tests and it seems like the first message takes about a second to send whereas our timeout is set to five seconds. The second message is about the same size, so it should take about the same time to send, right? Anyhow, we did try to increase the timeout to ten seconds, to no avail.

View PostBigSHinyToys, on 08 June 2012 - 05:34 PM, said:

the range of wifi in CC is 50 meters (blocks) so you would only need a repeater computer every 50 not 17. this range is also configurable so you could make it 100 or a 1000 if you wanted.
According to the wiki, the range is 64 meters by default and decreases to 17 meters in a thunderstorm. If I'd want my system to work in all conditions, I'd need to place one every 17 blocks. Surely, I could ask the server admin to increase the range but that would be like cheating the question, right? :)/>

I'll probably go with the modem/repeater solution: they're faster and cheaper than bundled cables. Still, as an engineer I'm intrigued by this problem and I'd like to know if it is possible to do this with bundled cables. If anyone has a solution or an explanation for this, do share please!

#6 BigSHinyToys

  • Members
  • 1,001 posts

Posted 08 June 2012 - 06:15 PM

you are right storm do cause a range decrease and it is 64 blocks. This has never been a real problem form me so far.The bundled cable is not capable of fast speeds due to it relying on Redstone (sorta). it should be possible all be it more work to make a program that breaks a message down and sends it over a cable before assembling it at the ther end. you should look at the rednet api if you want to know how it works.

this is a set of programs i made when i first started using CC before modems. it is a extreamly basic 4 bit sender down a single redstone line (not bundle)

sender
Spoiler
reciver
Spoiler

if that could be duplicated for each one of the 16 cables in a bundle you would have speeds of 40 bit's per second. that is extremely slow compared to wifi

#7 Calculator

  • Members
  • 14 posts
  • LocationBelgium

Posted 08 June 2012 - 06:35 PM

View PostBigSHinyToys, on 08 June 2012 - 06:15 PM, said:

you are right storm do cause a range decrease and it is 64 blocks. This has never been a real problem form me so far.The bundled cable is not capable of fast speeds due to it relying on Redstone (sorta). it should be possible all be it more work to make a program that breaks a message down and sends it over a cable before assembling it at the ther end. you should look at the rednet api if you want to know how it works.
Agreed, redstone is slower than modems. Still, a simple test shows that the short message I'm sending takes about a second to send. Even though it's slower, it should still be able to receive the message before timing out.

View PostBigSHinyToys, on 08 June 2012 - 06:15 PM, said:

this is a set of programs i made when i first started using CC before modems. it is a extreamly basic 4 bit sender down a single redstone line (not bundle)

if that could be duplicated for each one of the 16 cables in a bundle you would have speeds of 40 bit's per second. that is extremely slow compared to wifi
I checked the code of the Rednet API and it sort of does that. By default, it sends and receives at a clock rate of 15 Hz which means that it can send 15 packets of 16 bits per second, resulting in a net transfer rate of 240 bps. When using a modem, it simply passes the whole message in one go to the modem, hence the instant transfer.
Also, your code could be greatly simplified with bitwise operations. Just sayin'. :)/>

So really, I'm not looking into finding a replacement for the Rednet API. I just want to know why the reply doesn't get through.

#8 BigSHinyToys

  • Members
  • 1,001 posts

Posted 08 June 2012 - 06:49 PM

that code was made a long time ago i know there is huge room for simplification. as for bit wise operations, lua 5.1 witch juaj is based on and cc uses does not support them.
http://www.lua.org/manual/5.1/

http://www.lua.org/manual/5.2/

http://luaj.org/luaj/README.html

#9 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 08 June 2012 - 08:20 PM

View PostBigSHinyToys, on 08 June 2012 - 06:49 PM, said:

that code was made a long time ago i know there is huge room for simplification. as for bit wise operations, lua 5.1 witch juaj is based on and cc uses does not support them.
http://www.lua.org/manual/5.1/

http://www.lua.org/manual/5.2/

http://luaj.org/luaj/README.html
That's why there's a bit api in CraftOS :)/>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users