问题标签 [interfacing]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
65 浏览

python - 在 c++ 中使用 python 中的 python 类实例(增强)

我正在寻找一种方法来创建用 python 编写的类的实例并从 c++ 调用它的方法。如果可用,我更愿意包含 boost python 库。我想像在 python 中有一个类

我已经找到了很多线程,如何使用 python 库在 c++ 中导入 python 模块,也许我已经找到了一种方法来创建类的实例。

但从那时起,我就陷入了困境。如何创建类的实例并调用其方法?

谢谢

0 投票
0 回答
515 浏览

r - Allocatable array is already allocated when interfacing Fortran with R

I am working on interfacing some modern Fortran code with R and get the following error:

forrtl: severe (151): allocatable array is already allocated

Even though the error message is the same, I don't think the origin of this issue is not directly related with this entry here


The problem/background:

I have compiled my Fortran code myself as shared object, using ifort and the relevant flags

I can call the shared object using .Fortran once in R. Then I have to do dyn.unload("HX.so") in order to then reload it (dyn.load("HX.so") and rerun it.

Just running and rerunning an R script that finishes the R session in between works fine.

During single runs and after loading and unloading in R, the content that is passed back to me in my R session or printed during running the R script is the expected output.

Here is what else is shown after the error message:


What I have tried so far:

As the error message suggests, I have identified all ALLOCATED ALLOCATABLES and looked whether they are all DEALLOCATED as well. I did find a few that were not, but that has not solved the issue.

I checked that the Fortran code is running until the end using a simple WRITE (*,*) 'END' statement before END SUBROUTINE.


The aim is to be able to call the Fortran code many times in R, to do sensitivity analysis- so, always having to unload and load it would slow things down substantially.

If you think I need to provide more information, let me know.


edit: compiling with -g -traceback does not catch anything at run or compile time.

compiling with -g -traceback -check catches the following error at runtime:

line 278 in the "main" subroutine (HX) calls subroutine INIT, which then in line 27 shows an ALLOCATABLE. Doing grep I have not found it being allocated anywhere else. NOTE: but it also was not deallocated anywhere..

all flags used:

My R-code:


NOTE- solution: It was actually a DEALLOCATE issue.. Not all allocated arrays had been deallocated by the end of the run..and I simply had not found them all ( even though that was one of therouble shooting attempts I had made in advance of posting this..) Is my guess correct that maybe the compiler didn't pick up on the issue because unlike in the previous post on stackoverflow, the (de-)allocation was not technically in a loop ( until I turned the Fortran executable into a shared object)? I would find this surprising, but the only info I found is that deallocation is just "good programming practice" ?

0 投票
2 回答
457 浏览

embedded - 无法将值 1 设置为 MPLAB 中的输入引脚

我正在使用 MPLAB 对 PIC 套件 14f458 执行操作。

现在我想创建一个代码,使用按钮通过微控制器传递不同数量的电压电源 LED。第一次按下按钮时,我应该得到 10% DC 的波形,第二次和第三次分别为 50% 和 95%。

我已经解决了这个问题,但仍然将 RE2 PORT 的值设为 0 而不是 1。而且我也不知道在释放按钮时如何停止计时器。

我的代码如下:

我的编译器卡在函数 timer_10() 中。请帮我。

0 投票
1 回答
456 浏览

xml - 将原生 DDS 系统与 ROS2 连接

要与基于 ROS2 的发布者和基于 RTI Connext 的订阅者进行通信,它们都需要具有兼容的 QoS 设置。

我正在使用 RTI Connector for python 并使用 XML Application Creation 来运行订阅者。

talker_py在具有默认QoS 的 ROS2 中运行一个并在 RTI Connext Pro 中订阅这些消息。

ROS2 IDL 看起来像这样:

我使用rtiddsgen实用工具将其转换为 XML 文件。这是转换后的 XML:

我添加<types>到我的USER_QoS.xml,它看起来像:

现在,当我使用 RTI Connector for python 时,这里的第一步是尝试加载USER_QoS.xml文件,它总是给出错误Unable to parse the .xml file。我强烈认为这是因为定义中存在module关键字<types>

这是 RTI 连接器的 python 脚本:

我觉得连接器无法解析这个module关键字。会不会是这样?

0 投票
1 回答
55 浏览

java - Android libgdx: NullPointerException on SQLiteOpenHelper database

I am trying to write a code in my game to save the score when the player dies. For that purpose I implemented an interface to use SQLiteOpenHelper (the interface is in the core project and the SQLiteOpenHelper is in the android project). For anyone doesn't know, the interface thing is for this purpose see code

The problem is that when I want to save the score (int) the game crashes and an NullPointerException appears.

My code:

In the android project, the database using SQLiteOpenHelper:

#xA;

Next, the main class of the android project with the database implemented:

#xA;

In the core project, the interface that is implemented in the database of the android project:

#xA;

In the main class of the core project (CatchEmAll.java), the implementation of the interface:

#xA;

Finally the game screen of the game (in core project), where I want to save the score using that interface:

#xA;

The null exception is in db.addScore(score);

I guess i'ts because I need to use the DatabaseInterface created in the main class of the core project (CatchemAll.java) but I don't know how can I do that and if this is the problem or not. Use Android API in libgdx is a nightmare.

logcat error:

08-23 14:13:41.961 7568-7596/borruey.catchemall E/AndroidRuntime: FATAL EXCEPTION: GLThread 282 Process: borruey.catchemall, PID: 7568 java.lang.NullPointerException: Attempt to invoke interface method 'void borruey.catchemall.databasescore.DataBaseInterface.addScore(int)' on a null object reference at borruey.catchemall.screens.GameScreen.render(GameScreen.java:182) at com.badlogic.gdx.Game.render(Game.java:46) at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:495) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1571) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270) 08-23 14:13:45.978 7568-7568/borruey.catchemall E/AndroidGraphics: waiting for pause synchronization took too long; assuming deadlock and killing

