Serial IO support for SuperSocket
The sample code below shows us how we build a serial IO communication server with SuperSocket.
varhost=SuperSocketHostBuilder.Create<StringPackageInfo,CommandLinePipelineFilter>().UsePackageHandler(async(s,package)=>{awaits.SendAsync(Encoding.UTF8.GetBytes(package.ToString()+"\r\n"));}).ConfigureSuperSocket(options =>{options.Name="SIOServer";options.Listeners=new[]{newSerialIOListenOptions(){PortName="COM2",// serial port nameBaudRate=9600,// baudRate of the serial portParity=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"
}
]
}
}