-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuart_brk_ioctl.c
More file actions
43 lines (36 loc) · 815 Bytes
/
uart_brk_ioctl.c
File metadata and controls
43 lines (36 loc) · 815 Bytes
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
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
* All rights reserved.
*/
#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>
#define DEV_TTY_UART_PATH "/dev/ttyS1"
int main(int argc, char *argv[])
{
int fd, val;
if (argc != 2) {
printf("Invalid argument count [%d]\n", argc);
return -EINVAL;
}
fd = open(DEV_TTY_UART_PATH, O_RDWR);
if (!fd)
return -EINVAL;
val = atoi(argv[1]);
if (val == 1) {
printf("assert on %d\n", fd);
ioctl(fd, TIOCCBRK, 0);
} else if (val == 0){
printf("deassert on %d\n", fd);
ioctl(fd, TIOCSBRK, 0);
} else{
printf("Ignore invalid paramter, please pass 1 or 0\n");
}
close(fd);
return 0;
}