Resource Manager: Serial Ports

bridged with qdn.public.qnxrtp.x86
Post Reply
Douglas Mota Dias

Resource Manager: Serial Ports

Post by Douglas Mota Dias » Sun Dec 22, 2002 1:13 pm

Dear friends,
I'm building a resource manager to deal with serial ports under QNX 6.1 RTP
Neutrino2. Everything was ok until I start to write my devctl() handler
function.
The problem is that I can't set the output baud rate inside my_devctl()
function. I try to do it using a client test program that I've built.
Debugging the 2 programs I've noted that the problem is that the pointers
"data" (in my_devctl) and "termios_p" (in client) are pointing to different
addresses. How can it be? Shouldn't the macro _DEVCTL_DATA points "data"
to the data area of "msg"?
I'm sending my codes above.
Please help me. I'm very worried about it because it's my
university-graduating project and I have to finish it until January.

Best Regards and Merry Christmas.
Douglas Mota Dias, Rio de Janeiro, Brazil.
e-mail: douglasm@uninet.com.br


This is my devctl() handler function that's inside my resource manager:

static int
my_devctl (resmgr_context_t *ctp, io_devctl_t *msg, iofunc_ocb_t *ocb)
{
int sts;
struct termios *data;

if (msg -> i.dcmd == DCMD_CHR_TCSETATTR)
{
data = _DEVCTL_DATA (msg);
switch (data -> c_ospeed)
{
case B4800 :
// make somethig . . .
break;
case B9600 :
// make something . . .
break;
default:
return (ENOSYS);
}
}
// tell the client it worked
memset (&msg -> o, 0, sizeof (msg ->o));
return (_RESMGR_PTR (ctp, &msg -> o, sizeof (msg -> o)));
}


These are the lines of my client test program that I use to set the baud
rate to 9600:

cfsetospeed( &termios_p, B9600 );
tcsetattr( fd, TCSANOW, &termios_p);


And this is the tcsetattr.c that I've downloaded from cvs.qnx.com:

#include <termios.h>
#include <devctl.h>
#include <sys/dcmd_chr.h>
#include <errno.h>

int tcsetattr(int fd, int optact, const struct termios *termios_p) {
int dcmd;

switch(optact) {
case TCSANOW:
dcmd = DCMD_CHR_TCSETATTR;
break;

case TCSADRAIN:
dcmd = DCMD_CHR_TCSETATTRD;
break;

case TCSAFLUSH:
dcmd = DCMD_CHR_TCSETATTRF;
break;

default:
errno = EINVAL;
return -1;
}

return _devctl(fd, dcmd, (void *)termios_p, sizeof *termios_p,
_DEVCTL_FLAG_NORETVAL | _DEVCTL_FLAG_NOTTY);
}

Post Reply

Return to “qdn.public.qnxrtp.x86”