1 Star 0 Fork 0

zakailynn / SuperSocket.SerialIO

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
kerryjiang 提交于 2020-05-14 00:33 . fixed a typo in the readme

SuperSocket.SerialIO

Join the chat at https://gitter.im/supersocket/community Build Status

Serial IO support for SuperSocket

The sample code below shows us how we build a serial IO communication server with SuperSocket.

var host = SuperSocketHostBuilder
    .Create<StringPackageInfo, CommandLinePipelineFilter>()
    .UsePackageHandler(async (s, package) =>
        {
            await s.SendAsync(Encoding.UTF8.GetBytes(package.ToString() + "\r\n"));
        })
    .ConfigureSuperSocket(options =>  
        {
            options.Name = "SIOServer";
            options.Listeners = new[] {
                new SerialIOListenOptions()
                {
                    PortName = "COM2",   // serial port name
                    BaudRate = 9600,  // baudRate of the serial port
                    Parity = Parity.None,
                    StopBits = StopBits.None,
                    Databits = 5;  // value limit 5 to 8
                }
            };
        })
    .UseSerialIO()
    .ConfigureLogging((hostCtx, loggingBuilder) => {
        loggingBuilder.AddConsole();
    }).Build();

You also can leave the infromation of Serial IO in the configuration.

{
    "serverOptions": {
        "name": "SIOServer",
        "listeners": [
            {
                "path": "sio://COM1/?BaudRate=9600&Parity=Odd&StopBits=2&Databits=7"
            }
        ]
    }
}
1
https://gitee.com/zakailynn/SuperSocket.SerialIO.git
git@gitee.com:zakailynn/SuperSocket.SerialIO.git
zakailynn
SuperSocket.SerialIO
SuperSocket.SerialIO
master

搜索帮助