Coder Social home page Coder Social logo

windup's Introduction

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();

###License Copyright 2009โ€“2015 gaoc and contributors MIT License (enclosed)

windup's People

Contributors

gc87 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.