Skip to content

SuperSocket/SuperSocket.SerialIO

Repository files navigation

SuperSocket.SerialIO

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

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"
            }
        ]
    }
}

About

Serial IO support for SuperSocket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages