aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Fries <github-raster@xenoworld.de>2015-07-22 21:38:51 +0200
committerClemens Fries <github-raster@xenoworld.de>2015-07-22 21:38:51 +0200
commit71540f5d1258c2598e11e52868a02afbf61db0b7 (patch)
tree9c777980db212edfae27996a927fc1722ce61f8f
parent5d82f6b7cb83f1389f3b6c63fd1faef79d2e3fef (diff)
examples/minimal.c: Be a tad more helpful when opening the devicev0.1-alpha
-rw-r--r--src/examples/minimal.c11
1 files changed, 10 insertions, 1 deletions
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 <stdlib.h>
+#include <errno.h>
/**
* 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];