thanks for solving the A/D driver problem, Mr xtang

(In qnx host, so use english)
Mr xtang:
First thanks so much for your guidance on the serial port communication. I will try my best to correct my code following your suggestions.
Sorry to trouble you but this A/D driver problem has confused me about these two days. Pls point me the road to rome.

Just as I described in one former subject, the A/D card provide a universal driver for QNX.

after “tar”, I can get a header(dscud.h) and a library(libdscud5.a). I have checked the header file, all the functions I will use in my programe are listed in it and I think it do the initialization job.

First I copy the header file to the /usr/include foder(I debug and run the .c code in the local host). Then I include the dscud.h at the beginning of the source code.Its ok.
But how can I include the .a library.Actually it is a long time problem for me because I could never see the .a and .so library in the “C/C++ project” perspective in my IDE.
I also tried 1).properties->library
paths->/opt/dscud5 (which is the location of the library).
2).copy the (.a)file into /usr/lib & /x86/lib and then build in IDE
But no use. Actually I am not clear how to use the properties to add a new library. (If ok, please give me a guidance).The code could not recognize the functions listed in the <dscud.h>.
So please help me where I make mistake? Do I put the .a in the wrong folder or sth else?
And if not bothering you too much, could you guide me how to add a new library into a project in the IDE and then show these in the “C/C++” perspective?

Actually I also try the cmd line compiling according the manufacture’s notes:
$ gcc /root/workspace/daqtest/daqtest.c -o -I/opt/dscud5 -L/opt/dscud5 -llibdscud5

but get the following:

gcc /root/workspace/daqtest/daqtest.c -o daqtest -I /opt/dscud5 -L /opt/dscud5 -llibdscud5

/root/workspace/daqtest/daqtest.c: In function `PeriodicThread’:
/root/workspace/daqtest/daqtest.c:49: warning: return makes pointer from integer without a cast
/root/workspace/daqtest/daqtest.c:60: warning: return makes pointer from integer without a cast
/root/workspace/daqtest/daqtest.c:90: warning: return makes pointer from integer without a cast
/root/workspace/daqtest/daqtest.c:102: warning: return makes pointer from integer without a cast
/root/workspace/daqtest/daqtest.c:118: warning: return makes pointer from integer without a cast
/root/workspace/daqtest/daqtest.c:125: warning: return makes pointer from integer without a cast
/usr/bin/ntox86-ld: cannot find -llibdscud5
collect2: ld returned 1 exit status

I am totally confused and dont know why QNX cant find the .a file. Could you give a explanation again?

Sorry to trouble you too much! ANd Many thanks again!!!

your tar file needs to be untarred into the directory /opt/dscud5

please check the files in there "ls -l /opt/dscud5 "
it should show a header(dscud.h) and a library(libdscud5.a).

The Manufacture’s gcc line does not looks right, try use qcc

$ qcc /root/workspace/daqtest/daqtest.c -o daqtest -I/opt/dscud5 -L/opt/dscud5 -ldscud5

By the way, even in QNX, try to run “cpim” in photon, you can type in Chinese from there :slight_smile:

xtang is correct, if the library name is libdscud5.a, you will need to link with -ldscud5

Xtang 先生 Liug先生:

非常谢谢你们的讲解。 我更改了libdscud5 to
ldscud5,的确可以找到這個庫函數了,但是出现了别的奇怪提示,如下:

qcc /root/workspace/daqtest/daqtest.c -o daqtest -I/opt/dscud5 -L/opt/dscud5 -ldscud5

/root/workspace/daqtest/daqtest.c: In function PeriodicThread': /root/workspace/daqtest/daqtest.c:49: warning: return makes pointer from integer without a cast /root/workspace/daqtest/daqtest.c:60: warning: return makes pointer from integer without a cast /root/workspace/daqtest/daqtest.c:90: warning: return makes pointer from integer without a cast /root/workspace/daqtest/daqtest.c:102: warning: return makes pointer from integer without a cast /root/workspace/daqtest/daqtest.c:118: warning: return makes pointer from integer without a cast /root/workspace/daqtest/daqtest.c:125: warning: return makes pointer from integer without a cast /opt/dscud5/libdscud5.a(herc.o): In function HERCRefVoltToBytes’:
herc.o(.text+0x3577): undefined reference to floor' /opt/dscud5/libdscud5.a(dmm48.o): In function DMM48RefVoltToBytes’:
dmm48.o(.text+0x3047): undefined reference to floor' /opt/dscud5/libdscud5.a(common.o): In function DSCGetCounterFactor’:
common.o(.text+0xf1): undefined reference to sqrt' /opt/dscud5/libdscud5.a(dmm16at.o): In function DMM16ATRefVoltToBytes’:
dmm16at.o(.text+0x2e3b): undefined reference to floor' /opt/dscud5/libdscud5.a(dmm32.o): In function DMM32RefVoltToBytes’:
dmm32.o(.text+0x3c9f): undefined reference to floor' /opt/dscud5/libdscud5.a(dmmat.o): In function DMMATRefVoltToBytes’:
dmmat.o(.text+0x2e5f): undefined reference to `floor’
cc: /usr/bin/ntox86-ld error 1

