Documentaton on serial devctl (dcmd_chr.h)

Hello All,

Anybody have an idea where I would find documentation on the macros in
dcmd_chr.h?

I’m doing some development on RTP and also Neutrino at work. I need to
toggle RTS to control RS-485 in a multidrop fashion. I found a doc in the
Knowledge base that describes how to do this in QNX 4. Unfortunately, it’s
not exactly the same in Neutrino/RTP.

I pretty much know what I want to do, but finding the documentation as a bit
frustrating.

Thanks in advance.
–Todd
todd_hitt@yahoo.com

Hi Todd

I am going through the same pains at the moment :stuck_out_tongue:
Hi Todd

I’m going thru the same process at the mo. The docs are very light here
(unless I haven’t found it yet) and like you I know exactly what I want to
do and it should be very simple but its frustrating finding anything on it.

What I have discovered is that to twiddle the bits you have to set (or
clear) the bit you want to change and then also set a bit to say you want to
change it: i.e.

ser_write_data|=_CTL_RTS; // set RTS bit
ser_write_data|=_CTL_RTS_CHG; // set this bit to make it change state
otherwise naff all will happen
res=devctl(fd, DCMD_CHR_SERCTL, &ser_write_data, sizeof(ser_write_data), 0);

to read the data I think you do a :

res=devctl(fd, DCMD_CHR_LINESTATUS, &ser_read_data, sizeof(ser_read_data),
0);

where ser_write_data and ser_read_data are 16bits (as far as I can
remember).


I’ve found though that reading the Ring Indicator bit in seems a bit
unreliable sometimes it doesn’t detect it as being set even though I can see
9v on it with a meter! Investigating this at the moment.

I’ve you find any documentation please let me know :slight_smile:

Hope this helps…

Cheers

Jim

Todd Hitt wrote in message <8suet9$493$2@inn.qnx.com>…

Hello All,

Anybody have an idea where I would find documentation on the macros in
dcmd_chr.h?

I’m doing some development on RTP and also Neutrino at work. I need to
toggle RTS to control RS-485 in a multidrop fashion. I found a doc in the
Knowledge base that describes how to do this in QNX 4. Unfortunately, it’s
not exactly the same in Neutrino/RTP.

I pretty much know what I want to do, but finding the documentation as a
bit
frustrating.

Thanks in advance.
–Todd
todd_hitt@yahoo.com

\

You’ve got exactly what I’ve been told / found out. I’m actually using the
read command to read the bits.

The problem I’m having at the moment it is seems to take devctl 13 msec to
deassert RTS. This is too long. The other devices on the RS-485 “network”
will have responded already. I’m investigating directly manipulating the
UART registers (and that’s not working but that’s another story).

I haven’t found any documentation and tech support told me that given that
I’m using a prerelease (I’m actually using Neutrino 2.0C) that some of the
docs aren’t finished.

–Todd

“Jim Atkins” <jamesa@tsd.serco.com> wrote in message
news:8t4b6l$bu0$1@inn.qnx.com

Hi Todd

I am going through the same pains at the moment > :stuck_out_tongue:
Hi Todd

I’m going thru the same process at the mo. The docs are very light here
(unless I haven’t found it yet) and like you I know exactly what I want to
do and it should be very simple but its frustrating finding anything on
it.

What I have discovered is that to twiddle the bits you have to set (or
clear) the bit you want to change and then also set a bit to say you want
to
change it: i.e.

ser_write_data|=_CTL_RTS; // set RTS bit
ser_write_data|=_CTL_RTS_CHG; // set this bit to make it change state
otherwise naff all will happen
res=devctl(fd, DCMD_CHR_SERCTL, &ser_write_data, sizeof(ser_write_data),
0);

to read the data I think you do a :

res=devctl(fd, DCMD_CHR_LINESTATUS, &ser_read_data, sizeof(ser_read_data),
0);

where ser_write_data and ser_read_data are 16bits (as far as I can
remember).


I’ve found though that reading the Ring Indicator bit in seems a bit
unreliable sometimes it doesn’t detect it as being set even though I can
see
9v on it with a meter! Investigating this at the moment.

I’ve you find any documentation please let me know > :slight_smile:

Hope this helps…

Cheers

Jim

Todd Hitt wrote in message <8suet9$493$> 2@inn.qnx.com> >…
Hello All,

