artnet4j icon indicating copy to clipboard operation
artnet4j copied to clipboard

Reading freeze after 1sec of artnet inactivity

Open Nspada2 opened this issue 2 years ago • 6 comments

Hi guys, I'm using this repo in an android app I'm developing. I noticed that if artnet stays still for more then 1 sec the reading freeze and need some time to wakeup. Any ideas about how to fix it? I'm using the Server Listener to read any change

Here a video of the problem. https://youtu.be/G5EKXNKhBLs

Nspada2 avatar Aug 11 '23 00:08 Nspada2

Hi, thanks for the provided video, would it also be possible to provide a minimal example which shows the problem? Without code it is difficult to help you with that.

cansik avatar Aug 11 '23 08:08 cansik

ArtNetClient artnet=new ArtNetClient();
        artnet.start();
        artnet.getArtNetServer().addListener(
                new ArtNetServerEventAdapter() {
                    @Override public void artNetPacketReceived(ArtNetPacket packet) {
                        dmxData = artnet.readDmxData(0, 0);
                        System.out.println("1:" + Byte.toUnsignedInt(dmxData[0]) + " 2:" + Byte.toUnsignedInt(dmxData[1]));
                        int a,b;
                        a=Byte.toUnsignedInt(dmxData[0])*20/255;
                        b=Byte.toUnsignedInt(dmxData[1])*20/255;
                        binding.textview1.setText("1:" + a + " 2:" + b);
                        binding.progressBar.setProgress(a);
                        binding.progressBar2.setProgress(b);
                    }
                });

Nspada2 avatar Aug 13 '23 14:08 Nspada2

Does this behaviour happen only on android or is it possible to reproduce it on a computer as well?

To be honest, I can't find anything special in the code and I don't own an android phone. So it's a bit difficult to test.

cansik avatar Aug 14 '23 05:08 cansik

It's impossible to try that on android studio because of the network adaptor isolated from the host. It never hapens with other software. What I think is that it stops reading as soon as artnet stop transmitting, but, artnet protocol can stay "mute" up to 3 seconds if notthing changes, it only talk when something change or, if not, it sends a confirm that is alive every 3 secs. A workaround I found is to use a channel which I don't use and give it a sinewave, so values are always changing and the connecrion is always mantained.

Nspada2 avatar Aug 14 '23 16:08 Nspada2

Afaik there is no mechanism built into artnet4j that would prevent this behaviour (only send every nth second). Maybe android is messing with the sockets. I think I can not really help you with that problem, but I'll let the issue open for others with artnet4j & android experience.

cansik avatar Aug 14 '23 16:08 cansik

No problem, in my app I only use the reciver, but this could be helpful for someone with my preblem. BTW the workaround works fine (if you can control the artnetOut)

Nspada2 avatar Aug 14 '23 20:08 Nspada2