不太清楚是这个.a函数库本身有问题,还是我又犯了什么错误,您们帮忙看看,好吗,我也同时发信给厂商的tech support了,如果有回音我也会贴在咱们网上。

另外一个问题就是:希望您们能给一个指导:像我这种情况,得到一个新的library,并要用到其中的函数,如何在IDE中将这个库包含进去,并正确使用它呢?还有,开哪个窗口我可以检测到我的project已经包含了这个库了呢?(用了properties――>library path,添加了我这个libdscud5.a的路径,不管用,虽然在C-build console的提示里看到这个路径被包含进去了,但是仍然是不认所包含的函数)。我也从没看到libc.so文件出现在我的project的下拉菜单中,觉得可能这和包含新的library的问题可以一起解决,麻烦您们了。

为了更清楚一点,我放一些源文件,您们帮忙看一下,
1)。比如这是我用到的dscud.h 的一部分:
/*/////////////
// DSCADSCAN //
//////////// */

typedef struct
{

BYTE low_channel; /* INPUT: Low channel of the scan /
BYTE high_channel; /
INPUT: High channel of the scan */
DSCSAMPLE sample_values; / I/O: The user must point this to memory that has been allocated and ready to accept (high - low + 1) DSCADSAMPLE values into it /
BYTE gain; /
Obsolete */

} DSCADSCAN;
.
.
.
//////////////////
// A/D Functions //
//////////////// /


BYTE DSCUDAPICALL dscADScan(DSCB board, DSCADSCAN
dscadscan, DSCSAMPLE
sample_values);

.
.
.

(您们看,函数声明了)

2).
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include <sys/netmgr.h>
#include <sys/neutrino.h>

//include the daq header
#include <dscud.h>
// Define the codes for the pulses
#define Pulse_Timer _PULSE_CODE_MINAVAIL
#define Pulse_Exit _PULSE_CODE_MINAVAIL + 1
typedef union {
struct _pulse pulse;
} ThreadMessage;

int iChannelIdentifier,i=1;

void* PeriodicThread(void *vArguments)
{
ThreadMessage tmMessage;
int iReceiveIdentifier;
DSCB dscb;
.
.
DSCADSETTINGS dscadsettings;
DSCADSCAN dscadscan;
.
.initialzation
.
// Infinite loop
while(1)
{
// Receive the message
printf(“before\n”);
iReceiveIdentifier = MsgReceive(iChannelIdentifier, &tmMessage,sizeof(ThreadMessage), NULL);
printf(“after\n”);
.
. Check if this is a pulse message
if(iReceiveIdentifier == 0)
{
.
.
.
// do the scan and test results
if((result = dscADScan(dscb, &dscadscan, dscadscan.sample_values)) != DE_NONE)
{
dscGetLastError(&errparams);
fprintf(stderr, “dsc AD scan failed %s (%s)\n”, dscGetErrorString(result), errparams.errstring);
return result;
}
else
{
printf(“Now its time to show the data\n”);
printf(“DATA is: %X, %X, %X, %X\n”, dscadscan.sample_values[0], dscadscan.sample_values[1], dscadscan.sample_values[2], dscadscan.sample_values[3]);
}
}

}
// Display the destruction message
printf(“Destroying thread\n”);
}