0 投票
1 回答
67 浏览

python - 从网络控制机器人

我正在尝试让 RPi3 机器人接受来自 Web 和触摸屏/键盘界面的命令。我有一个处理键盘的脚本,我正在寻找我在 Python 中拥有的当前脚本以扩展以接受来自网络的实时输入。以及试图弄清楚如何将数据发送到脚本。

更多细节如下,但这是基本问题。

我使用树莓派和 3 个控制直流电机和伺服系统的 arduino 来创建机器人,以使机器人移动。该程序是用 Python 编写的,并从命令行运行。运行时:

  • 查询 Raspberry 上的活动串口
  • 打开每个可用端口
  • 向接收方 arduino 发送一个整数
  • arduino 以识别整数响应,因此 RPI 可以命名端口
  • 然后脚本等待用户输入,如“转发”
  • 命令被翻译并发送到正确的端口
  • 机器人移动

这一切都很完美。现在我想扩展它。我想保持这个功能完好无损并添加一个网络界面,这样我就可以从任何地方控制它。我尝试了几种不同的方法,但都没有成功。我已经安装了 apache,并且可以毫无问题地为页面提供服务,我可以获取页面上的数据,但我无法弄清楚如何让网页将数据发送到正在运行的 arduino 脚本。我的问题源于机器人控制脚本需要独立于网页运行。我现在仍然希望从键盘保持相同的输入,但我也希望它接受来自网页的数据。如果我每次都从网页调用机器人控制器,则每次都需要重新建立端口连接,这最多需要 20 秒...

我在想,如果我创建一个监听脚本,我可以让网站调用监听器,该监听器只会运行以接收来自网络的数据并将其传递给机器人控制器并返回。但我不确定如何做到这一点,或者这是否是最好的方法。

我查看了 websockets、CGI/wsgi、Flask、编写文件和 JSON,但我似乎无法将它们全部串起来。

如果这不是在正确的地方或之前已经回答过,请提前致谢并道歉。此外,我没有包含任何代码,因为唯一可靠的代码是机器人控制器。我希望有一些真正专业知识的人可以帮助我解开这个问题。

在此先感谢肯V

0 投票
1 回答
148 浏览

string - How does std.string.toStringz work in dlang?

https://dlang.org/library/std/string/to_stringz.html

In my understanding it could not work:

toStringz creates an array on the stack and returns its pointer. After toStringz returns, the array on the stack is discarded and the pointer becomes invalid.

But I suppose it indeed works because of being a part of the standard library. So what is wrong in my understanding of the above?

Another related question:

What does scope return in the signature of this function mean? I visited https://dlang.org/spec/function.html but found no scope return there.

0 投票
0 回答
95 浏览

interfacing - 微控制器接口:芯片使能程序错误

如何解决 progisp.172 中用于接口 8051 微控制器的芯片使能程序错误

0 投票
0 回答
960 浏览

stm32 - 如何使用 spi 通信将 STM32F302R8 与 ADS1256 连接?

我尝试使用 SPI 通信连接 Nucleo-F302R8 和高精度 AD/DA 波共享板。虽然这样做我无法传输或接收数据。我使用 spi3 进行通信,并为芯片选择引脚提供了 ai/o。spi_clk 引脚不产生任何时钟脉冲。我尝试通过环回调试 spi,发现在 mosi 引脚上发生了接收,但时钟又是空的(使用数字示波器检查。我是这个环境的新手,需要很大的帮助。我已经分享了我的代码片段Spi配置:2lines,8bit,极性低,相位1edge,msb在前

0 投票
1 回答
29 浏览

python - 为什么 pyautogui 不会在绘图软件中突出显示和使用键盘动作?(这可以解决吗)

我正在使用像素工作室来制作一些动画。我能够自动化它。但是,pyautogui 按键和鼠标拖动交互不起作用。点击有效,但拖动以突出显示和键盘箭头按键无效。我在我的桌面上测试了代码——点击和键盘移动和拖动以突出显示所有工作正常,但是一旦我进入绘图系统,只有点击可以。是什么导致了这个问题,有没有办法解决它?谢谢!(代码如下所示供参考)