How to detect a scan time out on Linux

The default time out for the scan of a page on Linux is 5000ms, but how can you detect if a time out has occurred?

The following snippet of C code can be used in bardecode.c at the end of the main function…

        uint16 t;
        STGetParameter(hBarcode, ST_DID_TIMEOUT, &t) ;
        if (t)
                printf (“Scan timed out\n”) ;
        else
                printf (“Scan completed without time out\n”) ;

This might mean that you would get the following outputs (depending on the speed of your system)…

$ ./bardecode ~/tmp/image.jpg –TimeOut 1000
123456
Scan timed out
$ ./bardecode ~/tmp/image.jpg –TimeOut 5000
123456
Scan completed without time out

The first call to bardecode used a 1 second time out where as the second used the default of 5s. Note that the fact a time out occurred doesn’t mean that the library wasn’t able to find a bar code, it just means that it didn’t complete a scan of the entire page.