From e8d34d11799fc79c7c53bdcd40f9b4ee7be7a2c5 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Wed, 25 Sep 2024 17:42:22 +0800
Subject: [PATCH] Merge branch 'master' of ssh://weike-iot.com:2280/framwork

---
 booster/comport.h |   52 +++++++++++++++++++++-------------------------------
 1 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/booster/comport.h b/booster/comport.h
index 755e02e..2754d43 100644
--- a/booster/comport.h
+++ b/booster/comport.h
@@ -1,17 +1,18 @@
 /*********************************************************************************
- *      Copyright:  (C) 2018 LingYun IoT System Studio
+ *      Copyright:  (C) 2023 LingYun IoT System Studio.
  *                  All rights reserved.
  *
- *       Filename:  comport.h
- *    Description:  This head file is for the common TTY/Serial port operator library
+ *       Filename:  comport.c
+ *    Description:  This file is linux comport common API functions
  *
- *        Version:  1.0.0(10/17/2018~)
+ *        Version:  1.0.0(11/08/23)
  *         Author:  Guo Wenxue <guowenxue@gmail.com>
- *      ChangeLog:  1, Release initial version on "10/17/2018 03:33:25 PM"
+ *      ChangeLog:  1, Release initial version on "11/08/23 16:18:43"
  *
  ********************************************************************************/
-#ifndef  __COMPORT_H_
-#define  __COMPORT_H_
+
+#ifndef  _COMPORT_H_
+#define  _COMPORT_H_
 
 #include  <stdio.h>
 #include  <stdlib.h>
@@ -27,36 +28,25 @@
 #include  <sys/stat.h>
 #include  <sys/select.h>
 
-
-#ifndef DEVNAME_LEN
-#define DEVNAME_LEN          32
-#endif
-
-//#define COM_DEBUG
-#ifdef  COM_DEBUG
-#define COM_PRINT(format,args...) printf(format, ##args)
-#else
-#define COM_PRINT(format,args...) do{} while(0);
-#endif
-
+#define CONFIG_DEF_FRAGSIZE    128
 typedef struct comport_s
 {
-    char           devname[DEVNAME_LEN];
+    char           devname[32];
     unsigned char  databit, parity, stopbit, flowctrl;
     long           baudrate;
 
     int            fd;
-    int            frag_size;
+    int            fragsize; /* frag size when do large data send */
 } comport_t;
 
 
 /*
- *  description: Open the comport specified by $comport
+ *  description: Open the comport and returned by $comport
  *
- *   input args: $comport:  corresponding comport point
+ *   input args: $comport:  corresponding comport handler
  *               $devname:  The comport device name path, such as '/dev/ttyS3'
- *               $baudrate:  The baudrate, such as 115200
- *               $settings:  The databit,parity,stopbit,flowctrl settings, such as '8N1N'
+ *               $baudrate: The baudrate, such as 115200
+ *               $settings: The databit,parity,stopbit,flowctrl settings, such as '8N1N'
  *
  * return value: The comport opened file description, <0 means failure
  */
@@ -64,21 +54,21 @@
 
 /*
  *  description: close comport
- *   input args: $comport:  corresponding comport point
+ *   input args: $comport:  corresponding comport handler
  */
 extern void comport_close(comport_t *comport);
 
 /*
- *  description: write $send_bytes bytes data from $buf to $comport
+ *  description: write $bytes $data to $comport
  * return value: 0: write ok  <0: write failure
  */
-extern int  comport_send(comport_t *comport, char *buf, int send_bytes);
+extern int  comport_send(comport_t *comport, char *data, int data_bytes);
 
 /*
- *  description: read data from $comport in $timeout <ms> to $buf no more than $bufsize bytes
+ *  description: read data from $comport in $timeout <ms> to $buf no more than $buf_size bytes
  * return value: the actual read data bytes, <0: read failure
  */
-extern int  comport_recv(comport_t *comport, char *buf, int bufsize, unsigned long timeout);
-
+#define TIMEOUT_NONE           0
+extern int  comport_recv(comport_t *comport, char *buf, int buf_size, unsigned long timeout);
 
 #endif

--
Gitblit v1.9.1