C# Serial.IsOpen失败-C-Kinect
我正在开发Kinect用户界面手势识别。 我还使用了一个arduino,八个LED连接到数字引脚。LED模拟开门等输出。 所以我用了“再见”这个程序 我想增加6个手势来识别,但这不是我主题的目的。当然,如果你能告诉我,不要犹豫 因此,当识别到一个手势时,我调用我的方法在串行端口上写入内容:C# Serial.IsOpen失败-C-Kinect,c#,arduino,kinect,C#,Arduino,Kinect,我正在开发Kinect用户界面手势识别。 我还使用了一个arduino,八个LED连接到数字引脚。LED模拟开门等输出。 所以我用了“再见”这个程序 我想增加6个手势来识别,但这不是我主题的目的。当然,如果你能告诉我,不要犹豫 因此,当识别到一个手势时,我调用我的方法在串行端口上写入内容: protected override void LookForGesture() { // Swipe to right if (ScanPos
protected override void LookForGesture()
{
// Swipe to right
if (ScanPositions((p1, p2) => Math.Abs(p2.Y - p1.Y) < SwipeMaximalHeight, // Height
(p1, p2) => p2.X - p1.X > -0.01f, // Progression to right
(p1, p2) => Math.Abs(p2.X - p1.X) > SwipeMinimalLength, // Length
SwipeMininalDuration, SwipeMaximalDuration)) // Duration
{
RaiseGestureDetected("SwipeToRight");
Serial.writeSerial("A");
return;
}
当我使用调试模式时,程序会在检测到刷卡时右键停止。
所以我可以看到,通过writeSerial方法,程序试图发送一些东西,但此时串口关闭了
我的串行通信应该是正常的,因为它与按钮一起工作。
事实上,我放了几个按钮。这样我就不必一直重新连接我的手势,也因为我现在还不能这样做
如果你愿意,我也可以提供我的完整代码
多谢各位
public void writeSerial(string dataToSend)
{
sw.Start();
// Makes sure serial port is open before trying to write
try
{
if (!(_serialPort.IsOpen)) _serialPort.Open();
_serialPort.Write(dataToSend);
Console.Write("data send");
}
catch (Exception ex)
{
Console.WriteLine("Error opening/writing to serial port :: " + ex.Message, "Error!");
}