适用于Linux的虚拟串行端口(Virtual Serial Port for Linux)
我需要在Linux上测试一个串口应用程序,但是我的测试机只有一个串口。
有没有办法向Linux添加虚拟串口,并通过shell或脚本模拟设备来测试我的应用程序?
注意:我无法重新映射端口,它在ttys2上硬编码,我需要在应用程序写入时进行测试。
I need to test a serial port application on Linux, however, my test machine only has one serial port.
Is there a way to add a virtual serial port to Linux and test my application by emulating a device through a shell or script?
Note: I cannot remap the port, it hard coded on ttys2 and I need to test the application as it is written.
原文:https://stackoverflow.com/questions/52187
最满意答案
该问题是由在Windows上运行PyScripter(v2.5.3.0)中的代码引起的。 从命令行运行工作正常。
The issue was caused by running the code in PyScripter (v2.5.3.0) on windows. Running from the command line worked fine.
相关问答
更多-
正如医生所说(也在你的描述中), 进程是并行工作者可以一起运行的数量,如果没有设置,它将与计算机中的CPU数量相同。 maxtasksperchild是每个进程可以处理的最大任务数, 这意味着如果完成的任务数量达到了maxtasksperchild,那么该进程将被终止,并且将启动一个新进程并将其添加到Pool 我来看看代码: def f(x): print "pid: ", os.getpid(), " deal with ", x sys.stdout.flush() if __name ...
-
Python 2.7:进程池不工作(创建了无限工作者)(Python 2.7: process pool not working (inifinite workers created))[2022-03-30]
该问题是由在Windows上运行PyScripter(v2.5.3.0)中的代码引起的。 从命令行运行工作正常。 The issue was caused by running the code in PyScripter (v2.5.3.0) on windows. Running from the command line worked fine. -
Python无法使用multiprocessing.pool分配内存(Python cannot allocate memory using multiprocessing.pool)[2022-08-04]
正如对我的问题的评论所示,答案来自Puciek。 解决方案是在完成后关闭进程池。 我认为它会自动关闭,因为results变量对RunMany是本地的,并且在RunMany完成后将被删除。 但是,python并不总是按预期工作。 固定代码是: def RunMany(inputs): from multiprocessing import cpu_count, Pool proc=inputs[0] pool=Pool(processes = proc) results=[] for arg1 in inp ... -
在调用multiprocessing.Pool , multiprocessing模块会创建几个新进程(使用os.fork或类似的)。 默认情况下,在fork ,新进程会继承所有打开的文件描述符。 当您使用subprocess.PIPE参数调用subprocess.Popen , subprocess.PIPE subprocess模块会创建一些新的管道文件描述符,以向/从新流程发送数据。 在这种特殊情况下,管道用于将数据从父进程(python)发送到子进程(gzip),并且gzip将退出 - 从而使pro ...
-
建议为每个进程创建一次MongoClient ,而不是为每个进程共享同一个客户端。 这是因为MongoClient还使用连接池处理来自进程的多个连接,并且不是fork-safe 。 首先,当要处理的集合中的每个文档都已耗尽时,您希望确保while循环中断。 尽管这并不是所有的细节条件,但是如果skipped的循环数大于文档数,则可以打开循环。 其次,初始化循环外的进程Pool ,并在循环内映射进程。 multiprocessing.Pool.map等待子进程完成并返回,因此加入池将导致异常。 如果你想异步运 ...
-
加速与PC的CPU核心数量成正比,而不是块的数量。 理想情况下,如果你有4个CPU核心,你应该看到4倍的加速。 在考虑性能改进时,还必须考虑其他因素,例如IPC开销。 产生太多进程也会对您的性能产生负面影响,因为它们会相互竞争CPU。 我建议使用multiprocessing.Pool来处理大多数逻辑。 如果您有多个参数,只需使用apply_async方法。 from multiprocessing import Pool pool = Pool() for file_chunk in file_chu ...
-
我为Runnable创建了一个CallableDecorator来解决这个问题。 现在即使使用GenericObjectPool,我也有正确的返回值。 由于现在对于读取状态没有依赖于Pool对象,即使重用对象也不会导致状态重置 - 因此,代码中的2个更改 - 更改 futures.add(completionService.submit(myRunnable, myRunnable)); 至 futures.add(completionService.submit(new CallableDecorato ...
-
如何初始化具有共享状态的python多进程工作者池?(How to initialize a pool of python multiprocessing workers with a shared state?)[2023-06-07]
解决方案就像为doc2vec和regressions使用全局一样简单。 The solution as simple as using a global for both doc2vec and regressions. -
你想使用join方法 ,它暂停主进程线程向前移动,直到所有子进程结束: 阻塞调用线程,直到调用join()方法的进程终止或发生可选超时。 from multiprocessing import Process def f(name): print 'hello', name if __name__ == '__main__': processes = [] for i in range(10): p = Process(target=f, args=('bob', ...
-
事实证明,这只是在Wing编辑器中运行调试模式时的一个问题,请参阅Stephan Deibels评论我的其他问题multiprocessing.Pool似乎在Windows中工作但在ubuntu中不起作用? 。 It turned out that this was only a problem when running the Debug mode in the Wing Editor, see Stephan Deibels comment in my other question multiproce ...