From c13c9806f957ebc675462737f4b328d3ab89e028 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Mon, 10 Jul 2023 17:29:22 +0800
Subject: [PATCH] update gpsd.c

---
 gpsd/booster/comport.h |   69 ++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/gpsd/booster/comport.h b/gpsd/booster/comport.h
new file mode 100644
index 0000000..a5a04b5
--- /dev/null
+++ b/gpsd/booster/comport.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2022 Guo Wenxue
+ * Author: Guo Wenxue <guowenxue@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GPL license.
+ */
+
+#ifndef  _COMPORT_H_
+#define  _COMPORT_H_
+
+#include  <stdio.h>
+#include  <stdlib.h>
+#include  <unistd.h>
+#include  <string.h>
+#include  <getopt.h>
+#include  <fcntl.h>
+#include  <errno.h>
+#include  <termios.h>
+#include  <sys/stat.h>
+#include  <sys/wait.h>
+#include  <sys/types.h>
+#include  <sys/stat.h>
+#include  <sys/select.h>
+
+#define CONFIG_DEF_FRAGSIZE    128
+typedef struct comport_s
+{
+    char           devname[32];
+    unsigned char  databit, parity, stopbit, flowctrl;
+    long           baudrate;
+
+    int            fd;
+    int            fragsize; /* frag size when do large data send */
+} comport_t;
+
+
+/*
+ *  description: Open the comport and returned by $comport
+ *
+ *   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'
+ *
+ * return value: The comport opened file description, <0 means failure
+ */
+extern int  comport_open(comport_t *comport, const char *devname, long baudrate, const char *settings);
+
+/*
+ *  description: close comport
+ *   input args: $comport:  corresponding comport handler
+ */
+extern void comport_close(comport_t *comport);
+
+/*
+ *  description: write $bytes $data to $comport
+ * return value: 0: write ok  <0: write failure
+ */
+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 $buf_size bytes
+ * return value: the actual read data bytes, <0: read failure
+ */
+#define TIMEOUT_NONE           0
+extern int  comport_recv(comport_t *comport, char *buf, int buf_size, unsigned long timeout);
+
+#endif

--
Gitblit v1.9.1