C-talk with SRR IPC for QNX6.3

Hi all,

C-talk for QNX6.3 is available with complete sources at

http://wwww.sf.net/projects/openqnx

It’s an enhanced version with native message passing IPC and other QNX6
specific enhancements.

Below is an example for a client/server application …

Regards

Armin Steinhoff


//*****************************************************************************
//*
//* STEINHOFF Automation & Fieldbus Systems
//*
//* www.steinhoff-automation.com
//*
//*****************************************************************************/

loadDLL(“QNXlib”);
delay = ‘qnxDelay’;

name_attach=‘name_attach’;
MsgReceive=‘qnxMsgReceive’;
MsgReply=‘qnxMsgReply’;
name_attach=‘qnxNameAttach’;


CTK_INTEGER = 1;
CTK_REAL = 2;
CTK_RAW_POINTER = 4;
CTK_STRING = 5;

attach = ‘AllocRawObj’(32);
rcvmsg = ‘AllocRawObj’(128);
rplmsg = ‘AllocRawObj’(41);
‘SetRawObjValue’(rplmsg, ‘0123456789012345678901234567890123456789’);

NULLptr = ‘AllocRawObj’(0);

chid = name_attach(“server”, attach);
println("CHID: ", chid);

for(;:wink:
{
recvid = MsgReceive(chid, rcvmsg, 128, NULLptr);
if(recvid != -1)
{
val = ‘GetRawObjValue’(rcvmsg, CTK_STRING);
println("message received: ", val);
MsgReply(recvid, 0, rplmsg, 41);
}
}



//*****************************************************************************
//*
//* STEINHOFF Automation & Fieldbus Systems
//*
//* www.steinhoff-automation.com
//*
//*****************************************************************************/

loadDLL(“QNXlib”);
delay = ‘qnxDelay’;
getClock = ‘qnxGetClock’;

MsgSend=‘qnxMsgSend’;
MsgReply=‘qnxMsgReply’;
name_open=‘qnxNameOpen’;


CTK_INTEGER = 1;
CTK_REAL = 2;
CTK_RAW_POINTER = 4;
CTK_STRING = 5;

recvmsg = ‘AllocRawObj’(41); // pointer object ref. receive buffer
sendmsg = ‘AllocRawObj’(128);
‘SetRawObjValue’(sendmsg,
‘qwertyuiopasdfghjklzxcvbnm0123456789012345678901234567890123456789’);

coid = name_open(“server”);

if(coid > 0)
{
start = getClock();
for(i=0; i < 1000000; i++)
{
resp = MsgSend(coid, sendmsg, 128, recvmsg, 41);
if(resp == -1)
{
println("Error: ", resp);
}
else
{
val = ‘GetRawObjValue’(recvmsg, CTK_STRING);
println("received msg: ",val);
}

delay(1);
}
stop = getClock();
println(“time=”, stop - start);
}
else
println(“Error: server not started …”);

Armin Steinhoff wrote:

Hi all,

C-talk for QNX6.3 is available with complete sources at

http://wwww.sf.net/projects/openqnx
^^^^

Sorry for that world-wide-waste of ‘w’

-Armin

It’s an enhanced version with native message passing IPC and other QNX6
specific enhancements.

Below is an example for a client/server application …

Regards

Armin Steinhoff


//*****************************************************************************

//*
//* STEINHOFF Automation & Fieldbus Systems
//*
//* > www.steinhoff-automation.com > –
//*
//*****************************************************************************/


loadDLL(“QNXlib”);
delay = ‘qnxDelay’;

name_attach=‘name_attach’;
MsgReceive=‘qnxMsgReceive’;
MsgReply=‘qnxMsgReply’;
name_attach=‘qnxNameAttach’;


CTK_INTEGER = 1;
CTK_REAL = 2;
CTK_RAW_POINTER = 4;
CTK_STRING = 5;

attach = ‘AllocRawObj’(32);
rcvmsg = ‘AllocRawObj’(128);
rplmsg = ‘AllocRawObj’(41);
‘SetRawObjValue’(rplmsg, ‘0123456789012345678901234567890123456789’);

NULLptr = ‘AllocRawObj’(0);

chid = name_attach(“server”, attach);
println("CHID: ", chid);

for(;:wink:
{
recvid = MsgReceive(chid, rcvmsg, 128, NULLptr);
if(recvid != -1)
{
val = ‘GetRawObjValue’(rcvmsg, CTK_STRING);
println("message received: ", val);
MsgReply(recvid, 0, rplmsg, 41);
}
}



//*****************************************************************************

//*
//* STEINHOFF Automation & Fieldbus Systems
//*
//* > www.steinhoff-automation.com > –
//*
//*****************************************************************************/


loadDLL(“QNXlib”);
delay = ‘qnxDelay’;
getClock = ‘qnxGetClock’;

MsgSend=‘qnxMsgSend’;
MsgReply=‘qnxMsgReply’;
name_open=‘qnxNameOpen’;


CTK_INTEGER = 1;
CTK_REAL = 2;
CTK_RAW_POINTER = 4;
CTK_STRING = 5;

recvmsg = ‘AllocRawObj’(41); // pointer object ref. receive buffer
sendmsg = ‘AllocRawObj’(128);
‘SetRawObjValue’(sendmsg,
‘qwertyuiopasdfghjklzxcvbnm0123456789012345678901234567890123456789’);

coid = name_open(“server”);

if(coid > 0)
{
start = getClock();
for(i=0; i < 1000000; i++)
{
resp = MsgSend(coid, sendmsg, 128, recvmsg, 41);
if(resp == -1)
{
println("Error: ", resp);
}
else
{
val = ‘GetRawObjValue’(recvmsg, CTK_STRING);
println("received msg: ",val);
}

delay(1);
}
stop = getClock();
println(“time=”, stop - start);
}
else
println(“Error: server not started …”);