本文整理汇总了C#中Solid.Arduino.Test.MockSerialConnection类的典型用法代码示例。如果您正苦于以下问题:C# MockSerialConnection类的具体用法?C# MockSerialConnection怎么用?C# MockSerialConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockSerialConnection类属于Solid.Arduino.Test命名空间,在下文中一共展示了MockSerialConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
public void Write()
{
var connection = new MockSerialConnection();
var session = CreateSerialSession(connection);
connection.EnqueueStringRequest("Test!");
session.Write("Test!");
}
示例2: ClearSession
public void ClearSession()
{
var connection = new MockSerialConnection();
var session = new ArduinoSession(connection);
session.Clear();
session.Dispose();
}
示例3: CreateSessionWithOpenConnection
public void CreateSessionWithOpenConnection()
{
var connection = new MockSerialConnection();
connection.Open();
var session = new ArduinoSession(connection);
Assert.AreEqual(true, connection.IsOpen);
}
示例4: TimeOutReached
public void TimeOutReached()
{
var connection = new MockSerialConnection();
var session = new ArduinoSession(connection);
session.TimeOut = 1;
// TODO: verder uitwerken.
}
示例5: WriteI2C_SlaveAddress_Parameter_Is127
public void WriteI2C_SlaveAddress_Parameter_Is127()
{
var connection = new MockSerialConnection();
var session = CreateFirmataSession(connection);
connection.EnqueueRequest(0xF0, 0x76, 0x7F, 0x00, 0x11, 0x00, 0x22, 0x00, 0x33, 0x00, 0x44, 0x00, 0x7F, 0x01, 0xF7);
session.WriteI2C(127, 0x11, 0x22, 0x33, 0x44, 0xFF);
}
示例6: SetI2CReadInterval_Interval_Is0x3FFF
public void SetI2CReadInterval_Interval_Is0x3FFF()
{
var connection = new MockSerialConnection();
var session = CreateFirmataSession(connection);
connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x78, 0x7F, 0x7F, 0xF7 });
session.SetI2CReadInterval(0x3FFF);
}
示例7: WriteI2C_SlaveAddress_Parameter_Is0x3FF
public void WriteI2C_SlaveAddress_Parameter_Is0x3FF()
{
var connection = new MockSerialConnection();
var session = CreateFirmataSession(connection);
connection.EnqueueRequest(0xF0, 0x76, 0x7F, 0x27, 0x7F, 0x01, 0xF7);
session.WriteI2C(0x3FF, 255);
}
示例8: ConfigureServo_MaxPulse_IsNegative
public void ConfigureServo_MaxPulse_IsNegative()
{
var connection = new MockSerialConnection();
var session = CreateServoSession(connection);
connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7 });
session.ConfigureServo(15, 0, -1);
}
示例9: ConfigureServo_MinPulse_Is0x4000
public void ConfigureServo_MinPulse_Is0x4000()
{
var connection = new MockSerialConnection();
var session = CreateServoSession(connection);
connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00 });
session.ConfigureServo(0, 0x4000, 0);
}
示例10: ConfigureServo_PinNumber_Is128
public void ConfigureServo_PinNumber_Is128()
{
var connection = new MockSerialConnection();
var session = CreateServoSession(connection);
connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00 });
session.ConfigureServo(128, 0, 0);
}
示例11: TimeOut_GetAndSet
public void TimeOut_GetAndSet()
{
var connection = new MockSerialConnection();
var session = new ArduinoSession(connection);
Assert.AreEqual(-1, session.TimeOut);
session.TimeOut = 7;
Assert.AreEqual(7, session.TimeOut);
}
示例12: GetProtocolVersionAsync
public void GetProtocolVersionAsync()
{
var connection = new MockSerialConnection();
var session = CreateFirmataSession(connection);
connection.EnqueueRequestAndResponse(new byte[] { 0xF9 }, new byte[] { 0xF9, 2, 3 });
ProtocolVersion version = session.GetProtocolVersionAsync().Result;
Assert.AreEqual(2, version.Major);
Assert.AreEqual(3, version.Minor);
Assert.AreEqual(1, _messagesReceived.Count);
}
示例13: ResetBoard
public void ResetBoard()
{
var connection = new MockSerialConnection();
var session = CreateFirmataSession(connection);
connection.EnqueueRequestAndResponse(new byte[] { 0xFF }, new byte[] { 0xF9, 2, 3 });
session.ResetBoard();
Assert.AreEqual(1, _messagesReceived.Count);
FirmataMessage message = _messagesReceived.Dequeue();
Assert.AreEqual(MessageType.ProtocolVersion, message.Type);
var version = (ProtocolVersion)message.Value;
Assert.AreEqual(2, version.Major);
Assert.AreEqual(3, version.Minor);
}
示例14: ReceivedStringBufferOverflow
public async Task ReceivedStringBufferOverflow()
{
var connection = new MockSerialConnection();
var session = CreateSerialSession(connection);
var t = Task.Run(() =>
{
string data = session.Read(1000);
}
);
connection.MockReceiveDelayed(new string('*', 3000));
await t;
}
示例15: ReadTo
public async Task ReadTo()
{
var connection = new MockSerialConnection();
var session = CreateSerialSession(connection);
var t = Task.Run(() =>
{
string data = session.ReadTo('.');
Assert.AreEqual("A line", data);
}
);
connection.MockReceiveDelayed("A line.");
await t;
}