[英]NI-DAQmx C libs over nodejs
I'm making a nodejs app that have to pull data from a NI USB 6210. National Instruments, gives away a bunch of examples that use their (pure) C libs, since, I'm on nodejs, I thought I could "easily" recycle them into a node module using node-gyp, but I discovered that node modules are more likely to be written in C++, rather than plain C ( as described in the reference ), so I was wondering about other possible solutions. 我正在制作一个必须从NI USB 6210提取数据的Node.js应用。NationalInstruments,提供了许多使用其(纯)C库的示例,因为我使用的是Node.js,我认为我可以“轻松地“使用node-gyp将它们回收到节点模块中,但是我发现节点模块更有可能是用C ++而不是纯C语言编写的( 如本参考资料中所述 ),因此我想知道其他可能的解决方案。 Aside from that the whole library thing is also based on a bunch of frameworks ( on OSX ) 除此之外,整个库还基于一堆框架(在OSX上)
/Library/Frameworks/nidaqmxbase.framework
/Library/Frameworks/nidaqmxbaselv.framework
/Library/Frameworks/lib67xx.framework
/Library/Frameworks/libDIO96.framework
/Library/Frameworks/libESeries.framework
/Library/Frameworks/libmiteDma.framework
/Library/Frameworks/libMSeries.framework
/Library/Frameworks/libSSeries.framework
/Library/Frameworks/libUSB-92xx.framework
so my second question is how does the frameworks interact with nodejs? 所以我的第二个问题是框架如何与Node.js交互? I've a little bit of confusion about this. 我对此有些困惑。
UPDATE UPDATE
Thanks to @mscdex I've built my first node module that should just wrap the frameworks and make'em available on the node side. 感谢@mscdex,我建立了第一个节点模块,该模块应该只包装框架并使它们在节点侧可用。 This is what I've done so far: 到目前为止,这是我所做的:
binding.gyp binding.gyp
{
"targets": [
{
"target_name": "addon",
"sources": [
],
"include_dirs": [
"./includes/NIDAQmxBase.h"
],
"conditions": [
[
"OS=='mac'",
{
"defines": [
"__MACOSX_CORE__"
],
"architecture": "i386",
"link_settings": {
"libraries": [
"-framework",
"nidaqmxbase",
"-framework",
"nidaqmxbaselv"
]
}
}
]
]
}
]
}
with this I've run the configure and the build commands 为此,我运行了configure和build命令
to be noticed that I'm using nw-gyp that is a hack of the node-gyp, because I need to build a module for node-webkit, but it's just like node-gyp with a few improvements. 注意,我使用的是nw-gyp ,它是node-gyp的一种工具,因为我需要为node-webkit构建一个模块,但这就像node-gyp一样,但有一些改进。
This operation produced a file called addon.node (weighted 8kb) 此操作产生了一个名为addon.node的文件(权重8kb)
After that I've tried to run a simple js test file 之后,我尝试运行一个简单的js测试文件
var ni = require('./libs/addon');
console.log(ni);
as I ran this it produced 当我运行它产生
Error: Symbol addon_module not found.
at Module.load (module.js:352:32)
at Function.Module._load (module.js:308:12)
at Module.require (module.js:360:17)
at require (module.js:376:17)
at window.require (eval at undefined, <anonymous>:1:112)
at eval (file:///Users/myUser/MyPath/MyNodeWebkitProject/public/js/ni-daqmx.js:1:10)
and that is where I'm stuck. 那就是我被困住的地方。
You can use/wrap C libraries in node (C++) with no problem. 您可以毫无问题地使用/包装节点(C ++)中的C库。
As far as the frameworks go, you should be able to add those files as libraries
in your binding.gyp file and gyp should automatically convert them to -framework lib67xx -framework libDIO96 ...
linker flags. 就框架而言,您应该能够将这些文件作为libraries
添加到您的binding.gyp文件中,并且-framework lib67xx -framework libDIO96 ...
应该自动将它们转换为-framework lib67xx -framework libDIO96 ...
链接器标志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.