From 71540f5d1258c2598e11e52868a02afbf61db0b7 Mon Sep 17 00:00:00 2001 From: Clemens Fries Date: Wed, 22 Jul 2015 21:38:51 +0200 Subject: examples/minimal.c: Be a tad more helpful when opening the device --- src/examples/minimal.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/examples/minimal.c') diff --git a/src/examples/minimal.c b/src/examples/minimal.c index 5550e9e..2ebdc44 100644 --- a/src/examples/minimal.c +++ b/src/examples/minimal.c @@ -19,6 +19,8 @@ */ #include "../ql570.h" +#include +#include /** * Raster line length for the QL-570 is 90 bytes. There are some other QL @@ -36,7 +38,14 @@ */ int main() { - FILE *device = fopen("/dev/usb/lp0", "wb"); + char *devname = "/dev/usb/lp0"; + FILE *device = fopen(devname, "wb"); + + if (device == NULL) { + fprintf(stderr, "Error while opening %s: %s\n", devname, strerror(errno)); + return EXIT_FAILURE; + } + ql_status status = {0}; uint8_t buffer[BUFFER_SIZE]; -- cgit