Skip to content

gc87/windup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windup

Introduction

  • Serial port access library on c#.

Quickstart

get all serial port name.

string[] portNames = GetSerialPorts ();

test a serial port is busy.

var isBusy = Talker.TouchSerialPort ("COM3", 9600)

create a instance of Talker.

var talker = new Talker () {
	PortName = "COM3",
	BaudRate = 9600,
	LineBreak = new LineBreak () { //set linebreak type
		Type = "nt",
	},
	Proc = list => { // data arrived process method(important)
		var str = string.Empty;
		foreach (var i in list) {
			var ch = (char)i;
			str += ch;
		}
		Console.WriteLine ("echo str: {0}", str);
	}
};

you can also use Parity, DataBits, StopBits to initlize talker.

linebreak type: "nt" -> '\r\n'; "linux" -> '\n'; "mac" -> '\r'; "length" -> you must initializing another property name is Length like this

var lineBreak = new LineBreak () {
		Type = "length",
		Length = 100
	},

"char" -> you must initializing another property name is Char like this

var lineBreak = new LineBreak () {
		Type = "char",
		Char = 'e'
	},

open talker if it's not opened.

if (!talker.IsOpen) {
	talker.Open (); 
}

write byte data to serialport.

talker.Write (new byte[] { 10, 12, 11, 17, 18 });

close talker.

var isSuccessed = talker.Close();

Screenshot

License

Copyright 2009–2015 gaoc and contributors MIT License (enclosed)

About

serial port access library on c#.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published