Index: libindi/drivers/video/v4l2driver.cpp =================================================================== --- libindi/drivers/video/v4l2driver.cpp (revision 1596) +++ libindi/drivers/video/v4l2driver.cpp (working copy) @@ -63,7 +63,7 @@ addDebugControl(); /* Port */ - IUFillText(&PortT[0], "PORT", "Port", "/dev/video0"); + IUFillText(&PortT[0], "PORT", "Port", "/dev/video1"); IUFillTextVector(&PortTP, PortT, NARRAY(PortT), getDeviceName(), "DEVICE_PORT", "Ports", OPTIONS_TAB, IP_RW, 0, IPS_IDLE); /* Video Stream */ @@ -614,12 +614,17 @@ frameCount=0; gettimeofday(&capture_start, NULL); if (lx->isenabled()) { - //startlongexposure(ExposeTimeN[0].value); - rc=startlongexposure(V4LFrame->expose); + rc=startlongexposure(V4LFrame->expose); if (rc == false) - DEBUG(INDI::Logger::DBG_WARNING, "Unable to start long exposure, falling back to auto exposure."); - } else - v4l_base->start_capturing(errmsg); + DEBUG(INDI::Logger::DBG_WARNING, "Unable to start long exposure, falling back to auto exposure."); + else { + if( lx->getLxmode() == LXSERIAL ) { + v4l_base->start_capturing( errmsg ); + } + } + } + else + v4l_base->start_capturing(errmsg); ExposeTimeNP->s = IPS_BUSY; if (IUUpdateNumber(ExposeTimeNP, values, names, n) < 0) @@ -706,6 +711,7 @@ bool V4L2_Driver::startlongexposure(double timeinsec) { lxtimer=IEAddTimer((int)(timeinsec*1000.0), (IE_TCF *)lxtimerCallback, this); + v4l_base->setlxstate( LX_ACCUMULATING ); return (lx->startLx()); } @@ -714,8 +720,10 @@ char errmsg[ERRMSGSIZ]; V4L2_Driver *p = (V4L2_Driver *)userpointer; p->lx->stopLx(); + p->v4l_base->setlxstate( LX_TRIGGERED ); IERmTimer(p->lxtimer); - p->v4l_base->start_capturing(errmsg); // jump to new/updateFrame + if( !p->v4l_base->isstreamactive() ) + p->v4l_base->start_capturing(errmsg); // jump to new/updateFrame } bool V4L2_Driver::UpdateCCDBin(int hor, int ver) Index: libindi/drivers/video/v4l2driver.h =================================================================== --- libindi/drivers/video/v4l2driver.h (revision 1596) +++ libindi/drivers/video/v4l2driver.h (working copy) @@ -66,7 +66,6 @@ #define TEMPFILE_LEN 16 - class V4L2_Driver: public INDI::CCD { public: @@ -85,7 +84,7 @@ static void newFrame(void *p); void updateFrame(); - + protected: virtual bool Connect(); @@ -191,6 +190,7 @@ int lxtimer; bool startlongexposure(double timeinsec); static void lxtimerCallback(void *userpointer); + short lxstate; }; #endif Index: libindi/libs/lx/Lx.cpp =================================================================== --- libindi/libs/lx/Lx.cpp (revision 1596) +++ libindi/libs/lx/Lx.cpp (working copy) @@ -38,10 +38,10 @@ //IUFillSwitch(&LxModeS[LXGPIO], "GPIO (Arm/RPI)", "", ISS_OFF); // IUFillSwitch(&LxModeS[4], "IndiDuino Switcher", "", ISS_OFF); // Snooping is not enough IUFillSwitchVector(&LxModeSP, LxModeS, NARRAY(LxModeS), device_name, "LX Mode", "", LX_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); - IUFillText(&LxPortT[0], "Port", "", "/dev/ttyS0"); + IUFillText(&LxPortT[0], "Port", "", "/dev/ttyUSB0"); IUFillTextVector(&LxPortTP, LxPortT, NARRAY(LxPortT), device_name, "Lx port", "", LX_TAB, IP_RW, 0, IPS_IDLE); - IUFillSwitch(&LxSerialOptionS[0], "Use DTR (pin 4)", "", ISS_ON); - IUFillSwitch(&LxSerialOptionS[1], "Use RTS (pin 7)", "", ISS_OFF); + IUFillSwitch(&LxSerialOptionS[0], "Use DTR (pin 4)", "", ISS_OFF); + IUFillSwitch(&LxSerialOptionS[1], "Use RTS (pin 7)", "", ISS_ON); IUFillSwitch(&LxSerialOptionS[2], "Use Serial command", "", ISS_OFF); IUFillSwitchVector(&LxSerialOptionSP, LxSerialOptionS, NARRAY(LxSerialOptionS), device_name, "Serial Options", "", LX_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); IUFillSwitch(&LxParallelOptionS[0], "Use Data 0 (pin 2)", "", ISS_OFF); @@ -285,6 +285,10 @@ return true; // not ours, don't care } +unsigned int Lx::getLxmode() { + return IUFindOnSwitchIndex(&LxModeSP); +} + bool Lx::startLx() { unsigned int index; IDMessage(device_name, "Starting Long Exposure"); Index: libindi/libs/lx/Lx.h =================================================================== --- libindi/libs/lx/Lx.h (revision 1596) +++ libindi/libs/lx/Lx.h (working copy) @@ -57,7 +57,9 @@ bool updateProperties(); bool startLx(); int stopLx(); +unsigned int getLxmode(); + private: INDI::DefaultDevice *dev; const char *device_name; Index: libindi/libs/webcam/v4l2_base.cpp =================================================================== --- libindi/libs/webcam/v4l2_base.cpp (revision 1596) +++ libindi/libs/webcam/v4l2_base.cpp (working copy) @@ -320,9 +320,15 @@ if (-1 == xioctl (fd, VIDIOC_QBUF, &buf)) return errno_exit ("ReadFrame IO_METHOD_MMAP: VIDIOC_QBUF", errmsg); + if( lxstate == LX_ACTIVE ) { + /* Call provided callback function if any */ if (callback) (*callback)(uptr); + } + + if( lxstate == LX_TRIGGERED ) + lxstate = LX_ACTIVE; break; @@ -399,6 +405,7 @@ if (cropset && cropbuf) { free(cropbuf); cropbuf=NULL; } + streamactive = false; return 0; } @@ -438,7 +445,8 @@ - selectCallBackID = IEAddCallback(fd, newFrame, this); + selectCallBackID = IEAddCallback(fd, newFrame, this); + streamactive = true; break; @@ -952,6 +960,8 @@ allocBuffers(); + lxstate = LX_ACTIVE; + switch (io) { case IO_METHOD_READ: Index: libindi/libs/webcam/v4l2_base.h =================================================================== --- libindi/libs/webcam/v4l2_base.h (revision 1596) +++ libindi/libs/webcam/v4l2_base.h (working copy) @@ -32,6 +32,13 @@ #define VIDEO_COMPRESSION_LEVEL 4 +enum { + LX_ACTIVE = 0, + LX_TRIGGERED, + LX_ACCUMULATING +}; + + class V4L2_Base { public: @@ -100,6 +107,10 @@ int setcroprect(int x, int y, int w, int h, char *errmsg); struct v4l2_rect getcroprect(); + void setlxstate( short s ) { lxstate = s; } + short getlxstate() { return lxstate; } + bool isstreamactive() { return streamactive; } + protected: int xioctl(int fd, int request, void *arg); @@ -134,6 +145,9 @@ bool cropset; bool cansetrate; bool streamedonce; + bool streamactive; + + short lxstate; struct v4l2_queryctrl queryctrl; struct v4l2_querymenu querymenu;