int main( void )
{ .
.initialization
.create the above thread
.

// Activate the timer
timer_settime(tTimerIdentifier, 0, &itsTimerSpecification, NULL);

while(getchar() != ‘q’)
{
printf(“in the loop …\n”);
}

// Display the status
printf(“destroying thread\n”);
printf(“i=%d\n”,i);

// Construct the destruct message
//tmMessage.pulse.code = Pulse_Exit;
//Send the destruct message
MsgSendPulse(seEvent.sigev_coid, 1, Pulse_Exit, Pulse_Exit);
return EXIT_SUCCESS;
}
这是我写的code的一部分,(compile完了错误一堆,都是提示 undefined reference to
`函数名 such as ‘dscADscan’)

今天一上午有没搞定,真的很麻烦您们再给指点指点
我该怎么做? 谢谢!!!!!!!!

/opt/dscud5/libdscud5.a(herc.o): In function HERCRefVoltToBytes': herc.o(.text+0x3577): undefined reference to floor’
/opt/dscud5/libdscud5.a(dmm48.o): In function DMM48RefVoltToBytes': dmm48.o(.text+0x3047): undefined reference to floor’
/opt/dscud5/libdscud5.a(common.o): In function DSCGetCounterFactor': common.o(.text+0xf1): undefined reference to sqrt’
/opt/dscud5/libdscud5.a(dmm16at.o): In function DMM16ATRefVoltToBytes': dmm16at.o(.text+0x2e3b): undefined reference to floor’
/opt/dscud5/libdscud5.a(dmm32.o): In function DMM32RefVoltToBytes': dmm32.o(.text+0x3c9f): undefined reference to floor’
/opt/dscud5/libdscud5.a(dmmat.o): In function DMMATRefVoltToBytes': dmmat.o(.text+0x2e5f): undefined reference to floor’

这里不是刚讨论过吗?

首先谢谢tang先生和liug先生的指点,关于这个a/d编程,今天又继续研究了一下,请教一个问题:

我在命令行调试中用了这个命令:
$ qcc /root/workspace/daqtest/daqtest.c -o daqtest -I/opt/dscud5 -L/opt/dscud5 -ldscud5 -lm

的确能够正确地得到可执行文件 daqtest ,但是它是在/ 目录下,而不是出现在/root/workspace/daqtest/x86/o/之中,请问这是为什么呢

之后我又回到IDE环境下进行调试, 但是很苦恼的是,我得不到可执行文件,我是这么做的:
1。 copy libdscud5.a 到/x86/lib之中,
2。 右击 daqtest project,并选择property, 指定library paths 为 /dscud5 和 /x86/lib
(其实经过拷贝后,这两个目录都含有libdscud5.a这个文件)
3。 指定Extra libs为: libdscud5 和 libm

退出,保存,compile, 结果失败(哎~~~~)

得到的部分提示如下:

make[1]: Entering directory /root/workspace/daqtest/x86' make -j 1 -Co -fMakefile all ; make -j 1 -Co-g -fMakefile all make[2]: Entering directory /root/workspace/daqtest/x86/o’
/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall -Wc,-Wno-parentheses -O -P -DNDEBUG -I. -I/root/workspace/daqtest/x86/o -I/root/workspace/daqtest/x86 -I/root/workspace/daqtest -I/usr/include -p /root/workspace/daqtest/daqtest.c
/bin/rm -f /root/workspace/daqtest/x86/o/daqtest
/usr/bin/qcc -Vgcc_ntox86 -o/root/workspace/daqtest/x86/o/daqtest daqtest.o -L. -L/dscud5 -L/x86/lib -L/x86/lib -L/x86/usr/lib -Bstatic -llibdscud5 -llibm -p
/usr/bin/ntox86-ld: cannot open daqtest.o: No such file or directory
cc: /usr/bin/ntox86-ld error 1
make[2]: *** [/root/workspace/daqtest/x86/o/daqtest] Error 1
make[2]: Target all' not remade because of errors. make[2]: Leaving directory /root/workspace/daqtest/x86/o’
make[2]: Entering directory /root/workspace/daqtest/x86/o-g' /usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall -Wc,-Wno-parentheses -P -I. -I/root/workspace/daqtest/x86/o -I/root/workspace/daqtest/x86/o-g -I/root/workspace/daqtest/x86 -I/root/workspace/daqtest -I/usr/include -g -DVARIANT_g -p /root/workspace/daqtest/daqtest.c /bin/rm -f /root/workspace/daqtest/x86/o-g/daqtest_g /usr/bin/qcc -Vgcc_ntox86 -o/root/workspace/daqtest/x86/o-g/daqtest_g daqtest.o -L. -L/dscud5 -L/x86/lib -L/x86/lib -L/x86/usr/lib -Bstatic -llibdscud5_g -llibm_g -g -p /usr/bin/ntox86-ld: cannot open daqtest.o: No such file or directory cc: /usr/bin/ntox86-ld error 1 make[2]: *** [/root/workspace/daqtest/x86/o-g/daqtest_g] Error 1 make[2]: Target all’ not remade because of errors.
make[1]: *** [all] Error 2
make: *** [all] Error 2
make[2]: Leaving directory /root/workspace/daqtest/x86/o-g' make[1]: Leaving directory /root/workspace/daqtest/x86’
好像是找不到这个dscud5-g 什么的,请您们给指点一下,我不太懂这是什么意思,
该怎么修改才能在IDE环境中的正确目录下得到可执行文件呢?

非常谢谢!

xtang和liug先生:
不好意思麻烦你们, 如果你们不忙的时候,请指点一下我现在的问题(今天又是郁闷之一天~~没啥进展)

thanks for your concern!!

Extra lib 应该是 dscud5 和 m 吧