bitfocus / companion-module-generic-pjlink

Companion Module
MIT License
6 stars 8 forks source link

Sending several Pjlink commands in sequence does not work well and gives error messages #18

Closed Gartom closed 2 years ago

Gartom commented 3 years ago

The pjlink module implementation is not working well with my projector (Hitachi CP-WX8265) as the module does not take into account for the time it takes to process and respond to a request. A subsequent request sent to the projector when the previous request has not been completed ends up logging an error that the password is wrong despite the fact that no password is set.

It seems that commands sent to the projector should be implemented using a command queue and a "blocking call" structure were the next command in the que is sent when the blocking call from the previous command has been completed. According to the Pjlink standard, the functionality can't be guaranteed if a new command is sent before a full response has been received: "However, if multiple commands are transmitted before receiving the projector’s/display’s response, the projector’s/display’s response to and execution of these commands are not guaranteed." (page 46 in standard)

https://pjlink.jbmia.or.jp/english/data_cl2/PJLink_5-1.pdf

McHauge commented 3 years ago

I would add a relative delay on each subsequent action on the same button, of 20-200ms. That is a typical thing that needs to be added in the web gui when having more than 3-5 actions on the same button for the same device. Simply because if you have more than one action on the same button without a delay, then they will all be executed in parallel, not sequential, that's how the companion core works as default, so not specificly a module thing. Hope this helps 👍

Gartom commented 3 years ago

Good comment, @McHauge, and I understand that this may be the issue in some cases.

In this case I could see, using Wireshark, that the behavior is consistent with when the projector is finished executing a command. As switching from one input to another takes almost 5 seconds I can't hinder the user to send another command, e.g. with another button. Any other command sent before the previous one is completed is handled as a password error and the connection is closed with the "red square" showing in top right corner on all buttons using the module.

I will try using the generic tcp-udp module instead as we only need four commands and get live feedback if a command works or needs to be sent again.

Gartom commented 3 years ago

Using the generic tcp-udp module works well for my use case so I personally don't need to get the pjlink module improved. I still believe the module would benefit of improvement but I will not push for it at least. :-)