-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
45 lines (35 loc) · 950 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// test.c
//
// usb64drive; A open-source 64drive library.
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "usb64drive.h"
#include <stdlib.h>
#include <stdio.h>
int main(int argc, const char *argv[]) {
const char *device;
unsigned version;
int fd;
if (argc > 2) {
printf("Usage: %s <device path>\n", argv[0]);
return EXIT_SUCCESS;
}
device = argc > 1 ? argv[1] : "/dev/ttyUSB0";
if ((fd = usb64drive_open(device)) < 0) {
printf("Failed to open: %s\n", device);
return EXIT_FAILURE;
}
printf("usb64drive_open: pass\n");
if (usb64drive_get_version(fd, &version)) {
printf("Failed to query version.\n");
usb64drive_close(fd);
return EXIT_FAILURE;
}
printf("usb64drive_get_version: pass [0x%.8X]\n", version);
usb64drive_close(fd);
return EXIT_SUCCESS;
}