From 9ada9cdc52c22fabb658680d3869d3ab6ab87f61 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Mon, 19 Aug 2024 10:26:57 +0800
Subject: [PATCH] update booster from booster project
---
booster/test/comport.c | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/booster/test/comport.c b/booster/test/comport.c
index 80be4e4..df216dc 100644
--- a/booster/test/comport.c
+++ b/booster/test/comport.c
@@ -1,15 +1,15 @@
/*********************************************************************************
- * Copyright: (C) 2021 Guo Wenxue <guowenxue@gmail.com>
+ * Copyright: (C) 2021 Guo Wenxue <guowenxue@gmail.com>
* All rights reserved.
*
* Filename: comport.c
- * Description: This file used to do ioctl() on common device or communicate
+ * Description: This file used to do ioctl() on common device or communicate
* with serial port/TTY device.
- *
+ *
* Version: 1.0.0(5/1/2021~)
* Author: Guo Wenxue <guowenxue@gmail.com>
* ChangeLog: 1, Release initial version on "5/1/2021 10:08:05 AM"
- *
+ *
********************************************************************************/
#include <getopt.h>
#include <libgen.h>
@@ -53,14 +53,14 @@
{NULL, 0, NULL, 0}
};
- while ((opt = getopt_long(argc, argv, "d:b:s:vh", long_options, NULL)) != -1)
+ while ((opt = getopt_long(argc, argv, "d:b:s:xvh", long_options, NULL)) != -1)
{
switch (opt)
{
case 'd':
dev_name = optarg;
break;
-
+
case 'b':
baudrate = atoi(optarg);
break;
@@ -175,10 +175,10 @@
ptr = strdup(name);
progname = basename(ptr);
- printf("Usage1: comport -d <device> [-b <baudrate>][-s <settings>] [-x]\n");
- printf(" -d[device ] device name\n");
+ printf("Usage: comport -d <device> [-b <baudrate>][-s <settings>] [-x]\n");
+ printf(" -d[device ] device name, such as /dev/ttyUSB0\n");
printf(" -b[baudrate] device baudrate (115200, 57600, 19200, 9600), default is 115200\n");
- printf(" -s[settings] device settings as like 8N1N(default setting)\n");
+ printf(" -s[settings] device settings as like 8N1N(defalt setting)\n");
printf(" - data bits: 8, 7\n");
printf(" - parity: N=None, O=Odd, E=Even, S=Space\n");
printf(" - stop bits: 1, 0\n");
@@ -211,7 +211,7 @@
void stdin_nonblock(void)
{
struct termios ttystate;
-
+
//get the terminal state
tcgetattr(STDIN_FILENO, &ttystate);
@@ -219,21 +219,21 @@
ttystate.c_lflag &= ~ICANON;
//minimum of number input read.
ttystate.c_cc[VMIN] = 1;
-
+
//set the terminal attributes.
tcsetattr(STDIN_FILENO, TCSANOW, &ttystate);
-}
-
+}
+
int kbhit(void)
-{
+{
struct timeval tv;
fd_set fds;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
FD_ZERO(&fds);
FD_SET(STDIN_FILENO, &fds); //STDIN_FILENO is 0
select(STDIN_FILENO + 1, &fds, NULL, NULL, &tv);
return FD_ISSET(STDIN_FILENO, &fds);
-}
+}
--
Gitblit v1.9.1