GregMefford / blinkchain

Nerves project to use Elixir to drive NeoPixels from a Raspberry Pi
MIT License
71 stars 27 forks source link

Timeouts waiting for blinkchain OS process to reply #27

Open joelbyler opened 4 years ago

joelbyler commented 4 years ago

I'm looking for tips or maybe additional data back to understand these errors. I notice that they've been coming up on a somewhat regular basis. Can I configure timeouts, or should I try and block updates until the previous reply has been received? Is that possible?

20:37:06.682 [error] GenServer Blinkchain.HAL terminating
** (RuntimeError) timeout waiting for blinkchain OS process to reply
    (blinkchain) lib/blinkchain/hal.ex:194: Blinkchain.HAL.receive_from_port/1
    (blinkchain) lib/blinkchain/hal.ex:109: Blinkchain.HAL.handle_call/3
    (stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:690: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message (from :lamp): :render

20:37:06.730 [error] GenServer :lamp terminating
** (stop) exited in: GenServer.call(Blinkchain.HAL, :render, 5000)
    ** (EXIT) an exception was raised:
        ** (RuntimeError) timeout waiting for blinkchain OS process to reply
            (blinkchain) lib/blinkchain/hal.ex:194: Blinkchain.HAL.receive_from_port/1
            (blinkchain) lib/blinkchain/hal.ex:109: Blinkchain.HAL.handle_call/3
            (stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
            (stdlib) gen_server.erl:690: :gen_server.handle_msg/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
    (elixir) lib/gen_server.ex:1009: GenServer.call/3
    (lamp_control) lib/lamp_control/lamp.ex:48: LampControl.Lamp.handle_cast/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_cast", {:set_color, "#19ff02"}}
mobileoverlord commented 4 years ago

I see this too. It appears that blinkchain doesn't work anymore with the latest systems

GregMefford commented 4 years ago

Hm yeah that's strange that it would time out without actually crashing. I just got the example rainbow project updated to work with the latest Nerves conventions and it fired right up for me like I expected. I'll push the updates up for that example project and keep fiddling with it to see if I can get it to break.

GregMefford commented 4 years ago

Ah I see! I am getting the same error messages during boot-up but it's still working fine apart from a momentary glitch that is visible, presumably as a result of the crash. I'm testing it on rpi3 and rpi3a with latest systems (1.11.1).

@mobileoverlord it sounds like maybe it's not working at all for you, right? Do you have a project I can clone and try, or a fw file that's not working?

If you're trying it on a rpi4, I do have one of those to test with, but I haven't had a chance to try it yet - need to get all the hardware put together.

joelbyler commented 4 years ago

FWIW, when I reported back in December, this was on an rpi0, I have a project but haven't touched it since January. I can dust it off and send you a link if thats of interest?

GregMefford commented 4 years ago

No pressure @joelbyler - if the only problem was seeing those logs, then I am able to reproduce that and I can try to figure out why they're happening. It seems like on my end, it's quickly restarting and continuing to work, but that's on much faster hardware (rpi3).

If your project was just breaking and not immediately fixing itself, then I'd definitely be interested to understand why.

joelbyler commented 4 years ago

👍 that's correct, mostly just extra noise in the logs. Thanks for looking into this @GregMefford

konstantinzolotarev commented 4 years ago

@GregMefford @joelbyler Any news on this issue ?

Getting same error from time to time.

18:51:05.713 [error] GenServer Blinkchain.HAL terminating
** (RuntimeError) timeout waiting for blinkchain OS process to reply
    (blinkchain 1.0.0) lib/blinkchain/hal.ex:194: Blinkchain.HAL.receive_from_port/1
    (blinkchain 1.0.0) lib/blinkchain/hal.ex:109: Blinkchain.HAL.handle_call/3
    (stdlib 3.12.1) gen_server.erl:661: :gen_server.try_handle_call/4
    (stdlib 3.12.1) gen_server.erl:690: :gen_server.handle_msg/6
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message (from Stairs.Controller): :render
State: %Blinkchain.HAL.State{config: %Blinkchain.Config{canvas: %Blinkchain.Config.Canvas{height: 1, width: 420}, channel0: %Blinkchain.Config.Channel{arrangement: [%Blinkchain.Config.Strip{count: 420, direction: :right, origin: {0, 0}, spacing: 1}], brightness: 32, gamma: nil, invert: false, number: 0, pin: 18, type: :grb}, channel1: %Blinkchain.Config.Channel{arrangement: [], brightness: 255, gamma: nil, invert: false, number: 1, pin: 0, type: :gbr}, dma_channel: 5}, port: #Port<0.33996>, subscriber: nil}
Client Stairs.Controller is alive

    (stdlib 3.12.1) gen.erl:167: :gen.do_call/4
    (elixir 1.10.2) lib/gen_server.ex:1020: GenServer.call/3
    (stairs 0.1.0) lib/stairs.ex:66: anonymous fn/2 in Stairs.on/1
    (elixir 1.10.2) lib/enum.ex:3371: Enum.reduce_range_inc/4
    (stairs 0.1.0) lib/stairs/controller.ex:32: Stairs.Controller.handle_cast/2
    (stdlib 3.12.1) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib 3.12.1) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

18:51:05.719 [error] GenServer Stairs.Controller terminating
** (stop) exited in: GenServer.call(Blinkchain.HAL, :render, 5000)
    ** (EXIT) an exception was raised:
        ** (RuntimeError) timeout waiting for blinkchain OS process to reply
            (blinkchain 1.0.0) lib/blinkchain/hal.ex:194: Blinkchain.HAL.receive_from_port/1
            (blinkchain 1.0.0) lib/blinkchain/hal.ex:109: Blinkchain.HAL.handle_call/3
            (stdlib 3.12.1) gen_server.erl:661: :gen_server.try_handle_call/4
            (stdlib 3.12.1) gen_server.erl:690: :gen_server.handle_msg/6
            (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
    (elixir 1.10.2) lib/gen_server.ex:1023: GenServer.call/3
    (stairs 0.1.0) lib/stairs.ex:66: anonymous fn/2 in Stairs.on/1
    (elixir 1.10.2) lib/enum.ex:3371: Enum.reduce_range_inc/4
    (stairs 0.1.0) lib/stairs/controller.ex:32: Stairs.Controller.handle_cast/2
    (stdlib 3.12.1) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib 3.12.1) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_cast", {:on, :from_middle}}
State: []
AlejandroHuerta commented 3 years ago

I get this error often when rendering. Sometimes multiple times in a row.

jasonmj commented 3 years ago

I too am getting this error. It's hard to pinpoint when or why.

jasonmj commented 3 years ago

Well, I think I got this worked out by setting my dma_channel to 9 as described here: https://github.com/GregMefford/blinkchain#dma-channel-selection

Lechindianer commented 3 years ago

Can confirm @jasonmj fix works on RPI2 with nerves 1.7.4 and nerves_system_rpi2 nerves_system_rpi2

EricHigdon commented 3 years ago

Setting dma_channel to 9 worked for me as well.