本文整理汇总了C#中IStream.begin方法的典型用法代码示例。如果您正苦于以下问题:C# IStream.begin方法的具体用法?C# IStream.begin怎么用?C# IStream.begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStream
的用法示例。
在下文中一共展示了IStream.begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitFirmata
private void InitFirmata()
{
//USB\VID_2A03&PID_0043&REV_0001
//create a serial connection
//var devices = await UsbSerial.listAvailableDevicesAsync();
//var devList = devices.ToList();
serial = new UsbSerial("VID_2A03", "PID_0043");
//construct the firmata client
firmata = new UwpFirmata();
firmata.FirmataConnectionReady += Firmata_FirmataConnectionReady;
firmata.StringMessageReceived += Firmata_StringMessageReceived;
//last, construct the RemoteWiring layer by passing in our Firmata layer.
arduino = new RemoteDevice(firmata);
arduino.DeviceReady += Arduino_DeviceReady;
//if you create the firmata client yourself, don't forget to begin it!
firmata.begin(serial);
//you must always call 'begin' on your IStream object to connect.
//these parameters do not matter for bluetooth, as they depend on the device. However, these are the best params to use for USB, so they are illustrated here
serial.begin(57600, SerialConfig.SERIAL_8N1);
}
示例2: Arduino_Connect
private async void Arduino_Connect()
{
arduinoConnected = false;
ArduinoConnectionStatusText.Text = "Connecting...";
arduinoConnection = new BluetoothSerial( "RNBT-773E" );
arduino = new RemoteDevice( arduinoConnection );
arduino.DeviceReady += Arduino_DeviceReady;
arduino.DeviceConnectionFailed += Arduino_DeviceConnectionFailed;
arduino.DeviceConnectionLost += Arduino_DeviceConnectionLost;
arduinoConnection.begin( 115200, SerialConfig.SERIAL_8N1 );
}
示例3: Page_Loaded
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
var devices = await UsbSerial.listAvailableDevicesAsync();
if (!devices.Any())
{
var dialog = new MessageDialog("There is no device connected");
await dialog.ShowAsync();
return;
}
connection = new UsbSerial(devices.First());
arduino = new RemoteDevice(connection);
arduino.DeviceReady += Setup;
connection.begin(57600, SerialConfig.SERIAL_8N1);
}
示例4: Init
public static async void Init()
{
var deviceList = await UsbSerial.listAvailableDevicesAsync();
var device = deviceList.First();
connection = new UsbSerial(device);
firmata = new UwpFirmata();
firmata.begin(connection);
App.Arduino = new RemoteDevice(firmata);
connection.ConnectionEstablished += OnConnectionEstablished;
connection.ConnectionFailed += OnConnectionFailed;
connection.begin(115200, SerialConfig.SERIAL_8N1);
//start a timer for connection timeout
timeout = new DispatcherTimer();
timeout.Interval = new TimeSpan(0, 0, 30);
timeout.Tick += Connection_TimeOut;
timeout.Start();
}
示例5: btnConnect_Click
private void btnConnect_Click(object sender, RoutedEventArgs e)
{
Helpers.OutputTextBox = txtMessages;
Helpers.ShowMessage("About to Connect");
// *** IMPORTANT ***
// You need to add the VID and PID for your device.
// I'll post screen shots of finding it on my blog
// at http://MosesSoftware.com
//
// NOTE: The line below is, obviously, for a USB cnnected
// device. You can also use a BlueTooth.
connection = new UsbSerial("VID_2341", "PID_0042");
arduino = new RemoteDevice(connection);
arduino.DeviceReady += OnDeviceReady;
arduino.AnalogPinUpdated += OnAnalogPinUpdated;
arduino.DeviceConnectionFailed += OnDeviceConnectionFailed;
arduino.DeviceConnectionLost += OnDeviceConnectionLost;
arduino.DigitalPinUpdated += OnDigitialPinUpdated;
arduino.StringMessageReceived += OnStringMessageReceived;
arduino.SysexMessageReceived += OnSysexMessageReceived;
arduino.I2c.I2cReplyEvent += OnI2CReplyEvent;
// *** IMPORTANT ***
// Make sure the baud rate is the same as the one specified
// in the Firmata program uploaded to the arduino.
connection.begin(57600, SerialConfig.SERIAL_8N1);
}