diff options
3 files changed, 153 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/serialcheck/serialcheck/0001-Add-option-to-enable-internal-loopback.patch b/meta-oe/recipes-devtools/serialcheck/serialcheck/0001-Add-option-to-enable-internal-loopback.patch new file mode 100644 index 000000000..f69254a29 --- /dev/null +++ b/meta-oe/recipes-devtools/serialcheck/serialcheck/0001-Add-option-to-enable-internal-loopback.patch | |||
@@ -0,0 +1,81 @@ | |||
1 | From 059d5512e840fe68e2bb37add6c9208fa9c34d15 Mon Sep 17 00:00:00 2001 | ||
2 | From: Sekhar Nori <nsekhar@ti.com> | ||
3 | Date: Tue, 24 Feb 2015 22:16:37 +0530 | ||
4 | Subject: [PATCH 1/2] Add option to enable internal loopback | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | --- | ||
8 | serialcheck.c | 23 +++++++++++++++++++++++ | ||
9 | 1 file changed, 23 insertions(+) | ||
10 | |||
11 | diff --git a/serialcheck.c b/serialcheck.c | ||
12 | index 4f5b747..4100c37 100644 | ||
13 | --- a/serialcheck.c | ||
14 | +++ b/serialcheck.c | ||
15 | @@ -12,6 +12,8 @@ | ||
16 | #include <sys/ioctl.h> | ||
17 | #include <linux/serial.h> | ||
18 | |||
19 | +#define TIOCM_LOOP 0x8000 | ||
20 | + | ||
21 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) | ||
22 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) | ||
23 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) | ||
24 | @@ -40,6 +42,7 @@ struct g_opt { | ||
25 | unsigned char hflow; | ||
26 | unsigned char do_termios; | ||
27 | unsigned char *cmp_buff; | ||
28 | + unsigned char loopback; | ||
29 | }; | ||
30 | |||
31 | /* name, key, arg, flags, doc, group */ | ||
32 | @@ -51,6 +54,7 @@ static struct argp_option options[] = { | ||
33 | {"mode", 'm', "M", 0, "transfer mode (d = duplex, t = send r = receive)", 0}, | ||
34 | {"loops", 'l', "NUM", 0, "loops to perform (0 => wait fot CTRL-C", 0}, | ||
35 | {"no-termios", 'n', NULL, 0, "No termios change (baud rate etc. remains unchanged)", 0}, | ||
36 | + {"loopback", 'k', NULL, 0, "loopback mode", 0}, | ||
37 | {NULL, 0, NULL, 0, NULL, 0} | ||
38 | }; | ||
39 | |||
40 | @@ -67,6 +71,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) | ||
41 | go->baudrate = 115200; | ||
42 | go->loops = UINT_MAX; | ||
43 | go->do_termios = 1; | ||
44 | + go->loopback = 0; | ||
45 | break; | ||
46 | case ARGP_KEY_ARG: | ||
47 | ret = ARGP_ERR_UNKNOWN; | ||
48 | @@ -113,6 +118,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) | ||
49 | } else | ||
50 | go->loops = num; | ||
51 | break; | ||
52 | + case 'k': | ||
53 | + go->loopback = 1; | ||
54 | + break; | ||
55 | default: | ||
56 | ret = ARGP_ERR_UNKNOWN; | ||
57 | } | ||
58 | @@ -487,6 +495,21 @@ int main(int argc, char *argv[]) | ||
59 | die("tcflush failed: %m\n"); | ||
60 | } | ||
61 | |||
62 | + if (opts.loopback) { | ||
63 | + unsigned int mcr; | ||
64 | + | ||
65 | + ret = ioctl(fd, TIOCMGET, &mcr); | ||
66 | + if (ret < 0) | ||
67 | + die("mcr get failed: %m\n"); | ||
68 | + | ||
69 | + mcr |= TIOCM_LOOP; | ||
70 | + | ||
71 | + ret = ioctl(fd, TIOCMSET, &mcr); | ||
72 | + if (ret < 0) | ||
73 | + die ("mcr set failed: %m\n"); | ||
74 | + | ||
75 | + } | ||
76 | + | ||
77 | ret = fcntl(fd, F_SETFL, 0); | ||
78 | if (ret) | ||
79 | printf("Failed to remove nonblock mode\n"); | ||
80 | -- | ||
81 | 1.9.1 | ||
diff --git a/meta-oe/recipes-devtools/serialcheck/serialcheck/0002-Restore-original-loopback-config.patch b/meta-oe/recipes-devtools/serialcheck/serialcheck/0002-Restore-original-loopback-config.patch new file mode 100644 index 000000000..1b8c95b10 --- /dev/null +++ b/meta-oe/recipes-devtools/serialcheck/serialcheck/0002-Restore-original-loopback-config.patch | |||
@@ -0,0 +1,49 @@ | |||
1 | From a6e5813d2f8402bf3a311c8bcda02623bfb76882 Mon Sep 17 00:00:00 2001 | ||
2 | From: Carlos Hernandez <ceh@ti.com> | ||
3 | Date: Tue, 24 Feb 2015 16:00:34 -0500 | ||
4 | Subject: [PATCH 2/2] Restore original loopback config | ||
5 | |||
6 | If loopback option is enabled, disable it at the end of the test. | ||
7 | |||
8 | Signed-off-by: Carlos Hernandez <ceh@ti.com> | ||
9 | Upstream-status: Pending | ||
10 | --- | ||
11 | serialcheck.c | 9 +++++++-- | ||
12 | 1 file changed, 7 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/serialcheck.c b/serialcheck.c | ||
15 | index 4100c37..06470f7 100644 | ||
16 | --- a/serialcheck.c | ||
17 | +++ b/serialcheck.c | ||
18 | @@ -427,6 +427,7 @@ int main(int argc, char *argv[]) | ||
19 | unsigned char *data; | ||
20 | unsigned int open_mode; | ||
21 | off_t data_len; | ||
22 | + unsigned int mcr; | ||
23 | |||
24 | argp_parse(&argp, argc, argv, 0, NULL, &opts); | ||
25 | if (!opts.file_trans) | ||
26 | @@ -496,8 +497,6 @@ int main(int argc, char *argv[]) | ||
27 | } | ||
28 | |||
29 | if (opts.loopback) { | ||
30 | - unsigned int mcr; | ||
31 | - | ||
32 | ret = ioctl(fd, TIOCMGET, &mcr); | ||
33 | if (ret < 0) | ||
34 | die("mcr get failed: %m\n"); | ||
35 | @@ -535,6 +534,12 @@ int main(int argc, char *argv[]) | ||
36 | ret = tcsetattr(fd, TCSAFLUSH, &old_term); | ||
37 | if (ret) | ||
38 | printf("tcsetattr() of old ones failed: %m\n"); | ||
39 | + if (opts.loopback) { | ||
40 | + mcr &= ~(TIOCM_LOOP); | ||
41 | + ret = ioctl(fd, TIOCMSET, &mcr); | ||
42 | + } | ||
43 | + if (ret) | ||
44 | + printf("disabling loopback failed: %m\n"); | ||
45 | |||
46 | close(fd); | ||
47 | return status; | ||
48 | -- | ||
49 | 1.9.1 | ||
diff --git a/meta-oe/recipes-devtools/serialcheck/serialcheck_1.0.0.bb b/meta-oe/recipes-devtools/serialcheck/serialcheck_1.0.0.bb new file mode 100644 index 000000000..98324e816 --- /dev/null +++ b/meta-oe/recipes-devtools/serialcheck/serialcheck_1.0.0.bb | |||
@@ -0,0 +1,23 @@ | |||
1 | SUMMARY = "Application to verify operation of serial ports" | ||
2 | HOMEPAGE = "http://git.breakpoint.cc/cgit/bigeasy/serialcheck.git/" | ||
3 | LICENSE = "GPLv2" | ||
4 | LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" | ||
5 | |||
6 | SRC_URI = "git://git.breakpoint.cc/bigeasy/serialcheck.git \ | ||
7 | file://0001-Add-option-to-enable-internal-loopback.patch \ | ||
8 | file://0002-Restore-original-loopback-config.patch" | ||
9 | |||
10 | SRCREV = "63854a2d0c0129efab132ec328a75279e013fb84" | ||
11 | |||
12 | S = "${WORKDIR}/git" | ||
13 | |||
14 | CFLAGS_prepend = "-Wall -Wextra -Wno-sign-compare -Wno-pointer-sign " | ||
15 | |||
16 | do_install() { | ||
17 | install -d ${D}${bindir} | ||
18 | install ${S}/serialcheck ${D}${bindir} | ||
19 | install -d ${D}${docdir}/${BP} | ||
20 | install ${S}/Readme.txt ${D}${docdir}/${BP} | ||
21 | } | ||
22 | |||
23 | BBCLASSEXTEND = "nativesdk" | ||