Skip to content

simultaneous use of teletype queries and norns crow.send crashes crow #492

@Dewb

Description

@Dewb

When simultaneously receiving serial messages from norns and i2c query commands from Teletype, crow will eventually crash.

Crow can also be made to crash immediately by redefining the ii.self.query0 function while this is happening.

Example real-world application: adding an option to dreamsequence to synchronize its scale with teletype (branch)

The crash is observable in both crow 3.0.0 and crow 4.0.5.

Example repro script (this is not totally minimal, I believe one coroutine calling crow.send is sufficient, but more crash sooner.)

-- minimal script to reproduce teletype-crow-norns crash issue
-- steps to reproduce:
--   connect crow to teletype via i2c
--   put N.B CROW.Q0 in M script (default M 1000 is sufficient, but faster Ms crash sooner)
--   connect crow to norns via usb
--   run this script
--   crow will generally crash within 20-30 seconds. norns is hung until crow is disconnected or power cycled.

crow_updates = {}

function init()
  redraw()
  
  clock.run(function() 
    while true do
      update_crow(1)
      clock.sleep(0.5)
    end
  end)
  
  clock.run(function() 
    while true do
      update_crow(2)
      clock.sleep(0.17)
    end
  end)

  -- uncomment this to crash immediately  
  -- clock.run(function()
  --   clock.sleep(1)
  --   crow.send("ii.self.query0 = function() print('query0*') end")
  -- end)
end

function redraw()
  screen.clear()
  screen.level(15)
  screen.move(2,8)
  screen.text("crow stress test " .. os.clock())

  for i = 1, #crow_updates do
    if crow_updates[i] then
      screen.move(12, 20 + (i-1) * 12)
      screen.text("ran crow update " .. i)
      crow_updates[i] = false
    end
  end
  
  screen.update()
end

function refresh()
  redraw()
  update_crow(3)
end

function update_crow(n)
  norns.crow.send("foo = " .. n)
  crow_updates[n] = true
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions