From 0bfa79c37976d144f1746bba03f72bc92db22df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=98=8A=E8=8B=8F?= Date: Mon, 27 May 2024 11:21:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9EREADME=5Fzh.md=E3=80=81RE?= =?UTF-8?q?ADME.md=E5=92=8CREADME.OpenSource=E6=96=87=E4=BB=B6=20Signed-of?= =?UTF-8?q?f-by:liuhaosu@huawei.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘昊苏 --- README.OpenSource | 11 +++++ README.md | 120 ++++++++++++++++++++++++++++++++++++++++++++++ README_zh.md | 118 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 249 insertions(+) create mode 100644 README.OpenSource create mode 100644 README.md create mode 100644 README_zh.md diff --git a/README.OpenSource b/README.OpenSource new file mode 100644 index 000000000..9e7cc95b9 --- /dev/null +++ b/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name" : "backends", + "License" : "GPL v2", + "License File" : "LICENSE", + "Version Number" : "1.1.1", + "Owner" : "guoshengbang@huawei.com", + "Upstream URL" : "https://gitlab.com/sane-project/backends/-/releases/1.1.1", + "Description" : "SANE stands is an application programming interface (API) that provides standardized access to any raster image scanner hardware. " + } +] diff --git a/README.md b/README.md new file mode 100644 index 000000000..305ca07e9 --- /dev/null +++ b/README.md @@ -0,0 +1,120 @@ +# SANE +## Introduction +SANE is an application programming interface (API) that provides standardized access to any raster image scanner hardware (flatbed scanner, hand-held scanner, video- and still-cameras, frame-grabbers, etc.). + +You can also learn more about the SANE project through [the official website](http://sane-project.org/) + +## Background Brief +In the process of OpenHarmony's southward ecological development, it is necessary to be compatible with printers in the stock market. The use of CUPS printing system can directly connect with most printers in the market, which also reduces the difficulty for printer manufacturers to adapt to OpenHarmony. + +## Directory structure +``` +- LICENSE Copyright File +- OAT.xml OAT.XML filtering configuration file +- README.OpenSource Project README OpenSource files +- README.md English Description +- README_zh.md Chinese Description +- backend scanning device backend source code +- include SANE API interface +- lib SANE library source code +- sanei SANE internal utility functions and tools +- doc documents and instruction files +``` + +## How to use +### 1、Header file import +```c +#include +``` +### 2、Add Compilation Dependency +Add in the bundle. json file +```json +"deps": { + "third_party": [ + "backends" + ] +} +``` +Add dependencies where needed in BUILD.gn + +```json +deps += [ "//third_party/backends:third_sane" ] +``` +### 3、Example of interface usage +```c +SANE_Status status; +SANE_Handle handle; + +// Initialize SANE +status = sane_init(NULL, NULL); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to initialize SANE: %s\n", sane_strstatus(status)); + return 1; +} + +// Open the first scanner device +status = sane_open("your_scanner_device_name", &handle); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to open scanner: %s\n", sane_strstatus(status)); + return 1; +} + +// Get scanner device information +const SANE_Device *device_info; +status = sane_get_devices(&device_info, SANE_FALSE); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to get scanner device information: %s\n", sane_strstatus(status)); + return 1; +} + +// Set scan parameters +SANE_Parameters parameters; +status = sane_get_parameters(handle, ¶meters); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to get scan parameters: %s\n", sane_strstatus(status)); + return 1; +} + +// Start scanning +SANE_Image image; +status = sane_start(handle); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to start scanning: %s\n", sane_strstatus(status)); + return 1; +} + +// Read scan data +do { + status = sane_read(handle, &image); + if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to read scan data: %s\n", sane_strstatus(status)); + break; + } + +} while (status == SANE_STATUS_GOOD); + +// Finish scanning +status = sane_cancel(handle); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to cancel scanning: %s\n", sane_strstatus(status)); + return 1; +} + +// Close the scanner device +status = sane_close(handle); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to close scanner: %s\n", sane_strstatus(status)); + return 1; +} + +// Exit SANE +sane_exit(); +``` + +### 相关仓 +[print_print_fwk](https://gitee.com/openharmony/print_print_fwk) + +### 参与贡献 +[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/参与贡献.md) + +[Commit message spec](https://gitee.com/openharmony/device_qemu/wikis/Commit%20message%E8%A7%84%E8%8C%83) \ No newline at end of file diff --git a/README_zh.md b/README_zh.md new file mode 100644 index 000000000..d5d7a11e6 --- /dev/null +++ b/README_zh.md @@ -0,0 +1,118 @@ +# 三方开源软件sane-backends +## SANE简介 +SANE是一个应用程序编程接口(API),它提供对任何光栅图像扫描仪硬件(平板扫描仪、手持式扫描仪、视频和静态摄像机、帧处理器等)的标准化访问。 + +您也可以通过[CUPS官网主页](https://github.com/OpenPrinting/cups)了解更多关于SANE项目的信息。 + +## 引入背景简述 +OpenHarmony南向生态发展过程中,需要对存量市场的扫描仪进行兼容。使用SANE扫描系统能直接对接市场上大部分的扫描仪,也减少了扫描仪驱动适配OpenHarmony系统的难度。 + +## 目录结构 +``` +- LICENSE 版权文件 +- OAT.xml OAT.xml过滤配置文件 +- README.OpenSource 项目README.OpenSource文件 +- README.md 英文说明 +- README_zh.md 中文说明 +- backend 扫描设备后端源码 +- include SANE API接口 +- lib SANE 库源码 +- sanei SANE 内部实用函数和工具 +- doc 文档和说明文件 +``` + +## 如何使用 +### 1、头文件引入 +```c +#include +``` +### 2、添加编译依赖 +在您的 bundle.json 文件 添加 +```json +"deps": { + "third_party": [ + "backends" + ] +} +``` +在您的BUILD.gn需要的地方添加依赖 +```json +deps += [ "//third_party/backends:third_sane" ] +```c +SANE_Status status; +SANE_Handle handle; + +// Initialize SANE +status = sane_init(NULL, NULL); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to initialize SANE: %s\n", sane_strstatus(status)); + return 1; +} + +// Open the first scanner device +status = sane_open("your_scanner_device_name", &handle); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to open scanner: %s\n", sane_strstatus(status)); + return 1; +} + +// Get scanner device information +const SANE_Device *device_info; +status = sane_get_devices(&device_info, SANE_FALSE); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to get scanner device information: %s\n", sane_strstatus(status)); + return 1; +} + +// Set scan parameters +SANE_Parameters parameters; +status = sane_get_parameters(handle, ¶meters); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to get scan parameters: %s\n", sane_strstatus(status)); + return 1; +} + +// Start scanning +SANE_Image image; +status = sane_start(handle); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to start scanning: %s\n", sane_strstatus(status)); + return 1; +} + +// Read scan data +do { + status = sane_read(handle, &image); + if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to read scan data: %s\n", sane_strstatus(status)); + break; + } + +} while (status == SANE_STATUS_GOOD); + +// Finish scanning +status = sane_cancel(handle); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to cancel scanning: %s\n", sane_strstatus(status)); + return 1; +} + +// Close the scanner device +status = sane_close(handle); +if (status != SANE_STATUS_GOOD) { + fprintf(stderr, "Failed to close scanner: %s\n", sane_strstatus(status)); + return 1; +} + +// Exit SANE +sane_exit(); +``` + +### 相关仓 +[print_print_fwk](https://gitee.com/openharmony/print_print_fwk) + +### 参与贡献 +[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/参与贡献.md) + +[Commit message规范](https://gitee.com/openharmony/device_qemu/wikis/Commit%20message%E8%A7%84%E8%8C%83) + -- Gitee From fc886c5ac6360582b81eca0d27d871f5e4e9cdf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=98=8A=E8=8B=8F?= Date: Thu, 11 Jul 2024 19:27:26 +0800 Subject: [PATCH 2/3] =?UTF-8?q?sane-backends=E6=96=B0=E5=A2=9Ehilog?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0=20Signed-off-by:liuhaosu@h?= =?UTF-8?q?uawei.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘昊苏 --- bundle.json | 13 ++++++++++++- include/sane/sanei_debug.h | 5 +++++ sanei/sanei_init_debug.c | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bundle.json b/bundle.json index a13a0ff14..bc514030d 100644 --- a/bundle.json +++ b/bundle.json @@ -32,7 +32,18 @@ "sub_component": [ "//third_party/backends:third_sane" ], - "inner_kits": [], + "inner_kits": [ + { + "name": "//third_party/backends:third_sane", + "header": { + "header_files": [ + "sane/sane.h", + "sane/saneopts.h" + ], + "header_base": "//third_party/backends/include" + } + } + ], "test": [] } } diff --git a/include/sane/sanei_debug.h b/include/sane/sanei_debug.h index 465d3e25e..f948f7dec 100644 --- a/include/sane/sanei_debug.h +++ b/include/sane/sanei_debug.h @@ -9,6 +9,7 @@ #include +#include "hilog/log.h" #ifdef __cplusplus extern "C" { #endif @@ -79,7 +80,11 @@ extern void sanei_debug_ndebug (int level, const char *msg, ...); # define DBG_LEVEL (0) # define DBG_INIT() +#ifndef ENABLE_HILOG # define DBG sanei_debug_ndebug +#else +# define DBG(level, ...) ((void)HiLogPrint(LOG_APP, LOG_INFO, 0, "sanekit", __VA_ARGS__)) +#endif # define IF_DBG(x) #else /* !NDEBUG */ diff --git a/sanei/sanei_init_debug.c b/sanei/sanei_init_debug.c index 690cc2eca..fe21f7756 100644 --- a/sanei/sanei_init_debug.c +++ b/sanei/sanei_init_debug.c @@ -107,6 +107,7 @@ sanei_init_debug (const char * backend, int * var) DBG (0, "Setting debug level of %s to %d.\n", backend, *var); } +#if defined(LOG_DEBUG) static int is_socket (int fd) { @@ -122,6 +123,7 @@ is_socket (int fd) return 0; #endif } +#endif void sanei_debug_msg -- Gitee From 6d3411649215dde9f63762867ba641194244bbc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=87=AF?= Date: Thu, 11 Jul 2024 20:36:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?sane-backends=E6=96=B0=E5=A2=9Econfig.h=20S?= =?UTF-8?q?igned-off-by:liuhaosu@huawei.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张凯 --- include/sane/.gitignore | 2 +- include/sane/config.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 include/sane/config.h diff --git a/include/sane/.gitignore b/include/sane/.gitignore index f282c157d..7240c56aa 100644 --- a/include/sane/.gitignore +++ b/include/sane/.gitignore @@ -1,3 +1,3 @@ config.h.in -config.h +# config.h stamp-h1 diff --git a/include/sane/config.h b/include/sane/config.h new file mode 100644 index 000000000..48082f72f --- /dev/null +++ b/include/sane/config.h @@ -0,0 +1 @@ +12 -- Gitee