小编Pes*_*nat的帖子

如何找到可用的COM端口?

如何在我的电脑中找到可用的COM端口?我正在使用框架v1.1.是否可以找到所有COM端口?如果可能的话,帮我解决问题.

c# serial-port

14
推荐指数
3
解决办法
4万
查看次数

在C#中,我如何收听已经打开的COM(串行)端口?

我正在使用一个与我的COMM端口对话的程序,但是我已经创建了另一个程序,我想"嗅探"通信端口消息,并对这些消息执行它自己的操作.这在.NET c#中是否可行?

c# serial-port sniffing listener

9
推荐指数
1
解决办法
2万
查看次数

C++/CLI-> C#错误C2526:C连接函数无法返回C++类

我有一个使用VS2010 C#构建的简单.NET dll,它暴露了一个类的2个静态成员

public class Polygon
{
    public static void Test(int test) {}
    public static void Test(List<int> test) {}
}
Run Code Online (Sandbox Code Playgroud)

然后我从VS2010 C++创建了一个Console应用程序,并在_tmain上面添加了这个函数

extern "C" void TestMe()
{
    Polygon::Test(3);
}
Run Code Online (Sandbox Code Playgroud)

添加引用和编译会给我这个错误

1>WierdError.cpp(9): error C2526: 'System::Collections::Generic::List<T>::GetEnumerator' : C linkage function cannot return C++ class 'System::Collections::Generic::List<T>::Enumerator'
1>          with
1>          [
1>              T=int
1>          ]
1>          WierdError.cpp(9) : see declaration of 'System::Collections::Generic::List<T>::Enumerator'
1>          with
1>          [
1>              T=int
1>          ]
1>          WierdError.cpp(9) : see reference to class generic instantiation 'System::Collections::Generic::List<T>' being compiled
1>          with …
Run Code Online (Sandbox Code Playgroud)

c# c++-cli visual-studio-2010 extern linkage

9
推荐指数
1
解决办法
3836
查看次数

BOOST_FOREACH对boost :: shared_ptr <list>的迭代

我正在做类似这个项目正确的BOOST_FOREACH用法吗?

但是,我返回的列表包含在boost :: shared_ptr中.如果我没有在BOOST_FOREACH循环之前将列表分配给变量,那么我会在运行时遇到崩溃,因为列表正在被破坏,因为它是临时的.

boost::shared_ptr< list<int> > GetList()
{
    boost::shared_ptr< list<int> > myList( new list<int>() );
    myList->push_back( 3 );
    myList->push_back( 4 );
    return myList;
}
Run Code Online (Sandbox Code Playgroud)

然后......

// Works if I comment out the next line and iterate over myList instead
// boost::shared_ptr< list<int> > myList = GetList();

BOOST_FOREACH( int i, *GetList() ) // Otherwise crashes here
{
    cout << i << endl;
}
Run Code Online (Sandbox Code Playgroud)

我希望能够使用上面的内容而不必引入变量'myList'.这可能吗?

c++ boost shared-ptr temporaries boost-foreach

7
推荐指数
1
解决办法
2883
查看次数

如何在不使用外部API的情况下从python中的串口读取?

我必须通过串口读取从自制设备发送的流.问题是它应该部署在我无法安装任何新东西的机器上,这意味着我必须使用python标准库来执行此操作.这是可能的,如果是这样,我该如何管理呢.

如果事实证明几乎是不可能的,我将不得不让某人安装pySerial,但如果没有这个可以做到,我会非常感激.

如果在Linux/Windows的差异,这是在Windows机器上,但我真的很感激一个跨平台的解决方案.

python serial-port

6
推荐指数
1
解决办法
4281
查看次数

4
推荐指数
1
解决办法
5078
查看次数

对数组进行排序而不是对ArrayList进行排序

我有一个数组,而不是一个arrayList,我想对它进行排序.这只告诉我Collections不适用于参数(pixelPlaceSort.Pixel [],...等.

Collections.sort(pixels, new PixelComparator());
Run Code Online (Sandbox Code Playgroud)

我可以使用List来解决它,但为了学习的目的,我不希望这样.

那怎么能起作用呢?c是一个int.

class PixelComparator implements Comparator<Pixel> {

  PixelComparator() {
  }

  public int compare(Pixel p1, Pixel p2) {
    if(p1.c < p2.c) {
      return -1; 
    } else if(p1.c > p2.c) {
      return 1; 
    }
    else {
      return 0; 
    }
  }


}
Run Code Online (Sandbox Code Playgroud)

java arrays sorting processing

0
推荐指数
1
解决办法
266
查看次数