Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
dom11990

Wireless card not receiving messages reliably?

Question

hi all,

I'm on the Enigmatica 2 Expert Modpack and trying to get a simple wireless network up and running. I wrote two programs in MineOS to send and receive broadcast messages. Unfortunately, the receiver seems to randomly drop some.

This is the recevier:

local event = require("event")
local comp = require("component")
---------------------------------------------------------------------------------

modem = comp.get("modem")
modem.open(1)

-- modem_message signature: type: string = "modem_message", localAddress: string, remoteAddress: string, port: number, distance: number, ....
local function ModemEventHandler(e1,localAddress,remoteAddress,port,distance,data1,data2,data3)
  if type(e1) == "string" then
    print(e1)
    if e1 == "modem_message" then
      print("Distance: " .. distance .. " contents: " .. data1)
    end
  end
end
---------------------------------------------------------------------------------

event.addHandler(ModemEventHandler)

This the sender:

 


-- Import libraries
local event = require("event")
local cp = require("component")

---------------------------------------------------------------------------------

modem = cp.get("modem")

function Timer1_s()
  data = "sent some data " .. computer.uptime()
    res = modem.broadcast(1,data)
    if res then 
      st = "true"
    else
      st="false"
    end
    print(data .. " " .. st)
end

event.addHandler(Timer1_s,1)

The sender always prints the uptime and true whereas the receiver seems to skip around 10% of them. Range is 65.97, everything is max tier. Any idea on what could be causing this or do you suspect it has to do with MineOS not handling the events properly?

Edit:

I went ahead and made another computer and put it 2 blocks away from the sender. This machine reliably receives the messages. What could be going on? Everything is chunkloaded and the wiki says explicitly that packets cannot get lost.

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I know this question is 2 years old, but still, if anyone else gets the same problem (and since the wiki says almost nothing about it), hopefully this will be helpful.

The reason is obstructions. When sending a wireless message, OC checks a random line in a 3x3 tunnel between the source and destination. It then takes a few (inverse root of the gap) random coordinates inside that line and checks if there's a block there, summing their hardness. Then it spreads that hardness evenly across the entire distance, sums it, and subtracts that sum from the signal's strength.

For example, say we have two computers on an even grassy ground with a distance of 9 between them. Grass block's hardness is 0.6. Most of the time, the signal will move through the air, and you will only need signal strength 9 to reach the other computer. However, sometimes the signal will try to move through the ground, which will require a strength of (9 + 0.6*9) ~ 15 (rounding up)

The problem may also arise because of a single hard block. Say we have a single cobblestone (hardness = 2) somewhere between two computers. We also put the computers in the air to avoid the ground interference. There is a possibility that all the checks fall on this very block, which will make the OC assume that the entire distance is filled with these blocks. So, because of a single cobblestone block, you will need (9 + 2 * 9) = 27 strength to reliably reach the other computer.

To illustrate this, here's the simple setup of two robots with a cobblestone pillar between them. The robot on the left sends a hundred messages to the other one, noting which ones of them got a reply, then moves back, and keeps repeating that 10 times. The results are on the second picture.

javaw_2024-05-07=10-10-43.jpg

javaw_2024-05-07=10-13-46.jpg

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.