Testing PHD2 on Linux and INDI..

622 views
Skip to first unread message

Markku Siitonen

unread,
Sep 8, 2014, 2:16:33 PM9/8/14
to open-phd...@googlegroups.com
Hello group!!

Just tested how far the Linux version have come..

Downloaded source and compiled, everything went just fine, no errors at all.. :)

Then running PHD2...

The first light dialogue came up, pressing "Next>" result was dumping core.. but if I just pressed that dialogue away it stayed alive, but I think something will be missing in the configuration then..??

Connected to my remote observatory via VPN/SSH, started up INDI as usual, started up PHD2 on local machine and entered IP, pressed "Connect" and the devices showed up in the droplist, selected INDI camera wich is a Lodestar and my mount wich is a EQ8 and INDI menus turned up :)

Then I was a bit confused, should I connect devices via the Camera dialogue or from the INDI interface ??
However, I connected via INDI interface and things came to life :)

But then.. I could not get a pic from the camera... after a couple of tries everything just dissaperas and left a message :

No INDI telescope is set.  Please set INDImount in the preferences file
*** Error in `phd2': free(): invalid pointer: 0x0a7008b8 ***
Aborted (core dumped)

I would guess that this is the aftermath of the first step to make a gear selection that didn't work..??

I submit my errorlog so maybe someone can do some debugging.. and of course I'll do some more testing if required!!

Br
/Markku
PHD2_DebugLog_2014-09-08_194159.txt

Hans

unread,
Sep 8, 2014, 2:53:19 PM9/8/14
to open-phd...@googlegroups.com
Hi Markku,



On Monday, 8 September 2014 20:16:33 UTC+2, Markku Siitonen wrote:
The first light dialogue came up, pressing "Next>" result was dumping core.. but if I just pressed that dialogue away it stayed alive, but I think something will be missing in the configuration then..??

Which dialog is this exactly ?

Connected to my remote observatory via VPN/SSH, started up INDI as usual, started up PHD2 on local machine and entered IP, pressed "Connect" and the devices showed up in the droplist, selected INDI camera wich is a Lodestar and my mount wich is a EQ8 and INDI menus turned up :)

Good. The next step is to click the 'connect equipment' camera icon (lower left) , and select 'indi mount' and 'indi camera' in there. Then press 'connect all' and close that dialog. Then you should be able to get images from your camera when you press the just enabled 'begin looping' button.

Does this work for you ?

ps. thanks for testing ! We definitely need more Linux volunteers for PHD2.

-- Hans

Markku Siitonen

unread,
Sep 8, 2014, 3:31:27 PM9/8/14
to open-phd...@googlegroups.com

Hi Hans..

This is the wizard..


and when I press "Next>" button I get this at console :

(phd2:6699): Gdk-CRITICAL **: IA__gdk_pixbuf_get_from_drawable: assertion 'src_x + width <= src_width && src_y + height <= src_height' failed

(phd2:6699): Gdk-CRITICAL **: IA__gdk_pixbuf_get_from_drawable: assertion 'src_x + width <= src_width && src_y + height <= src_height' failed

(phd2:6699): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_pixels: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(phd2:6699): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_rowstride: assertion 'GDK_IS_PIXBUF (pixbuf)' failed
Segmentation fault (core dumped)


Seems to have something to do with GDK pixbuf, ??

/Markku

Markku Siitonen

unread,
Sep 9, 2014, 1:03:33 PM9/9/14
to open-phd...@googlegroups.com
Hi Hans.

Now to the second part..

Just did "Connect all" ans you wrote, and Only the camera was connected.. the INDI Mount is greyed (Connected) out but the statusline says Scope connected and No cam.. so a bit confusing.. :)  and I can't connect the cam, and can't disconnect the mount.

The second time I tried all from the begining it connects the mount but not the cam, and this time the statusline also says Scope connected and No cam, witch is true..

After a couple of more tries the cam connects but the mount does not, after that I pressed the "Begin looping.." but no pics :( at the commandline I get :

Camera is ready
Camera connected state: 1
Exposing for 1000(ms)
ERROR: Camera_INDIClass::Capture timeout, trying to continue
Exposing for 1000(ms)
ERROR: Camera_INDIClass::Capture timeout, trying to continue

That's about as far I can get for now.

Br
/Markku

Chris Ryan

unread,
Sep 11, 2014, 6:50:11 AM9/11/14
to open-phd...@googlegroups.com
I'm also investigating using PHD2 and Linux and got the same problem hitting the "Next" button on the wizard.

I rebuilt the code with DEBUG enabled and got this:

08:38:07 PM: Debug: Failed to connect to session manager: SESSION_MANAGER
environment variable
not defined
[New Thread 0x7fffec64a700 (LWP 3161)]
[New Thread 0x7fffebe49700 (LWP 3162)]

(phd2:3147): Gdk-CRITICAL **: IA__gdk_pixbuf_get_from_drawable: assertion
'src_x + width <= src_width && src_y + height <= src_height' failed

(phd2:3147): Gdk-CRITICAL **: IA__gdk_pixbuf_get_from_drawable: assertion
'src_x + width <= src_width && src_y + height <= src_height' failed

(phd2:3147): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_pixels: assertion
'GDK_IS_PIXBUF (pixbuf)' failed

(phd2:3147): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_rowstride: assertion
'GDK_IS_PIXBUF (pixbuf)' failed

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff74a2043 in wxBitmap::GetPixbuf() const () from
/usr/lib64/libwx_gtk2u_core-3.0.so.0


I did a backtrace and have attached the output.

Hope that helps.

I'm going to attempt to go further and bypass the starting wizard and see how it goes.

Chris
phd2_debug2.txt

Chris Ryan

unread,
Sep 11, 2014, 8:05:10 AM9/11/14
to open-phd...@googlegroups.com
My further attempts to use the system were very similar to Markku's.  I could see my camera under INDI (SBig ST-i) but couldn't connect to it.  I was using the telescope simulator and it appeared to connect to it.

Chris

Patrick Chevalley

unread,
Sep 15, 2014, 2:52:43 PM9/15/14
to open-phd...@googlegroups.com
I am also trying PHD2 on Linux and I must say I am impressed by the result.

Compilation work fine on Kubuntu 14.04 using the instruction on the wiki. Just not need to install wxwidgets 3.0 manually as it is packaged now.

Then I run the program and get the same error with the equipment wizard. Fortunately it not show on the second run and let you configure manually.

As I am testing indoor I only connect my DMK21 and add the indi telescope simulator, with the following command:  indiserver -vv indi_v4l2_ccd indi_simulator_telescope

Then run phd2 and click the Equipement button, select "INDI camera" and "INDI mount", but do not click Connect for now, close this window.
Now click the menu INDI / Configure, click Connect, select "V4L2 CCD" for the camera driver and type /dev/video0 for the camera port. Select "Telescope Simulator" for the telescope driver. Click OK.
Click the Equipment button again and click Connect, both camera and mount connect immediately.
Doing the thing in this order make it work every time.

Then I tested mostly the camera and all work fine. Looping the images, it react correctly to exposure time change.
To access the specific camera properties I use the menu INDI / Controls. I tested to change the values for the Gain and Gamma, the effect on the image is as expected.

I am now waiting for better weather to test outside with a real mount.

Patrick Chevalley

unread,
Sep 16, 2014, 7:37:21 AM9/16/14
to open-phd...@googlegroups.com
A few more daylight testing today.
I connect my Atik314 with indi_atik_ccd instead of the DMK21 and immediately get the message:

ERROR: Camera_INDIClass::Capture timeout, trying to continue
Using a 0.1 second exposure time solve the problem but anything above 0.5 produce the error.

Looking at the source code I remark a hardcoded 3 seconds timeout in cam_INDI.cpp.
This is not enough to account for the exposure time added to the image download time by most CCD camera.
I change the value to 30 seconds and the camera worked normally.

Finally I make the following change with a timeout equal to the exposure time + 5 seconds:

Index: cam_INDI.cpp
===================================================================
--- cam_INDI.cpp        (revision 1120)
+++ cam_INDI.cpp        (working copy)
@@ -261,7 +261,7 @@
     }
     modal = true;
     msec = wxGetLocalTimeMillis();
-    while(modal && wxGetLocalTimeMillis() - msec < 3 * 1000) {
+    while(modal && wxGetLocalTimeMillis() - msec < (duration + 5 * 1000) ) {
         wxGetApp().Yield();
     }
     if (modal) {

Tell me if there is a better way than this forum to submit a patch.

Patrick


Andy Galasso

unread,
Sep 16, 2014, 10:56:25 AM9/16/14
to Patrick Chevalley, open-phd...@googlegroups.com
Hi Patrick,

Thanks for sending the patch. I will add you to the committer list so you can commit it yourself.

I believe Hans is working on INDI changes on a branch (newindi), so you should coordinate the change with Hans to see if he wants the change on trunk or in newindi.

While you are making the change, you should get rid of the wxGetApp().Yield().  The Capture() is happening in a worker thread and is allowed to block (since HasNonGuiCapture() is true).   wxGetApp().Yield() is a no-op for threads other than the main GUI thread, so that while loop is a busy loop, not good.

A better way would be to do something like wxMilliSleep(msec), then poll modal every 10ms or so until modal is cleared or the timeout.  Most of the other cameras do it that way (see for example cam_ascomlate.cpp.)

Andy

Patrick Chevalley

unread,
Sep 16, 2014, 3:46:56 PM9/16/14
to open-phd...@googlegroups.com
Hi Andy,

Thank you for your response, I will contact Hans.

I try to change the way it wait for the end of the exposure but it is not possible to wait as with the ascom driver because the indi client need to be active to receive the status change from the server, so using wxMilliSleep for the duration of the exposure do not work.

But it work to add
wxMilliSleep(10) along with wxGetApp().Yield()  in the loop and the cpu consumption drop drastically.

Patrick

Andy Galasso

unread,
Sep 16, 2014, 5:46:20 PM9/16/14
to Patrick Chevalley, open-phd...@googlegroups.com
Thanks, Patrick,

I guess I do not understand what is going on there because wxGetApp().Yield() really does nothing at all in the worker thread where Camera_INDIClass::Capture() is invoked (see implementation of PhdApp::Yield() in phd.cpp.)  Maybe Hans can explain it...

Cheers,
Andy

Patrick Chevalley

unread,
Sep 17, 2014, 9:47:36 AM9/17/14
to open-phd...@googlegroups.com, p...@ap-i.net
You are right with Yield() behavior.
I need to look more in detail at the code and I plan more stepping debug session to understand how it work.
But wxWidgets is not my usual development environment so this may take some time.

After a first look today I find that indi_io.cpp which handle the socket used for the connection to the indi server is a wxFrame:
//wxWidgets doesn't have a non-gui class that will receive idle events
//so we use a wxFrame which will never be shown
class IndiIO : public wxFrame

Maybe in this case HasNonGuiCapture() must be false ?
This may make wxGetApp().Yield() to really do something.

Patrick

Patrick Chevalley

unread,
Sep 17, 2014, 5:21:52 PM9/17/14
to open-phd...@googlegroups.com, p...@ap-i.net
I think I better understand how the exposure wait loop work now.
It is absolutely necessary that the message from the server are read during the exposure to set modal=false when the camera status change from busy to ok. This is why
wxMilliSleep(duration-100) cannot work with INDI.

I also put a break point in io_indi_sock_read() during a long exposure and look at the backtrace to understand who call the event if this is not
Yield().

If HasNonGuiCapture() is  true, wxGetApp().Yield() do nothing as expected but
io_indi_sock_read() is called by a event handler initiated by wxApp::DoIdle(). The CPU consumption is 100% during the whole exposure time. This is the actual state.

Replacing
wxGetApp().Yield() in the loop by wxMilliSleep(1) reduce the CPU consumption to about 1%. The event call chain is the same as previously: 
    while(modal && wxGetLocalTimeMillis() - msec < (duration + 5 * 1000)) {

       wxMilliSleep
(1);    
 
    }

bool Camera_INDIClass::HasNonGuiCapture(void) {
   
return true;
}

bt:
#0 io_indi_sock_read() at /home/pch/source/phd2/open-phd-guiding/libindiclient/wx/indi_io.cpp:102
...
#10 wxAppConsoleBase::ProcessPendingEvents()() at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#11 wxApp::DoIdle()() at /usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0


if HasNonGuiCapture() is false, wxGetApp().Yield() work and the event is initiated by  PhdApp::Yield(). The CPU consumption is 100% but this can be solved by adding wxMilliSleep(1) to the loop:
    while(modal && wxGetLocalTimeMillis() - msec < (duration + 5 * 1000)) {
       wxGetApp().Yield();
       wxMilliSleep(1);    
   
}

bool Camera_INDIClass::HasNonGuiCapture(void) {
   
return false;
}
bt:
#0 io_indi_sock_read() at /home/pch/source/phd2/open-phd-guiding/libindiclient/wx/indi_io.cpp:102
...
#10 wxAppConsoleBase::ProcessPendingEvents()() at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#11 wxGUIEventLoop::YieldFor(long)() at /usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#12 PhdApp::Yield() at /home/pch/source/phd2/open-phd-guiding/phd.cpp:199


Any preference on this two choice?

I prefer how the event is called by the second method but I will be tempted by the first one that make less change and avoid any side effect when changing
HasNonGuiCapture() value.

Patrick

Andy Galasso

unread,
Sep 17, 2014, 6:07:06 PM9/17/14
to open-phd...@googlegroups.com
Patrick,

Thanks for digging in and explaining that.  So to summarize: the main UI thread is handling the callback and setting modal to false, while the camera thread (worker thread) is spinning and polling the value of modal.

I think a cleaner way to do it would be to replace "modal" with a wxSemaphore and have the camera thread wait (with timeout) on the semaphore. That will be more efficient than polling, but a much bigger change. A less efficient, easier fix would be to poll at ~10 ms. 

while (modal && wxGetLocalTimeMillis() - msec < (duration + 5 * 1000))
    wxMilliSleep(10);

We really do not want to consider having HasNonGuiCapture return false, since that would move Capture into the main UI thread which is undesirable.

Cheers,
Andy

Patrick Chevalley

unread,
Sep 18, 2014, 11:42:49 AM9/18/14
to open-phd...@googlegroups.com
Andy,

I do this way and commit the change in subversion.
I just do add a small change to use wxMilliSleep(10) only for exposure longer than 100ms and wxMilliSleep(1) for the shorter, otherwise I get a timeout error frequently with the minimal exposure time.

Now I can return to what make me interested by PHD on Linux at first.
I am the developer of Cartes du Ciel planetarium and I want to add a function to set the PHD lock shift parameters based on the current movement of the comets or asteroids. The first testing with the simulator look promising but now I need real testing and this is more easy for me on Linux where I have my full development environment.

Patrick


Andy Galasso

unread,
Sep 18, 2014, 12:29:16 PM9/18/14
to open-phd...@googlegroups.com
Thanks, Patrick, that change looks good.

BTW I am a huge fan of Cartes du Ciel, I use it every day!

That is exciting to hear about the integration of lock shifting with CdC comet data.  Very cool idea!

I was also considering adding a comet tracking training mode where you center your imaging camera on the comet, wait for a few minutes, then center the comet again. PHD2 would compute the shift parameters based on the motion of a guide star in the interval.   It think having both comet modes (training mode and CDC orbital data mode) would be complementary, and great to have both.

Andy

Patrick Chevalley

unread,
Nov 1, 2014, 12:19:35 PM11/1/14
to open-phd...@googlegroups.com
Hi,

I make a few improvement to the Linux/INDI use this last month and today I include INDI in the profile manager so it is much more easy to use.

What is working now:
You can define many different INDI profile and load the one you want, then use the Connect or Connect All button.
I can successfully run a full calibration and guiding session using the INDI simulators for telescope and camera with the GSC catalog to plot the stars.

Limitation:
You can only connect to a single INDI server at a time, so all the drivers must run on the same INDI server.

Bug:
You cannot create a dark library.
It look like the INDI client message reception is locked by the dark dialog modal window.
Maybe it is best to finalize the move to the new INDI client before to try to solve that.

Patrick

Andy Galasso

unread,
Nov 2, 2014, 9:03:15 AM11/2/14
to Patrick Chevalley, OpenPHD Guiding
Great work!

Reply all
Reply to author
Forward
0 new messages