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

Stop rednet being crap!

Started by NeverCast, 24 February 2013 - 09:55 PM
NeverCast #1
Posted 24 February 2013 - 10:55 PM
Just found out that Rednet is limited to 0-127, anything else is sent as 239.. 239! What the!?

In 1.5, we're not limited to bundled cable transfer, so what ever reason there originally was that made it a good idea to have 7bit networking (I assume because of the way transfer over bundled cable was implemented) Can we get rid of that? Go to good ol' 8bit.

It wouldn't change any current programs, and it would mean encryption wouldn't be shit; would also mean I didn't have to rewrite my RC4 Algorithm to be 7bit so people can use it on a network.
I don't think http has this problem as I've transferred binary files from the net, but why with rednet, and with modems, when we're just sending a string. I mean, is it encoded in UTF7? I don't get it.

Sorry I didn't put a nice pitch for this suggestion, I just can't find reason that this decision was made, I would love to know why, I think I'd be more calm if I knew why.
Sora Firestorm #2
Posted 24 February 2013 - 11:04 PM
Agreed. Nothing can be broken, and we actually 'gain' support for some methods of cryptography. There isn't a reason to leave Rednet like this.
Tiin57 #3
Posted 24 February 2013 - 11:11 PM
Just found out that Rednet is limited to 0-127, anything else is sent as 239.. 239! What the!?

In 1.5, we're not limited to bundled cable transfer, so what ever reason there originally was that made it a good idea to have 7bit networking (I assume because of the way transfer over bundled cable was implemented) Can we get rid of that? Go to good ol' 8bit.

It wouldn't change any current programs, and it would mean encryption wouldn't be shit; would also mean I didn't have to rewrite my RC4 Algorithm to be 7bit so people can use it on a network.
I don't think http has this problem as I've transferred binary files from the net, but why with rednet, and with modems, when we're just sending a string. I mean, is it encoded in UTF7? I don't get it.

Sorry I didn't put a nice pitch for this suggestion, I just can't find reason that this decision was made, I would love to know why, I think I'd be more calm if I knew why.
What?
Do you mean that messages can only be integers 0-127?
NeverCast #4
Posted 24 February 2013 - 11:16 PM
That is correct.
NeverCast #5
Posted 24 February 2013 - 11:18 PM
Send
rednet.open('right')
while true do
  for i = 0, 255 do
   rednet.broadcast(string.char(i))
   sleep(0.1)
  end
end


Receive
rednet.open('right')
while true do
  _,m,_ = rednet.receive()
  print(string.byte(m,1,1))
  sleep(0)
end

Try it.
dan200 #6
Posted 24 February 2013 - 11:30 PM
You can send any lua data type however you like over the new modems. Being "limited to 128" is your programs fault.

Specifically, your use of string.byte and string.char. Why not just send the string?? :s
Cloudy #7
Posted 24 February 2013 - 11:45 PM
I'll point out that we don't do anything Java side to limit the string that is passed in. The string is simply passed to the receiver.

I personally think the attitude displayed in the OP is disgusting.
immibis #8
Posted 25 February 2013 - 12:19 AM
You can send any lua data type however you like over the new modems. Being "limited to 128" is your programs fault.

Specifically, your use of string.byte and string.char. Why not just send the string?? :s
He is sending strings. string.byte converts a character into an ASCII code, string.char converts an ASCII code into a one-character string.

Perhaps LuaJ is the problem.
Pinkishu #9
Posted 25 February 2013 - 12:38 AM
Some testing:

PC1:

m = peripheral.wrap("right")
m.open(2)

for i=100,150,1 do
  m.transmit(2,2,string.char(i))
  print("Sending " .. i .. " as " .. string.char(i) .. " (=="..string.byte(string.char(i))..")")
  sleep(0.1)
end

PC2

m=peripheral.wrap("right")
m.open(2)

while true do
  local evData = {os.pullEvent("modem_message")}
  print(string.byte(evData[5],1))
end

On the sending PC it shows the numbers correctly again, und the receiving anything over 127 becomes 239.

———————

Another test:
PC1:

m=peripheral.wrap("right")
m.open(2)

m.transmit(2,2,string.dump(function() print("hello world") end))
f=loadstring(string.dump(function() print("hello world") end))
f()

print hello world on sending pc

PC2:


m=peripheral.wrap("right")
m.open(2)

while true do
  local evData = {os.pullEvent("modem_message")}
  f,e= loadstring(evData[5])
  if not f then print(e) end
end
gets "bad constant" error
dan200 #10
Posted 25 February 2013 - 01:05 AM
Closing this thread as the complaint has eveyrthing to do with lua's implementation of string.byte and string.char, and nothing to do with rednet or modems