Anybody have an idea where I would find documentation on the macros in
dcmd_chr.h?

I’m doing some development on RTP and also Neutrino at work. I need to
toggle RTS to control RS-485 in a multidrop fashion. I found a doc in
the
Knowledge base that describes how to do this in QNX 4. Unfortunately,
it’s
not exactly the same in Neutrino/RTP.

I pretty much know what I want to do, but finding the documentation as a
bit
frustrating.

Thanks in advance.
–Todd
todd_hitt@yahoo.com



\

Hi Todd,

Unfortunatly this isn’t well covered in documentation quite yet (or
at least the last time I looked).

The function you are going to want to use is devctl(), here is a
quick example on what you would want to do.


int blah()
{
int i_Data, i_fd;
int RTS_TOGGLE;

fd = open ("/dev/ser1", O_RDONLY);

RTS_TOGGLE = 1; // Turn RTS on.

i_Data = _CTL_RTS_CHG | (RTS_TOGGLE ? _CTL_RTS : 0);

devctl (i_fd, DCMD_CHR_SERCTL, &i_Data, sizeof(i_Data), NULL);

}


Look into the /usr/nto/include/sys/dcmd_chr.h header for a better understanding
of how it works. Also look into /usr/nto/include/devctl.h
By looking at those two headers you can derive how things work pretty quickly.

Take care.


Erick.





In qdn.public.qnxrtp.newuser Todd Hitt <todd_hitt@yahoo.com> wrote:

Hello All,

Anybody have an idea where I would find documentation on the macros in
dcmd_chr.h?

I’m doing some development on RTP and also Neutrino at work. I need to
toggle RTS to control RS-485 in a multidrop fashion. I found a doc in the
Knowledge base that describes how to do this in QNX 4. Unfortunately, it’s
not exactly the same in Neutrino/RTP.

I pretty much know what I want to do, but finding the documentation as a bit
frustrating.

Thanks in advance.
–Todd
todd_hitt@yahoo.com

Have you also had probelms reading back valid results like I was talking
about with RI?

CD/CTS and DSR seem to read back ok but RI is really unreliable - I don’t
know if I’m missing something here but if theres 9v on the pin surely it
should read back as a 1. As I said the others are ok.

Out of interest Todd, what are you using for your development tools - QNX4,
RTP or CodeWarrior on PC?

Hi Jim,

I haven’t had need to read back things like the ring indicator. So I can’t
comment on that.

The sage actually continues with devctl etc.

  1. I timed how long it takes devctl to deassert RTS. 13 msec (actually this
    is the time from the last character sent it out when RTS goes low). Way too
    long. The devices I’m talking to have already sent about 5 bytes back by
    then.

  2. So, I tries changing the bits in the register directlly using in8 and
    out8. First off, in my system, mmap_device_io doesn’t work. It return
    NULL. Tech support informed me that on the x86, all this basically does is
    return the address you pass in so I could bypass it.

  3. When I manipulate the register, life is good with RTS. However, my
    tcdrain function “hangs”. Even after all of the character’s have been sent
    (I’ve got a protocol analyzer), it doesn’t return.

  4. So, I’m kind of stuck. I’ll probalby try a DCMD_CHR_TCDRAIN, but I think
    that really out to be the same as tcdrain(). I could write my own driver
    and not use devc-ser8250 at all. I’ve got an existing DOS driver that we
    wrote. However, one of the reasons to QNX at all was to get away from the
    home grown driver.

–Todd

P.S. We’re using CodeWarrior, although I played with RTP at home over the
weekend.

“Jim Atkins” <jamesa@tsd.serco.com> wrote in message
news:8t6nll$a70$1@inn.qnx.com

Have you also had probelms reading back valid results like I was talking
about with RI?

CD/CTS and DSR seem to read back ok but RI is really unreliable - I don’t
know if I’m missing something here but if theres 9v on the pin surely it
should read back as a 1. As I said the others are ok.

Out of interest Todd, what are you using for your development tools -
QNX4,
RTP or CodeWarrior on PC?

\

Thanks Erick. I’ve now got this info. Just wish it didn’t take 13 msec to
turn RTS off (see my other post).

–Todd


“Erick Muis” <emuis@qnx.com> wrote in message
news:8t4i3i$pb2$1@nntp.qnx.com

Hi Todd,

Unfortunatly this isn’t well covered in documentation quite yet (or
at least the last time I looked).

