niimaqsrc: Report on IMAQ error strings
This should probably be done as a #DEFINE GST_IMAQ_DEBUG or something instead of as a function.
This commit is contained in:
parent
bfdbf89aa8
commit
9b78e8c0f9
@ -119,6 +119,16 @@ static gboolean gst_niimaqsrc_set_caps_framesize (GstStructure * gs, gint width,
|
|||||||
|
|
||||||
static GstCaps *gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * src);
|
static GstCaps *gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * src);
|
||||||
|
|
||||||
|
uInt32
|
||||||
|
gst_niimaqsrc_report_imaq_error (uInt32 code) {
|
||||||
|
static char imaq_error_string[256];
|
||||||
|
if (code) {
|
||||||
|
imgShowError (code, imaq_error_string);
|
||||||
|
GST_ERROR ("IMAQ error: %s", imaq_error_string);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static void _____BEGIN_FUNCTIONS_____();
|
static void _____BEGIN_FUNCTIONS_____();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,22 +186,29 @@ gst_niimaqsrc_class_probe_interfaces (GstNiImaqSrcClass * klass, gboolean check)
|
|||||||
guint32 nports;
|
guint32 nports;
|
||||||
guint32 port;
|
guint32 port;
|
||||||
gchar * iname;
|
gchar * iname;
|
||||||
|
uInt32 rval;
|
||||||
|
|
||||||
/* get interface names until there are no more */
|
/* get interface names until there are no more */
|
||||||
if (imgInterfaceQueryNames (n, name) != 0)
|
if (rval = imgInterfaceQueryNames (n, name) != 0) {
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* ignore NICFGen */
|
/* ignore NICFGen */
|
||||||
if (g_strcmp0 (name, "NICFGen.iid") == 0)
|
if (g_strcmp0 (name, "NICFGen.iid") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* try and open the interface */
|
/* try and open the interface */
|
||||||
if (imgInterfaceOpen (name, &iid) != 0)
|
if (rval = imgInterfaceOpen (name, &iid) != 0) {
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* find how many ports the interface provides */
|
/* find how many ports the interface provides */
|
||||||
imgGetAttribute (iid, IMG_ATTR_NUM_PORTS, &nports);
|
rval = imgGetAttribute (iid, IMG_ATTR_NUM_PORTS, &nports);
|
||||||
imgClose (iid, TRUE);
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
|
rval = imgClose (iid, TRUE);
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
|
|
||||||
/* iterate over all the available ports */
|
/* iterate over all the available ports */
|
||||||
for (port=0; port < nports; port++) {
|
for (port=0; port < nports; port++) {
|
||||||
@ -626,6 +643,7 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
GST_LOG_OBJECT (src, "camera is still off , wait 50ms and retry");
|
GST_LOG_OBJECT (src, "camera is still off , wait 50ms and retry");
|
||||||
g_usleep (50000);
|
g_usleep (50000);
|
||||||
}
|
}
|
||||||
@ -637,13 +655,17 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
|||||||
("Camera doesn't seem to want to turn on!"),
|
("Camera doesn't seem to want to turn on!"),
|
||||||
("Camera doesn't seem to want to turn on!"));
|
("Camera doesn't seem to want to turn on!"));
|
||||||
|
|
||||||
if (src->sid)
|
if (src->sid) {
|
||||||
imgClose (src->sid,TRUE);
|
rval = imgClose (src->sid,TRUE);
|
||||||
src->sid = 0;
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
|
src->sid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (src->iid)
|
if (src->iid) {
|
||||||
imgClose (src->iid,TRUE);
|
rval = imgClose (src->iid,TRUE);
|
||||||
src->iid = 0;
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
|
src->iid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
@ -657,9 +679,10 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
|||||||
rval = imgSessionCopyBufferByNumber (src->sid, src->cumbufnum, data,
|
rval = imgSessionCopyBufferByNumber (src->sid, src->cumbufnum, data,
|
||||||
IMG_OVERWRITE_GET_OLDEST, &copied_number, &copied_index);
|
IMG_OVERWRITE_GET_OLDEST, &copied_number, &copied_index);
|
||||||
if (rval) {
|
if (rval) {
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||||
("failed to copy buffer %d", src->cumbufnum),
|
("failed to copy buffer %d", src->cumbufnum),
|
||||||
("failed to copy buffer %d", src->cumbufnum));
|
("failed to copy buffer %d, IMAQ error: \"%s\"", src->cumbufnum));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -819,12 +842,16 @@ gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * src)
|
|||||||
|
|
||||||
/* retrieve caps from IMAQ interface */
|
/* retrieve caps from IMAQ interface */
|
||||||
rval = imgGetAttribute (src->iid, IMG_ATTR_BITSPERPIXEL, &val);
|
rval = imgGetAttribute (src->iid, IMG_ATTR_BITSPERPIXEL, &val);
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
bpp = val;
|
bpp = val;
|
||||||
rval &= imgGetAttribute (src->iid, IMG_ATTR_BYTESPERPIXEL, &val);
|
rval &= imgGetAttribute (src->iid, IMG_ATTR_BYTESPERPIXEL, &val);
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
depth = val*8;
|
depth = val*8;
|
||||||
rval &= imgGetAttribute (src->iid, IMG_ATTR_ROI_WIDTH, &val);
|
rval &= imgGetAttribute (src->iid, IMG_ATTR_ROI_WIDTH, &val);
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
width = val;
|
width = val;
|
||||||
rval &= imgGetAttribute (src->iid, IMG_ATTR_ROI_HEIGHT, &val);
|
rval &= imgGetAttribute (src->iid, IMG_ATTR_ROI_HEIGHT, &val);
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
height = val;
|
height = val;
|
||||||
|
|
||||||
if (rval) {
|
if (rval) {
|
||||||
@ -883,9 +910,7 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
|||||||
{
|
{
|
||||||
GstNiImaqSrc* filter = GST_NIIMAQSRC(src);
|
GstNiImaqSrc* filter = GST_NIIMAQSRC(src);
|
||||||
Int32 rval;
|
Int32 rval;
|
||||||
gboolean ret;
|
|
||||||
gint i;
|
gint i;
|
||||||
GstPad * pad;
|
|
||||||
|
|
||||||
filter->iid = 0;
|
filter->iid = 0;
|
||||||
filter->sid = 0;
|
filter->sid = 0;
|
||||||
@ -895,6 +920,7 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
|||||||
/* open IMAQ interface */
|
/* open IMAQ interface */
|
||||||
rval=imgInterfaceOpen(filter->interface_name,&(filter->iid));
|
rval=imgInterfaceOpen(filter->interface_name,&(filter->iid));
|
||||||
if (rval) {
|
if (rval) {
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to open IMAQ interface"),
|
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to open IMAQ interface"),
|
||||||
("Failed to open camera interface %s", filter->interface_name));
|
("Failed to open camera interface %s", filter->interface_name));
|
||||||
goto error;
|
goto error;
|
||||||
@ -905,6 +931,7 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
|||||||
/* open IMAQ session */
|
/* open IMAQ session */
|
||||||
rval=imgSessionOpen(filter->iid, &(filter->sid));
|
rval=imgSessionOpen(filter->iid, &(filter->sid));
|
||||||
if (rval) {
|
if (rval) {
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to open IMAQ session"),
|
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to open IMAQ session"),
|
||||||
("Failed to open camera session %d", filter->sid));
|
("Failed to open camera session %d", filter->sid));
|
||||||
goto error;
|
goto error;
|
||||||
@ -932,6 +959,7 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
|||||||
}
|
}
|
||||||
rval=imgRingSetup (filter->sid, filter->bufsize, (void**)(filter->buflist), 0, FALSE);
|
rval=imgRingSetup (filter->sid, filter->bufsize, (void**)(filter->buflist), 0, FALSE);
|
||||||
if (rval) {
|
if (rval) {
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to create ring buffer"),
|
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to create ring buffer"),
|
||||||
("Failed to create ring buffer with %d buffers", filter->bufsize));
|
("Failed to create ring buffer with %d buffers", filter->bufsize));
|
||||||
goto error;
|
goto error;
|
||||||
@ -940,6 +968,7 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
|||||||
/*GST_LOG_OBJECT (filter, "Registering callback functions");
|
/*GST_LOG_OBJECT (filter, "Registering callback functions");
|
||||||
rval=imgSessionWaitSignalAsync2(filter->sid, IMG_SIGNAL_STATUS, IMG_BUF_COMPLETE, IMG_SIGNAL_STATE_RISING, Imaq_BUF_COMPLETE, filter);
|
rval=imgSessionWaitSignalAsync2(filter->sid, IMG_SIGNAL_STATUS, IMG_BUF_COMPLETE, IMG_SIGNAL_STATE_RISING, Imaq_BUF_COMPLETE, filter);
|
||||||
if(rval) {
|
if(rval) {
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to register BUF_COMPLETE callback"),
|
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to register BUF_COMPLETE callback"),
|
||||||
("Failed to register BUF_COMPLETE callback"));
|
("Failed to register BUF_COMPLETE callback"));
|
||||||
goto error;
|
goto error;
|
||||||
@ -949,12 +978,16 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
/* close IMAQ session and interface */
|
/* close IMAQ session and interface */
|
||||||
if(filter->sid)
|
if(filter->sid) {
|
||||||
imgClose(filter->sid,TRUE);
|
rval = imgClose(filter->sid,TRUE);
|
||||||
filter->sid = 0;
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
if(filter->iid)
|
filter->sid = 0;
|
||||||
imgClose(filter->iid,TRUE);
|
}
|
||||||
filter->iid = 0;
|
if(filter->iid) {
|
||||||
|
rval = imgClose(filter->iid,TRUE);
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
|
filter->iid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;;
|
return FALSE;;
|
||||||
|
|
||||||
@ -977,6 +1010,7 @@ gst_niimaqsrc_stop (GstBaseSrc * src)
|
|||||||
/* stop IMAQ session */
|
/* stop IMAQ session */
|
||||||
rval = imgSessionStopAcquisition (filter->sid);
|
rval = imgSessionStopAcquisition (filter->sid);
|
||||||
if (rval) {
|
if (rval) {
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Unable to stop acquisition"),
|
GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Unable to stop acquisition"),
|
||||||
("Unable to stop acquisition"));
|
("Unable to stop acquisition"));
|
||||||
}
|
}
|
||||||
@ -985,12 +1019,16 @@ gst_niimaqsrc_stop (GstBaseSrc * src)
|
|||||||
GST_DEBUG_OBJECT (filter, "Acquisition stopped");
|
GST_DEBUG_OBJECT (filter, "Acquisition stopped");
|
||||||
|
|
||||||
/* close IMAQ session and interface */
|
/* close IMAQ session and interface */
|
||||||
if(filter->sid)
|
if(filter->sid) {
|
||||||
imgClose(filter->sid,TRUE);
|
rval = imgClose(filter->sid,TRUE);
|
||||||
filter->sid = 0;
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
if(filter->iid)
|
filter->sid = 0;
|
||||||
imgClose(filter->iid,TRUE);
|
}
|
||||||
filter->iid = 0;
|
if(filter->iid) {
|
||||||
|
rval = imgClose(filter->iid,TRUE);
|
||||||
|
gst_niimaqsrc_report_imaq_error (rval);
|
||||||
|
filter->iid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (filter, "IMAQ interface closed");
|
GST_DEBUG_OBJECT (filter, "IMAQ interface closed");
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user