elianterelle / p2-camera-connection

MIT License
3 stars 1 forks source link

Multiple cameras failure #1

Open Rik83 opened 1 year ago

Rik83 commented 1 year ago

Hi, thank you for your excellent module !

I have two CX350. Cam1 (ip 192.168.1.89 - cxrop 49151 - portdist 49154) Cam2 (ip 192.168.1.90 - cxrop 49152 - portdist 49154) So I have two P2 modules installed Module1 (target ip 192.168.1.89 P2tctport 49151) Module2 (target ip 192.168.1.90 P2tctport 49152)

I can enable the module1. everything works perfectly. Or I can enable the module2. everything works perfectly.

BUT I can't enable both modules at the same time.

Log when enabling module1 alone: 23.07.17 08:13:20 Instance/Controller: Enable instance CX350-1 23.07.17 08:13:20 Instance/ModuleHost: Starting connection: "CX350-1"(sTHop2XRcFOvo-TpmFRx) 23.07.17 08:13:20 Instance/ModuleHost: Connection "CX350-1" started 23.07.17 08:13:20 Instance/ModuleHost: Registered module client "sTHop2XRcFOvo-TpmFRx" 23.07.17 08:13:20 Instance/Wrapper/CX350-1: Opening TCP Connection to 192.168.1.189:49151 23.07.17 08:13:20 Instance/Controller: instance "CX350-1" configuration updated 23.07.17 08:13:20 Instance/Wrapper/CX350-1: Opened UDP Socket on port 49153 23.07.17 08:13:20 Instance/Wrapper/CX350-1: Connecting via UDP to 192.168.1.189:49153

Log when enabling module2 alone: 23.07.17 08:16:20 Instance/Controller: Enable instance CX350-2 23.07.17 08:16:20 Instance/ModuleHost: Starting connection: "CX350-2"(yO-PnwUrUEEvIQ7-Lo30e) 23.07.17 08:16:20 Instance/ModuleHost: Connection "CX350-2" started 23.07.17 08:16:20 Instance/ModuleHost: Registered module client "yO-PnwUrUEEvIQ7-Lo30e" 23.07.17 08:16:20 Instance/Wrapper/CX350-2: Opening TCP Connection to 192.168.1.190:49152 23.07.17 08:16:20 Instance/Controller: instance "CX350-2" configuration updated 23.07.17 08:16:20 Instance/Wrapper/CX350-2: Opened UDP Socket on port 49153 23.07.17 08:16:20 Instance/Wrapper/CX350-2: Connecting via UDP to 192.168.1.190:49153

Log when enabling module2 (with module1 enable) 23.07.17 08:14:34 Instance/Controller: Enable instance CX350-2 23.07.17 08:14:34 Instance/ModuleHost: Starting connection: "CX350-2"(yO-PnwUrUEEvIQ7-Lo30e) 23.07.17 08:14:34 Instance/ModuleHost: Connection "CX350-2" started 23.07.17 08:14:34 Instance/ModuleHost: Registered module client "yO-PnwUrUEEvIQ7-Lo30e" 23.07.17 08:14:34 Instance/Wrapper/CX350-2: Opening TCP Connection to 192.168.1.190:49152 23.07.17 08:14:34 Instance/Controller: instance "CX350-2" configuration updated 23.07.17 08:14:34 Instance/ModuleHost: Connection "CX350-2" crashed 23.07.17 08:14:34 Instance/ModuleHost: Connection "CX350-2" stopped 23.07.17 08:14:34 Instance/Wrapper/CX350-2: Opened UDP Socket on port 49153 23.07.17 08:14:34 Instance/Wrapper/CX350-2: Connecting via UDP to 192.168.1.190:49153

AM I DOING SOMETHING WRONG ?

elianterelle commented 1 year ago

Hi, sadly, i could only test this module with a hc-x2 and a cx350, not with two cx350. Could you please try to change the port of the second camera to 49161 and send me the log of it after enabling it? If that doesn't work, i'll have to get my hands on two cx350 for testing.

Rik83 commented 1 year ago

I set the tcp port to 49161 to one module The module start, but all feedbacks do not work anymore.

23.07.17 19:36:32 Instance/Controller: Enable instance CX350-1 23.07.17 19:36:32 Instance/ModuleHost: Starting connection: "CX350-1"(sTHop2XRcFOvo-TpmFRx) 23.07.17 19:36:32 Instance/ModuleHost: Connection "CX350-1" started 23.07.17 19:36:32 Instance/ModuleHost: Registered module client "sTHop2XRcFOvo-TpmFRx" 23.07.17 19:36:32 Instance/Wrapper/CX350-1: Opening TCP Connection to 192.168.1.189:49161 23.07.17 19:36:32 Instance/Controller: instance "CX350-1" configuration updated 23.07.17 19:36:32 Instance/Wrapper/CX350-1: Opened UDP Socket on port 49153 23.07.17 19:36:32 Instance/Wrapper/CX350-1: Connecting via UDP to 192.168.1.189:49153