The function you are going to want to use is devctl(), here is a
quick example on what you would want to do.


int blah()
{
int i_Data, i_fd;
int RTS_TOGGLE;

fd = open ("/dev/ser1", O_RDONLY);

RTS_TOGGLE = 1; // Turn RTS on.

i_Data = _CTL_RTS_CHG | (RTS_TOGGLE ? _CTL_RTS : 0);

devctl (i_fd, DCMD_CHR_SERCTL, &i_Data, sizeof(i_Data), NULL);

}


Look into the /usr/nto/include/sys/dcmd_chr.h header for a better
understanding
of how it works. Also look into /usr/nto/include/devctl.h
By looking at those two headers you can derive how things work pretty
quickly.

Take care.


Erick.





In qdn.public.qnxrtp.newuser Todd Hitt <> todd_hitt@yahoo.com> > wrote:
Hello All,

Anybody have an idea where I would find documentation on the macros in
dcmd_chr.h?

I’m doing some development on RTP and also Neutrino at work. I need to
toggle RTS to control RS-485 in a multidrop fashion. I found a doc in
the
Knowledge base that describes how to do this in QNX 4. Unfortunately,
it’s
not exactly the same in Neutrino/RTP.

I pretty much know what I want to do, but finding the documentation as a
bit
frustrating.

Thanks in advance.
–Todd
todd_hitt@yahoo.com

\

Hmmmm

I havent used the tcdrain stuff so I’m afraid I’ve no insights there.
Mmap_device_io works ok (on x86) for me though but as support stated it
returns the address passed in so you could fudge that.

The reason that I mentioned CodeWarrior is that it seems like your using the
same setup as me. I dunno what you’ve been expecting but I was expecting CW
to be released anytime now with the metrowerks toolchain and libraries. I
wouldn’t hold your breath for it though as it seems like its all ‘on hold’
at the moment. I was using CW and getting on fine but I’ve recently (in the
last week) changed over to using RTP as I’m a bit worried that the CW
release may not happen and I don’t want to get too far down the road in
development and find out that its not being released. I’ve
customers/delivery times to think of too. If you decide to go the same way
then I’ve gone thru the process of getting ddd/gdb debugging the target
board over the ethernet etc so I can halp a bit there. As far as a
comparable (with CW) IDE though - there isn’t one yet, so its back to
makefiles etc which causes a bit of overhead - especially if you’ve got a
lot of code in you CW projects. You may have heard differently on the
Codewarrior front but when I tried to get any info out of QSSL it sort of
went quiet and they said ‘you may want to try the RTP’. One advantage is
that you can test on the host (provided your not testing a bit of code that
exercises your in house hw)…


Cheers

Jim

