[sane-devel] Fwd: [sane-commit] [SCM] SANE backends - scanner drivers branch, master, updated. RELEASE_1_0_22-179-g1e4595c
Chris Bagwell
chris at cnpbagwell.com
Thu Nov 10 13:31:36 UTC 2011
Yiks. How did I get a "u" as only a 1000 in my head. The test scans
worked so maybe the original values were a little high.
Anyways, this means I also messed up a patch for umax-pp.
I'll go the opposite direction since it proved to be confusing at
least once to me. I'll create a posix compatible sleep() using usleep
for platforms that do not have it and then people can more comfortably
think in seconds when needed.
Then I'll revert all my sleep->usleep changes.
Thanks much!
Chris
On Wed, Nov 9, 2011 at 10:47 PM, Stef <stef.dev at free.fr> wrote:
> Hello,
>
> since usleep() time value is expressed in microseconds, I think
> sleep(5) should be replaced by usleep(5000000UL). usleep(5000) is too
> short.
>
> Regards,
> Stef
>
> ---------- Forwarded message ----------
> From: Chris Bagwell <chris at cnpbagwell.com>
> To: sane-commit at lists.alioth.debian.org
> Date: Thu, 10 Nov 2011 04:00:08 +0000
> Subject: [sane-commit] [SCM] SANE backends - scanner drivers branch, master, updated. RELEASE_1_0_22-179-g1e4595c
> The following commit has been merged in the master branch:
> commit 50475719ef40038b4c73e13dc164d72b9995527e
> Author: Chris Bagwell <chris at cnpbagwell.com>
> Date: Wed Nov 9 21:50:18 2011 -0600
>
> portabilty mods to epson2 backend
>
> No behavior changes. Wrap some optional headers with #ifdef's and
> use usleep() instead of sleep() since it exist everywhere.
>
> diff --git a/backend/epson2-ops.c b/backend/epson2-ops.c
> index 575340c..e53f33c 100644
> --- a/backend/epson2-ops.c
> +++ b/backend/epson2-ops.c
> @@ -20,9 +20,9 @@
> #include "sane/config.h"
>
> #include <unistd.h> /* sleep */
> -
> +#ifdef HAVE_SYS_SELECT_H
> #include <sys/select.h>
> -
> +#endif
>
> #include "byteorder.h"
>
> @@ -1439,7 +1439,7 @@ e2_wait_button(Epson_Scanner * s)
> if (button_status)
> s->hw->wait_for_button = SANE_FALSE;
> else
> - sleep(1);
> + usleep(1000);
> } else {
> /* we run into an error condition, just continue */
> s->hw->wait_for_button = SANE_FALSE;
> @@ -1533,7 +1533,7 @@ e2_wait_warm_up(Epson_Scanner * s)
> s->retry_count);
> return SANE_STATUS_DEVICE_BUSY;
> }
> - sleep(5);
> + usleep(5000);
> }
>
> return SANE_STATUS_GOOD;
> @@ -1816,7 +1816,7 @@ read_info_block(Epson_Scanner * s, EpsonDataRec * result)
> if (ext_status[0] & EXT_STATUS_WU) {
> free(ext_status);
>
> - sleep(5); /* for the next attempt */
> + usleep(5000); /* for the next attempt */
>
> DBG(1, "retrying ESC G - %d\n", ++(s->retry_count));
>
> diff --git a/backend/epson2.c b/backend/epson2.c
> index bdd9c27..a07510f 100644
> --- a/backend/epson2.c
> +++ b/backend/epson2.c
> @@ -389,8 +389,6 @@ e2_network_discovery(void)
>
> struct timeval to;
>
> - long save_flags, flags;
> -
> status = sanei_udp_open_broadcast(&fd);
> if (status != SANE_STATUS_GOOD)
> return;
> @@ -405,9 +403,7 @@ e2_network_discovery(void)
> FD_ZERO(&rfds);
> FD_SET(fd, &rfds);
>
> - save_flags = flags = fcntl(fd, F_GETFL, 0L);
> - flags |= O_NONBLOCK;
> - fcntl(fd, F_SETFL, flags);
> + sanei_udp_set_nonblock(fd, SANE_TRUE);
> if (select(fd + 1, &rfds, NULL, NULL, &to) > 0) {
> while ((len = sanei_udp_recvfrom(fd, buf, 76, &ip)) == 76) {
> DBG(5, " response from %s\n", ip);
> @@ -417,7 +413,6 @@ e2_network_discovery(void)
> attach_one_net(ip);
> }
> }
> - fcntl(fd, F_SETFL, save_flags);
>
> DBG(5, "%s, end\n", __func__);
>
> @@ -650,7 +645,7 @@ device_detect(const char *name, int type, SANE_Status *status)
> * sleep a bit.
> */
> if (dev->connection == SANE_EPSON_NET)
> - sleep(1);
> + usleep(1000);
>
> return scanner_create(dev, status);
> }
> diff --git a/backend/epson2.h b/backend/epson2.h
> index b448784..807251a 100644
> --- a/backend/epson2.h
> +++ b/backend/epson2.h
> @@ -22,7 +22,9 @@
> #define BACKEND_NAME epson2
> #define DEBUG_NOT_STATIC
>
> +#ifdef HAVE_SYS_IOCTL_H
> #include <sys/ioctl.h>
> +#endif
>
> #ifdef HAVE_STDDEF_H
> #include <stddef.h>
>
> --
> SANE backends - scanner drivers
>
> _______________________________________________
> sane-commit mailing list
> sane-commit at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-commit
>
> --
> sane-devel mailing list: sane-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
> Unsubscribe: Send mail with subject "unsubscribe your_password"
> to sane-devel-request at lists.alioth.debian.org
>
More information about the sane-devel
mailing list