And I still can not start both modules

elianterelle commented 1 year ago

For me, this looks like the cx350 always uses the same port for feedback back to the module, regardless of the port configured for controlling the camera from companion. That is very unfortunate, as i currently can't listen on the same port from multiple companion module instances. I'll have to think about how i am going to fix this. Either a single instance of the cx350 module can connect to multiple cameras, or there needs to be a change in companion itself to allow for a shared process across module instances. And then i'll have to figure out how to test this, as i currently don't own two cx350, but i might be able to borrow some.

Rik83 commented 1 year ago

I can help you to test if you need

De : elianterelle @.> Envoyé : lundi 17 juillet 2023 19:49 À : elianterelle/p2-camera-connection @.> Cc : Rik83 @.>; Author @.> Objet : Re: [elianterelle/p2-camera-connection] Multiple cameras failure (Issue #1)

For me, this looks like the cx350 always uses the same port for feedback back to the module, regardless of the port configured for controlling the camera from companion. That is very unfortunate, as i currently can't listen on the same port from multiple companion module instances. I'll have to think about how i am going to fix this. Either a single instance of the cx350 module can connect to multiple cameras, or there needs to be a change in companion itself to allow for a shared process across module instances. And then i'll have to figure out how to test this, as i currently don't own two cx350, but i might be able to borrow some.

- Reply to this email directly, view it on GitHubhttps://github.com/elianterelle/p2-camera-connection/issues/1#issuecomment-1638602033, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACD5ICQGNDKUT3UEI3LFNXLXQV3HFANCNFSM6AAAAAA2MO7SNI. You are receiving this because you authored the thread.Message ID: @.***>

JP-Consulting-TX commented 11 months ago

Hello,

I am very new to companion and any form of coding. I have made it down the rabbit hole far enough to find myself in the same predicament. I have 2 CX350's and was able to control them individually with disabling the other. I changed the port numbers to coincide in the camera to the connection settings in companion. If you have since found a fix or can lend any help or suggestion, I'd greatly appreciate it. If you would like to have someone help with 2 CX350's on hand and ready, I'd be happy to do that too.

Thanks much

JP

elianterelle commented 9 months ago

I just received my second HC-X2, so i'll hopefully come around to fixing this in the next weeks!

Rik83 commented 9 months ago

Good news ! If you need any test, ask me when you want.

Arolarobola commented 4 months ago

For starts... Great job and thank you for this script/module!!! It works amazingly and is very responsive! I have been able to create an app that I've needed to control my 3-4 CX350's. The issue I'm having is that I CAN control each camera just fine but getting the feedback "camera data (cameraState & opticalState) from the cameras to populate the appropriate fields seems like it's limited to a single camera? Even if I change the ports to different ports. Can the script support cameraState/opticalState for multiple cameras? Thanks in advance! UPDATE: I was able to hack it a bit to make it work for my app. Just needed to pass back the IP address along with the data it was coming from and I filtered it form there. Thx

elianterelle commented 4 months ago

I've been working on this issue a few weeks ago. The issue is that the cx350s(or at least the hc-x2s with which i'm testing) always send udp data to the same port, no matter what port the udp request for new data came from. So you basically have to share a single udp listener for all cameras. I'll push my changes to a branch called "multi-camera". There'll be a new constructor parameter "customUdpClient" that you can pass a dgram udp socket to (which can be created with udp.createSocket('udp4'), so you only create one for all your instances of the P2CameraConnection class!). I wrote this module when i developed a companion module for the cx350/hc-x2, where i also just pushed a fix to an equally named branch: https://github.com/bitfocus/companion-module-panasonic-p2/commit/4358745ff09f37401f50ad04ff52b07235ec3569 I'm currently very busy with work, so i won't have time to document any of those changes and also to test them thoroughly, but my companion module seems to work with those changes. So if something is unclear, maybe you can look at the code of the companion module to see how i used it there. Hope this helps!

daubli commented 2 months ago

@elianterelle: Oh - that sounds great. I'll definitely take a look and check out those changes. I also did some research on that issue and came only up with very ugly solutions (use some kind of dispatcher service, that delegates the traffic onto another udp port and modify the udp port in the response of the env request)