This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
matejdro's profile picture

Slow two way communication using bundled cable

Started by matejdro, 27 August 2012 - 03:07 PM
matejdro #1
Posted 27 August 2012 - 05:07 PM
Hello! I'm playing around with bundled cable rednet.

I want turtle A to send message to turtle B and then I want turtle B to respond with another message which turtle A would read.

However, I'm having a big inconveience due to high delay. Here are my two testing scripts:

Turtle A

print("start")
start = os.clock()
rednet.broadcast("test")
rednet.receive()
print("end " .. (os.clock() - start))
It will send message and then enter receive mode. Clocks here are for benchmark.

Turtle B

rednet.receive()
sleep(0.1) -- Some small delay to allow turtle A to enter receiving mode
rednet.broadcast("testBack")

Result is quite bad - 1.6 seconds for a message to transfer two-way. Any idea how could I improve it?
matejdro #2
Posted 27 August 2012 - 05:52 PM
Performed similar test using modems instead of bundled cables and everything happened nearly instantly.

Could that be a bug or intentional feature for bundled cables? I need to use bundled cables because Turtle A is Crafty turtle which cannot have modem.
Lettuce #3
Posted 27 August 2012 - 07:33 PM
Okay, you tell us you are trying to get a turtle to receive a redpower bundled cable signal, and give us a picture of your setup. Then you tell us about rednet, which is completely separate, and you specifically said you can't use it.
I don't know what you want an answer for. If it's about those two turtles sending each-other a color-coded signal, we need to see that code, not the rednet code. I'm assuming you want to do away with rednet, and write a code to basically tell the crafty turtle blue = craft a pickaxe?
Please give us more detail. If it is within my realm of knowledge I will help you, otherwise it can't hurt, as someone else may be able to help.
MysticT #4
Posted 27 August 2012 - 07:42 PM
Yes, it's really slow, because it sends the message as bytes at a defined clock rate. You can do what Lettuce said and assign each color (or group of colors) a function (like crafting some item).

Okay, you tell us you are trying to get a turtle to receive a redpower bundled cable signal, and give us a picture of your setup. Then you tell us about rednet, which is completely separate, and you specifically said you can't use it.
Actually, rednet was originally based on bundled cables, and you still can use it with them. Modems were added after rednet.
Lettuce #5
Posted 27 August 2012 - 07:56 PM
Actually, rednet was originally based on bundled cables, and you still can use it with them. Modems were added after rednet.
I wasn't aware of that. I'm used to the newer 1.3+ versions. I picked this mod up about a month before dan200 updated to 1.4. Therefore I'm much more used to setBundledInput and getBundledInput. In fact I thought rednet was used exclusively as a sort of "internet" between computers, requiring modems. I have much to learn, "Lua Sensai."
matejdro #6
Posted 27 August 2012 - 07:57 PM
@Lettuce you can use bundled cables instead of modems for rednet communication.

I need full communication between the two (as sending actual numbers), so turning redstone on/off would not work :D/>/>
Lettuce #7
Posted 27 August 2012 - 08:05 PM
Ah! But that is where you are wrong (I think, I've just been wrong mind you.) If you need to send numbers, Bundled cable supports that. It's binary. Type "help redpower", then "help colors."
White is 1, orange is 2, magenta is 4….. etc. It gets up there pretty quick.
MysticT #8
Posted 27 August 2012 - 08:06 PM
And 65536 numbers is not enough?
What do you need it for? Maybe someone else has a better solution.
matejdro #9
Posted 27 August 2012 - 08:09 PM
Ah yeah, I can send numbers directly using bundled cable (without need to manaully encode colors). Completely forgot about that. Will figure something out :D/>/>
Lettuce #10
Posted 27 August 2012 - 08:13 PM
See? I'm good for something! Eat your greens kids! (Get it? Ha ha…)