当前位置: 首页 > news >正文

libserialport: cross-platform library for accessing serial ports

/***********************************************************************************
 *       libserialport: cross-platform library for accessing serial ports
 * 说明:
 *     很多时候,我们经常需要写一下串口方面的调试工具,象征一下我们的知识产权,
 * 但是对于很多人来说,也许仅仅关心上层的软件,并不关心驱动上的事,所以使用串
 * 口库就变成了一种很不错的选择。
 * 
 *                                             2015-12-22 深圳 南山平山村 曾剑锋
 **********************************************************************************/

一、参考文档:
    1. C: cross-platform RS232 serial library? [closed]
        http://stackoverflow.com/questions/2973402/c-cross-platform-rs232-serial-library
    2. request basic example code please #11
        https://github.com/martinling/libserialport/issues/11

二、README 翻译:
    -------------------------------------------------------------------------------
    libserialport: cross-platform library for accessing serial ports
    libserialport: 跨平台的串口库
    -------------------------------------------------------------------------------

    libserialport is a minimal library written in C that is intended to take care
    of the OS-specific details when writing software that uses serial ports.
    libserialport采用C语言编写,当我们写软件的时候可以规避一些操作系统 特有的内容。

    By writing your serial code to use libserialport, you enable it to work
    transparently on any platform supported by the library.
    通过使用libserialport,你的软件可以在任何平台上运行。

    The operations that are supported are:
    支持以下操作:

    - Port enumeration (obtaining a list of serial ports on the system).
    枚举串口
    - Opening and closing ports.
    打开关闭串口
    - Setting port parameters (baud rate, parity, etc).
    设置串口参数
    - Reading, writing and flushing data.
    读、写、刷新数据
    - Obtaining error information.
    获取错误

    libserialport is an open source project released under the LGPL3+ license.
    libserialport是一个开源项目,在LGPL3+协议下发行的

    Status
    现状
    ======

    The library should build and work on any Windows or Unix-based system. If it
    does not, please submit a bug.
    该库能够在任何Windows或者Unix-based系统下工作。当然,如果不能工作,请提交bug

    Enumeration is currently only implemented on Windows, Mac OS X and Linux. On
    other systems enumeration is not supported, but ports can still be opened by
    name and then used.
    枚举目前只在Windows、Mac OS X和Linux上实现了,在其他的系统上目前还不支持,
    但是串口还是可以通过名字打开并使用。

    If you know how to enumerate available ports on another OS, please submit a bug
    with this information, or better still a patch implementing it.
    如果你知道怎么枚举串口在其他的OS上,请提交对应的bug,将会实现这个功能。

    Future
    将来
    ======

    Future versions will add additional API calls for obtaining metadata about a
    port, e.g. for USB devices the USB VID and PID of the underlying device.
    将来的版本将添加用于获取串口元数据的API,例如,获取USB底层设备的VID、PID。

    Dependencies
    ============

    On Linux, libudev is required. On other systems no other libraries are required.
    在Linux系统上,libudev是依赖的库,在其他的系统上不依赖任何其他的库。

    The libudev dependency could be eliminated in favour of direct sysfs queries at
    the cost of some brevity. This is not currently a priority but if you feel like
    doing this feel free to submit a patch.

    Building
    编译
    ========

    The package uses a GNU style build system and requires a Unix style shell.
    On Windows it can be built with the MinGW toolchain and MSYS environment.
    这个包使用GNU编译系统,需要一个Unix形式的shell,在Windows上,可以通过MinGW
    工具、MSYS环境进行编译。

    Run "./autogen.sh" to generate the build system, "./configure" to setup, then
    "make" to build the library and "make install" to install it.
    运行"./autogen.sh" 来生成编译系统,"./configure"来配置,同时"make"来生成库,
    "make install"来进行安装

    API
    ===

    Doxygen API documentation is included.

三、Simple Demo:
    #include <stdio.h>
    #include "libserialport.h"

    int main ( void ) 
    {
        int i = 0;
        struct sp_port **ports;

        sp_list_ports(&ports);

        for (i = 0; i > 0 && ports[i]; i++)
            printf("Found port: '%s'.\n", sp_get_port_name(ports[i]));

        sp_free_port_list(ports);
    }
    

 

相关文章:

  • Linux USB驱动框架分析(2)【转】
  • 安卓android.support.design使用中的问题
  • swift锁屏播放,音乐进度更新,专辑,歌手名显示
  • srxboys 今日说 !
  • windows 下将目录映射成盘符
  • ios自定义控件,使UIScrollView自己处理输入时键盘遮挡控件
  • 算法学习笔记——动态规划法
  • js 自定义方法 实现停留几秒 sleep
  • Global Azure SQL Server Database异地复制配置介绍
  • 练习JavaScript实现过滤特殊字符
  • jQuery Mobile_页面事件
  • struts2遍历map
  • java基础tips
  • 第一章 Java常用集合类总览
  • 判定ftp上传的脚本
  • (三)从jvm层面了解线程的启动和停止
  • (十五)java多线程之并发集合ArrayBlockingQueue
  • 002-读书笔记-JavaScript高级程序设计 在HTML中使用JavaScript
  • Angular 4.x 动态创建组件
  • HTML5新特性总结
  • Java反射-动态类加载和重新加载
  • JS基础篇--通过JS生成由字母与数字组合的随机字符串
  • Nacos系列:Nacos的Java SDK使用
  • node.js
  • Octave 入门
  • php面试题 汇集2
  • SpingCloudBus整合RabbitMQ
  • SpriteKit 技巧之添加背景图片
  • zookeeper系列(七)实战分布式命名服务
  • 初识MongoDB分片
  • 动手做个聊天室,前端工程师百无聊赖的人生
  • 分享一份非常强势的Android面试题
  • 基于MaxCompute打造轻盈的人人车移动端数据平台
  • 简单基于spring的redis配置(单机和集群模式)
  • 将 Measurements 和 Units 应用到物理学
  • 你真的知道 == 和 equals 的区别吗?
  • 如何使用 OAuth 2.0 将 LinkedIn 集成入 iOS 应用
  • 学习笔记DL002:AI、机器学习、表示学习、深度学习,第一次大衰退
  • 一起参Ember.js讨论、问答社区。
  • 用 Swift 编写面向协议的视图
  • 蚂蚁金服CTO程立:真正的技术革命才刚刚开始
  • #控制台大学课堂点名问题_课堂随机点名
  • #我与Java虚拟机的故事#连载03:面试过的百度,滴滴,快手都问了这些问题
  • (52)只出现一次的数字III
  • (八)c52学习之旅-中断实验
  • (附源码)spring boot车辆管理系统 毕业设计 031034
  • (附源码)ssm捐赠救助系统 毕业设计 060945
  • (切换多语言)vantUI+vue-i18n进行国际化配置及新增没有的语言包
  • (十三)Flask之特殊装饰器详解
  • (一)80c52学习之旅-起始篇
  • (原创)Stanford Machine Learning (by Andrew NG) --- (week 9) Anomaly DetectionRecommender Systems...
  • (源码版)2024美国大学生数学建模E题财产保险的可持续模型详解思路+具体代码季节性时序预测SARIMA天气预测建模
  • .equal()和==的区别 怎样判断字符串为空问题: Illegal invoke-super to void nio.file.AccessDeniedException
  • .NET Core、DNX、DNU、DNVM、MVC6学习资料
  • .Net 路由处理厉害了