one more thing. In your earlier mail you said that you were using the read
command to read the bits in. I’m probably being dense here but how are you
doing that (whats the call look like) and what do the bits relate to i.e.
how do you know what bit is what (or do they still tie up with whats in
dcmd_chr.h

I’m interested to see if reading back that way I get the same result (with
flaky results for RI) as usin devctl.

Cheers

Jim

Hi Todd,

Sorry I didn’t see the other postings, my post got cross posted through some
QUICS magic.

Regarding the timming issue, I wasn’t aware of how long it took. Mind you
when I had to use this code, it didn’t really matter to me how long it took
(within reason mind you) to me.

In qdn.public.qnxrtp.newuser Todd Hitt <todd_hitt@yahoo.com> wrote:

Thanks Erick. I’ve now got this info. Just wish it didn’t take 13 msec to
turn RTS off (see my other post).

–Todd



“Erick Muis” <> emuis@qnx.com> > wrote in message
news:8t4i3i$pb2$> 1@nntp.qnx.com> …
Hi Todd,

Unfortunatly this isn’t well covered in documentation quite yet (or
at least the last time I looked).

The function you are going to want to use is devctl(), here is a
quick example on what you would want to do.


int blah()
{
int i_Data, i_fd;
int RTS_TOGGLE;

fd = open ("/dev/ser1", O_RDONLY);

RTS_TOGGLE = 1; // Turn RTS on.

i_Data = _CTL_RTS_CHG | (RTS_TOGGLE ? _CTL_RTS : 0);

devctl (i_fd, DCMD_CHR_SERCTL, &i_Data, sizeof(i_Data), NULL);

}


Look into the /usr/nto/include/sys/dcmd_chr.h header for a better
understanding
of how it works. Also look into /usr/nto/include/devctl.h
By looking at those two headers you can derive how things work pretty
quickly.

Take care.


Erick.





In qdn.public.qnxrtp.newuser Todd Hitt <> todd_hitt@yahoo.com> > wrote:
Hello All,

Anybody have an idea where I would find documentation on the macros in
dcmd_chr.h?

I’m doing some development on RTP and also Neutrino at work. I need to
toggle RTS to control RS-485 in a multidrop fashion. I found a doc in
the
Knowledge base that describes how to do this in QNX 4. Unfortunately,
it’s
not exactly the same in Neutrino/RTP.

I pretty much know what I want to do, but finding the documentation as a
bit
frustrating.

Thanks in advance.
–Todd
todd_hitt@yahoo.com

\

I think I miscommunicated.

I’m using the read command to read the incoming message, not bits from the
8250’s register. I’m using devctl to do that.

It’s looking like I’m going to have to write my own “driver” and control the
8250 completely. On further investigation, playing with the 8250 register’s
causes the 8250 driver (or somebody) to become rather unhappy. My
application won’t read (it never returns) nor do a tcdrain (also never
returns) once I mess with things. It does do a write though!

Beats me.

–Todd

“Jim Atkins” <jamesa@tsd.serco.com> wrote in message
news:8t9cjd$5gn$1@inn.qnx.com

one more thing. In your earlier mail you said that you were using the read
command to read the bits in. I’m probably being dense here but how are you
doing that (whats the call look like) and what do the bits relate to i.e.
how do you know what bit is what (or do they still tie up with whats in
dcmd_chr.h

I’m interested to see if reading back that way I get the same result (with
flaky results for RI) as usin devctl.

Cheers

Jim
\

Todd, Jim, Erick

It has been 2 months since your postings in several of the QNX
newsgroups regarding Todd’s original question about controlling
the serial port for RS-485 communication. I am just starting up
some similar work and I was wondering if you ever resolved your
port access problem and how you achieved it.

Any pointers would be appreciated.

Duane Mattern <d.mattern@ieee.org>
Plymouth, MA USA

Erick Muis <emuis@qnx.com> wrote:

Hi Todd,
Sorry I didn’t see the other postings, my post got cross posted through some
QUICS magic.
Regarding the timming issue, I wasn’t aware of how long it took. Mind you
when I had to use this code, it didn’t really matter to me how long it took
(within reason mind you) to me.
In qdn.public.qnxrtp.newuser Todd Hitt <> todd_hitt@yahoo.com> > wrote:
Thanks Erick. I’ve now got this info. Just wish it didn’t take 13 msec to
turn RTS off (see my other post).

–Todd


“Erick Muis” <> emuis@qnx.com> > wrote in message
news:8t4i3i$pb2$> 1@nntp.qnx.com> …
Hi Todd,

Unfortunatly this isn’t well covered in documentation quite yet (or
at least the last time I looked).

The function you are going to want to use is devctl(), here is a
quick example on what you would want to do.


int blah()
{
int i_Data, i_fd;
int RTS_TOGGLE;

fd = open ("/dev/ser1", O_RDONLY);

RTS_TOGGLE = 1; // Turn RTS on.

i_Data = _CTL_RTS_CHG | (RTS_TOGGLE ? _CTL_RTS : 0);

devctl (i_fd, DCMD_CHR_SERCTL, &i_Data, sizeof(i_Data), NULL);

}


Look into the /usr/nto/include/sys/dcmd_chr.h header for a better
understanding
of how it works. Also look into /usr/nto/include/devctl.h
By looking at those two headers you can derive how things work pretty
quickly.

Take care.


Erick.





In qdn.public.qnxrtp.newuser Todd Hitt <> todd_hitt@yahoo.com> > wrote:
Hello All,

Anybody have an idea where I would find documentation on the macros in
dcmd_chr.h?

I’m doing some development on RTP and also Neutrino at work. I need to
toggle RTS to control RS-485 in a multidrop fashion. I found a doc in
the
Knowledge base that describes how to do this in QNX 4. Unfortunately,
it’s
not exactly the same in Neutrino/RTP.

I pretty much know what I want to do, but finding the documentation as a
bit
frustrating.

Thanks in advance.
–Todd
todd_hitt@yahoo.com